Skip to content

x/crypto/ssh: validate DSA parameters in ParseDSAPrivateKey#365

Open
kingljl wants to merge 1 commit into
golang:masterfrom
kingljl:fix-ParseDSAPrivateKey
Open

x/crypto/ssh: validate DSA parameters in ParseDSAPrivateKey#365
kingljl wants to merge 1 commit into
golang:masterfrom
kingljl:fix-ParseDSAPrivateKey

Conversation

@kingljl

@kingljl kingljl commented Jul 16, 2026

Copy link
Copy Markdown

ParseDSAPrivateKey constructed a *dsa.PrivateKey without validating the
DSA parameters, unlike the public-key path (parseDSA). A maliciously
crafted key with an oversized Q or out-of-range Y/X could slow signing
or verification. Apply checkDSAParams and range-check Y (matching the
public-key path) and X (the private key value).

Fixes golang/go#80418

@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 52ec342) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/crypto/+/801440.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@kingljl kingljl changed the title ssh: validate DSA parameters in ParseDSAPrivateKey x/crypto/ssh: validate DSA parameters in ParseDSAPrivateKey Jul 16, 2026
@gopherbot

Copy link
Copy Markdown
Contributor

Message from Gopher Robot:

Patch Set 1:

(1 comment)


Please don’t reply on this GitHub thread. Visit golang.org/cl/801440.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Nicola Murino:

Patch Set 2:

(4 comments)


Please don’t reply on this GitHub thread. Visit golang.org/cl/801440.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Nicola Murino:

Patch Set 2: Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/801440.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 2:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2026-07-19T12:32:16Z","revision":"f74ba3f0fc64327514aafcfaa9e8f5c762a54654"}


Please don’t reply on this GitHub thread. Visit golang.org/cl/801440.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Nicola Murino:

Patch Set 2: -Commit-Queue

(Performed by <GERRIT_ACCOUNT_60063> on behalf of <GERRIT_ACCOUNT_35201>)


Please don’t reply on this GitHub thread. Visit golang.org/cl/801440.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 2:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/801440.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from golang-scoped@luci-project-accounts.iam.gserviceaccount.com:

Patch Set 2: LUCI-TryBot-Result+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/801440.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 85fd16f) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/crypto/+/801440.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 86cf48c) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/crypto/+/801440.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@kingljl
kingljl force-pushed the fix-ParseDSAPrivateKey branch 2 times, most recently from 1177747 to 7994d3a Compare July 20, 2026 03:33
ParseDSAPrivateKey constructed a *dsa.PrivateKey without validating the
DSA parameters, unlike the public-key path (parseDSA). A maliciously
crafted key with an oversized Q or out-of-range Y/X could slow signing
or verification. Apply checkDSAParams and range-check Y and X, matching
the public-key path.

This is a backward-incompatible change: the key must use parameter size
L1024N160, so keys with other parameter sizes (for example a 2048-bit
DSA key) that previously parsed now fail at parse time. Such keys could
never become a usable SSH signer, matching NewSignerFromKey.
@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 7994d3a) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/crypto/+/801440.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

@kingljl
kingljl force-pushed the fix-ParseDSAPrivateKey branch from 7994d3a to 140584d Compare July 20, 2026 03:35
@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 140584d) has been imported to Gerrit for code review.

Please visit Gerrit at https://go-review.googlesource.com/c/crypto/+/801440.

Important tips:

  • Don't comment on this PR. All discussion takes place in Gerrit.
  • You need a Gmail or other Google account to log in to Gerrit.
  • To change your code in response to feedback:
    • Push a new commit to the branch used by your GitHub PR.
    • A new "patch set" will then appear in Gerrit.
    • Respond to each comment by marking as Done in Gerrit if implemented as suggested. You can alternatively write a reply.
    • Critical: you must click the blue Reply button near the top to publish your Gerrit responses.
    • Multiple commits in the PR will be squashed by GerritBot.
  • The title and description of the GitHub PR are used to construct the final commit message.
    • Edit these as needed via the GitHub web interface (not via Gerrit or git).
    • You should word wrap the PR description at ~76 characters unless you need longer lines (e.g., for tables or URLs).
  • See the Sending a change via GitHub and Reviews sections of the Contribution Guide as well as the FAQ for details.

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.

x/crypto/ssh: ParseDSAPrivateKey lacks validation for DSA parameters

2 participants