Skip to content

Commit 6b0e004

Browse files
committed
Don't end strict kex until receiving newkeys
Previously non-strict packets would be allowed once Dropbear's own SSH_MSG_NEWKEYS had been sent, but for correctness it should only be allowed once receiving the SSH_MSG_NEWKEYS from the peer. Reported by Fabian Bäumer
1 parent 3eafae7 commit 6b0e004

File tree

3 files changed

+3
-1
lines changed

3 files changed

+3
-1
lines changed

src/common-kex.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,7 @@ void recv_msg_newkeys() {
197197
if (ses.kexstate.strict_kex) {
198198
ses.recvseq = 0;
199199
}
200+
ses.kexstate.recvfirstnewkeys = 1;
200201

201202
TRACE(("leave recv_msg_newkeys"))
202203
}

src/kex.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,7 @@ struct KEXState {
9191
unsigned int donefirstkex; /* Set to 1 after the first kex has completed,
9292
ie the transport layer has been set up */
9393
unsigned int donesecondkex; /* Set to 1 after the second kex has completed */
94+
unsigned int recvfirstnewkeys; /* Set to 1 after the first valid newkeys has been received */
9495

9596
unsigned our_first_follows_matches : 1;
9697

src/process-packet.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ void process_packet() {
4444

4545
unsigned char type;
4646
unsigned int i;
47-
unsigned int first_strict_kex = ses.kexstate.strict_kex && !ses.kexstate.donefirstkex;
47+
unsigned int first_strict_kex = ses.kexstate.strict_kex && !ses.kexstate.recvfirstnewkeys;
4848
time_t now;
4949

5050
TRACE2(("enter process_packet"))

0 commit comments

Comments
 (0)