You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Memory write overflow in userauth_keyboard_interactive #649
Vulnerability
libssh2 does not check userauth_kybd_auth_name_len which comes from a remote server and uses it as memcpy's argument. A remote attacker who compromises a SSH server may be able to crash the client when a user connects to the server.
If the size is wrong, like too big, then the copy will indeed contain data from adjacent bytes in the packet and it will put that data into the memory area for userauth_kybd_auth_name - but I don't see how that makes it vulnerable, just wrong. It can of course lead to a crash, and thus this could possibly be used as a mild DOS. But then the server can always cause the client to disconnect...
Sorry for post poc first, and I've hidden the project. You are very right. The adjacent bytes can be copied to userauth_kybd_auth_name. This could be an info leak, but I think it can hardly be exploited because there are checks for the next fields, so the client would just exit or crash.
Activity
bagder commentedon Dec 17, 2021
First: you don't post suspected security flaws in the public. You hurt all users running this code.
Are you talking about this code?
libssh2/src/userauth.c
Lines 1769 to 1784 in 9990b38
I agree that blindly using the size is silly, but it does allocate a block with the given size before the copy is done. Is that not enough?
bagder commentedon Dec 17, 2021
If the size is wrong, like too big, then the copy will indeed contain data from adjacent bytes in the packet and it will put that data into the memory area for userauth_kybd_auth_name - but I don't see how that makes it vulnerable, just wrong. It can of course lead to a crash, and thus this could possibly be used as a mild DOS. But then the server can always cause the client to disconnect...
userauth: check for too large userauth_kybd_auth_name_len
MarcoPoloPie commentedon Dec 17, 2021
Sorry for post poc first, and I've hidden the project. You are very right. The adjacent bytes can be copied to userauth_kybd_auth_name. This could be an info leak, but I think it can hardly be exploited because there are checks for the next fields, so the client would just exit or crash.
LayZeeDK commentedon Dec 17, 2021
@MarcoPoloPie
Please refer to https://github.com/libssh2/libssh2/security/policy 🙂
userauth: check for too large userauth_kybd_auth_name_len (#650)
userauth: check for too large userauth_kybd_auth_name_len (libssh2#650)