ssh/agent: bound RSA modulus and DSA parameters in key parsers#347
Open
tonghuaroot wants to merge 1 commit into
Open
ssh/agent: bound RSA modulus and DSA parameters in key parsers#347tonghuaroot wants to merge 1 commit into
tonghuaroot wants to merge 1 commit into
Conversation
The agent server's key parsers accept attacker-controlled RSA moduli and DSA P/Q/G parameters of arbitrary size from SSH_AGENTC_ADD_IDENTITY and SSH2_AGENTC_ADD_ID_CONSTRAINED messages, then run expensive crypto such as rsa.PrivateKey.Precompute with no size bound. A single oversized key (e.g. a 16384-bit RSA modulus) can cost hundreds of milliseconds to process, giving large CPU amplification per packet and allowing a malicious remote server reached over agent forwarding to peg a Go-based ssh-agent. Bound the sizes in parseRSAKey, parseRSACert, parseDSAKey, and parseDSACert, mirroring the limits the same package already enforces on the SSH-server side in ssh/keys.go: an 8192-bit RSA modulus cap and the FIPS 186-2 DSA parameter checks (1024-bit P, 160-bit Q, and a generator in range). Fixes golang/go#79725
Contributor
|
This PR (HEAD: cde0ba3) has been imported to Gerrit for code review. Please visit Gerrit at https://go-review.googlesource.com/c/crypto/+/784660. Important tips:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The agent server's key parsers accept attacker-controlled RSA moduli and
DSA P/Q/G parameters of arbitrary size from SSH_AGENTC_ADD_IDENTITY and
SSH2_AGENTC_ADD_ID_CONSTRAINED messages, then run expensive crypto such as
rsa.PrivateKey.Precompute with no size bound. A single oversized key (e.g.
a 16384-bit RSA modulus) can cost hundreds of milliseconds to process,
giving large CPU amplification per packet and allowing a malicious remote
server reached over agent forwarding to peg a Go-based ssh-agent.
Bound the sizes in parseRSAKey, parseRSACert, parseDSAKey, and parseDSACert,
mirroring the limits the same package already enforces on the SSH-server
side in ssh/keys.go: an 8192-bit RSA modulus cap and the FIPS 186-2 DSA
parameter checks (1024-bit P, 160-bit Q, and a generator in range).
Fixes golang/go#79725