Skip to content

Commit

Permalink
Comment fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
tomaswolf committed Jun 6, 2024
1 parent b4ee576 commit 8f6e96f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1612,13 +1612,15 @@ protected void decode() throws Exception {
if (!lengthOK) {
decoderBuffer.dumpHex(getSimplifiedLogger(), Level.FINEST,
"decode(" + this + ") invalid length packet", this);
// Mitigation against CVE-2008-5161 AKA CPNI-957037: make any disconnections due to decoding errors indistinguishable.
// Mitigation against CVE-2008-5161 AKA CPNI-957037: make any disconnections due to decoding
// errors indistinguishable from failed MAC checks.
//
// If we disconnect here, a client may still deduce (since it sent only one block) that the length check failed.
// So we keep on requesting more data and fail later. OpenSSH actually discards the next 256kB of data, but in fact
// any number of bytes will do.
// If we disconnect here, a client may still deduce (since it sent only one block) that the
// length check failed. So we keep on requesting more data and fail later. OpenSSH actually
// discards the next 256kB of data, but in fact any number of bytes will do.
//
// Remember the exception, continue requiring an arbitrary number of bytes, and throw the exception later.
// Remember the exception, continue requiring an arbitrary number of bytes, and throw the
// exception later.
discarding = new SshException(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR,
"Invalid packet length: " + decoderLength);
decoderLength = decoderBuffer.available() + (2 + random.random(20)) * inCipherSize;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1191,7 +1191,7 @@ public void disconnect(int reason, String msg) throws IOException {
switch (reason) {
case SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR:
case SshConstants.SSH2_DISCONNECT_MAC_ERROR:
// OpenSSH *always* sends back DISCONNECT_PROTOCOL_ERROR
// OpenSSH *always* sends back DISCONNECT_PROTOCOL_ERROR.
buffer.putInt(SshConstants.SSH2_DISCONNECT_PROTOCOL_ERROR);
// Yes, we don't tell the peer what exactly was wrong.
buffer.putString("Protocol error or corrupt packet");
Expand Down

0 comments on commit 8f6e96f

Please sign in to comment.