# SSH sequence number validity?

Looking at RFC4253, I came across the notion that the MAC is applied the encoded packet concatenated with a sequence number which acts as a counter.

However, I couldn't find any information on how that sequence number is validated. What happens if some messages get dropped or corrupted during transit?

Also, when do SSH connections get dropped? As in, decryption failure, MAC verification failure, etc.

However, I couldn't find any information on how that sequence number is validated. What happens if some messages get dropped or corrupted during transit?

SSH, similar to TLS, assumes that it is running over a reliable [1] transport protocol (such as TCP). If something goes wrong (e.g. some message is corrupted or dropped), then the system assumes that the system is under attack, and the connection is dropped.

This is explicitly stated in section 9.3.5 of RFC4251, which states:

This protocol is designed to be used over a reliable transport.  If
transmission errors or message manipulation occur, the connection is
closed.  The connection SHOULD be re-established if this occurs.


[1]: By reliable transport, I (as well as the RFC) mean that it delivers bytes correctly and in order, assuming that the system is not under attack.

• Great answer, thanks! However, where does that 'SHOULD be re-established' have its boundaries? Does the session undergo re-keying, re-authentication of parties, or is it simply a 'hiccup'? – Daniel B Jun 4 '18 at 11:12
• @DanielB: they'll have to restart the entire protocol, redoing the authentication. There is no option for doing anything less. – poncho Jun 4 '18 at 12:49