Skip to content
This repository was archived by the owner on Jan 26, 2026. It is now read-only.

Commit a6e055c

Browse files
ansasakicryptomilk
authored andcommitted
packet: Allow SSH2_MSG_EXT_INFO when authenticated
When the server requests rekey, it can send the SSH2_MSG_EXT_INFO. This message was being filtered out by the packet filtering. This includes a test to enforce the filtering rules for this packet type. Signed-off-by: Anderson Toshiyuki Sasaki <ansasaki@redhat.com> Reviewed-by: Andreas Schneider <asn@cryptomilk.org> (cherry picked from commit fe309ba)
1 parent 32221ea commit a6e055c

2 files changed

Lines changed: 36 additions & 1 deletion

File tree

src/packet.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,13 +263,17 @@ static enum ssh_packet_filter_result_e ssh_packet_incoming_filter(ssh_session se
263263
/*
264264
* States required:
265265
* - session_state == SSH_SESSION_STATE_AUTHENTICATING
266+
* or session->session_state == SSH_SESSION_STATE_AUTHENTICATED
267+
* (re-exchange)
266268
* - dh_handshake_state == DH_STATE_FINISHED
267269
*
268270
* Transitions:
269271
* - None
270272
* */
271273

272-
if (session->session_state != SSH_SESSION_STATE_AUTHENTICATING) {
274+
if ((session->session_state != SSH_SESSION_STATE_AUTHENTICATING) &&
275+
(session->session_state != SSH_SESSION_STATE_AUTHENTICATED))
276+
{
273277
rc = SSH_PACKET_DENIED;
274278
break;
275279
}

tests/unittests/torture_packet_filter.c

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,36 @@ static void torture_packet_filter_check_auth_success(void **state)
462462
assert_int_equal(rc, 0);
463463
}
464464

465+
static void torture_packet_filter_check_msg_ext_info(void **state)
466+
{
467+
int rc;
468+
469+
global_state accepted[] = {
470+
{
471+
.flags = (COMPARE_SESSION_STATE |
472+
COMPARE_DH_STATE),
473+
.session = SSH_SESSION_STATE_AUTHENTICATING,
474+
.dh = DH_STATE_FINISHED,
475+
},
476+
{
477+
.flags = (COMPARE_SESSION_STATE |
478+
COMPARE_DH_STATE),
479+
.session = SSH_SESSION_STATE_AUTHENTICATED,
480+
.dh = DH_STATE_FINISHED,
481+
},
482+
};
483+
484+
int accepted_count = 2;
485+
486+
/* Unused */
487+
(void) state;
488+
489+
rc = check_message_in_all_states(accepted, accepted_count,
490+
SSH2_MSG_EXT_INFO);
491+
492+
assert_int_equal(rc, 0);
493+
}
494+
465495
static void torture_packet_filter_check_channel_open(void **state)
466496
{
467497
int rc;
@@ -492,6 +522,7 @@ int torture_run_tests(void)
492522
cmocka_unit_test(torture_packet_filter_check_auth_success),
493523
cmocka_unit_test(torture_packet_filter_check_channel_open),
494524
cmocka_unit_test(torture_packet_filter_check_unfiltered),
525+
cmocka_unit_test(torture_packet_filter_check_msg_ext_info)
495526
};
496527

497528
ssh_init();

0 commit comments

Comments
 (0)