aboutsummaryrefslogtreecommitdiff
path: root/src/packet_cb.c
diff options
context:
space:
mode:
authorAris Adamantiadis <aris@0xbadc0de.be>2015-04-15 16:08:37 +0200
committerAndreas Schneider <asn@cryptomilk.org>2015-04-23 10:15:47 +0200
commitbf0c7ae0aeb0ebe661d11ea6785fff2cbf4f3dbe (patch)
tree0375ca3419731a32b6192b362e8d78db01dfd8f9 /src/packet_cb.c
parentb5dc8197f78b6639ca75aa93d6c421c0181d0f32 (diff)
downloadlibssh-bf0c7ae0aeb0ebe661d11ea6785fff2cbf4f3dbe.tar.gz
libssh-bf0c7ae0aeb0ebe661d11ea6785fff2cbf4f3dbe.tar.xz
libssh-bf0c7ae0aeb0ebe661d11ea6785fff2cbf4f3dbe.zip
CVE-2015-3146: Fix state validation in packet handlers
The state validation in the packet handlers for SSH_MSG_NEWKEYS and SSH_MSG_KEXDH_REPLY had a bug which did not raise an error. The issue has been found and reported by Mariusz Ziule. Signed-off-by: Aris Adamantiadis <aris@0xbadc0de.be> Reviewed-by: Andreas Schneider <asn@cryptomilk.org>
Diffstat (limited to 'src/packet_cb.c')
-rw-r--r--src/packet_cb.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/packet_cb.c b/src/packet_cb.c
index 17e39a4c..4fe6402a 100644
--- a/src/packet_cb.c
+++ b/src/packet_cb.c
@@ -97,7 +97,7 @@ SSH_PACKET_CALLBACK(ssh_packet_dh_reply){
(void)type;
(void)user;
SSH_LOG(SSH_LOG_PROTOCOL,"Received SSH_KEXDH_REPLY");
- if(session->session_state!= SSH_SESSION_STATE_DH &&
+ if (session->session_state != SSH_SESSION_STATE_DH ||
session->dh_handshake_state != DH_STATE_INIT_SENT){
ssh_set_error(session,SSH_FATAL,"ssh_packet_dh_reply called in wrong state : %d:%d",
session->session_state,session->dh_handshake_state);
@@ -138,12 +138,16 @@ SSH_PACKET_CALLBACK(ssh_packet_newkeys){
(void)user;
(void)type;
SSH_LOG(SSH_LOG_PROTOCOL, "Received SSH_MSG_NEWKEYS");
- if(session->session_state!= SSH_SESSION_STATE_DH &&
- session->dh_handshake_state != DH_STATE_NEWKEYS_SENT){
- ssh_set_error(session,SSH_FATAL,"ssh_packet_newkeys called in wrong state : %d:%d",
- session->session_state,session->dh_handshake_state);
- goto error;
+
+ if (session->session_state != SSH_SESSION_STATE_DH ||
+ session->dh_handshake_state != DH_STATE_NEWKEYS_SENT) {
+ ssh_set_error(session,
+ SSH_FATAL,
+ "ssh_packet_newkeys called in wrong state : %d:%d",
+ session->session_state,session->dh_handshake_state);
+ goto error;
}
+
if(session->server){
/* server things are done in server.c */
session->dh_handshake_state=DH_STATE_FINISHED;