Skip to content

Limit remote maximum packet size announced by the server - #1196

Open
mwiede wants to merge 1 commit into
masterfrom
fix/limit-remote-packet-size
Open

mwiede wants to merge 1 commit into
masterfrom
fix/limit-remote-packet-size

Conversation

@mwiede

@mwiede mwiede commented Oct 22, 2026

Copy link
Copy Markdown
Owner

The remote maximum packet size from SSH_MSG_CHANNEL_OPEN_CONFIRMATION was stored without validation and later used to allocate Buffers, so a malicious server could trigger OutOfMemoryError or NegativeArraySizeException. Cap it at PACKET_MAX_SIZE - 4096, which is always protocol-compliant as it is only an upper bound for what we send. Also guard the SFTP pipe size computation against int overflow.

Reported by pyj kor.

The remote maximum packet size from SSH_MSG_CHANNEL_OPEN_CONFIRMATION
was stored without validation and later used to allocate Buffers, so a
malicious server could trigger OutOfMemoryError or
NegativeArraySizeException. Cap it at PACKET_MAX_SIZE - 4096, which is
always protocol-compliant as it is only an upper bound for what we send.
Also guard the SFTP pipe size computation against int overflow.

Reported by pyj kor.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@norrisjeremy norrisjeremy left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch!

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants