Skip to content

ssh: quote remaining peer-controlled strings in error messages - #381

Closed
DeRuina wants to merge 2 commits into
golang:masterfrom
DeRuina:ssh-quote-peer-strings
Closed

DeRuina wants to merge 2 commits into
golang:masterfrom
DeRuina:ssh-quote-peer-strings

Conversation

@DeRuina

@DeRuina DeRuina commented Nov 7, 2026 •

Copy link
Copy Markdown
Contributor

CL 798420 switched peer-controlled strings in error messages to %q,
but a few sites still print them unquoted:

  • Waitmsg.String (and so ExitError.Error) prints the signal name
    and message from the server's exit-signal request.
  • parsePubKey prints the algorithm name read from the key blob.
  • The PublicKey.Verify implementations print the signature format.
  • The server's error for a service requested before authentication
    prints the service name sent by the client.

A malicious peer can use these to put control characters into a
client's terminal or logs. Quote them with %q like the other
messages. Signal, Msg and Lang still return the raw values.

Updates golang/go#80301

@gopherbot

Copy link
Copy Markdown
Contributor

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

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

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.

CL 798420 switched peer-controlled strings in error messages to %q,
but a few sites still print them unquoted:

  - Waitmsg.String (and so ExitError.Error) prints the signal name
    and message from the server's exit-signal request.
  - parsePubKey prints the algorithm name read from the key blob.
  - The PublicKey.Verify implementations print the signature format.

A malicious peer can use these to put control characters into a
client's terminal or logs. Quote them with %q like the other
messages. Signal, Msg and Lang still return the raw values.

Updates golang/go#80301

Change-Id: I9d8afa7853d7568a1974cf3a7e5aa16aa9a875e7
@DeRuina
DeRuina force-pushed the ssh-quote-peer-strings branch from bc5bc54 to 7ecdf44 Compare November 7, 2026 13:08
@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/861081.
After addressing review feedback, remember to publish your drafts!

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Dean Ruina:

Patch Set 1:

(1 comment)


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

@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 7ecdf44) has been imported to Gerrit for code review.

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

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

Message from Dean Ruina:

Patch Set 2:

(1 comment)


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

Quote the service name in the server's error for a service requested
before authenticating, and remove the comment in Session.wait.

Updates golang/go#80301

Change-Id: Ib90ee2ff4ffb31addaa3595acf7f9ee73614e6a6
@gopherbot

Copy link
Copy Markdown
Contributor

Message from Nicola Murino:

Patch Set 2:

(1 comment)


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

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Nicola Murino:

Patch Set 2:

(1 comment)


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

@gopherbot

Copy link
Copy Markdown
Contributor

This PR (HEAD: 1ca8daf) has been imported to Gerrit for code review.

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

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

Message from Dean Ruina:

Patch Set 3:

(2 comments)


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

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Nicola Murino:

Patch Set 3: Code-Review+2


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

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Nicola Murino:

Patch Set 3: Commit-Queue+1


Please don’t reply on this GitHub thread. Visit golang.org/cl/861081.
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 3:

Dry run: CV is trying the patch.

Bot data: {"action":"start","triggered_at":"2026-11-09T18:47:53Z","revision":"1c6133caa6b58f4c42acc4016224a18af48edf01"}


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

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Nicola Murino:

Patch Set 3: -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/861081.
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 3:

This CL has passed the run


Please don’t reply on this GitHub thread. Visit golang.org/cl/861081.
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 3: LUCI-TryBot-Result+1


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

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Michael Pratt:

Patch Set 4: Code-Review+1


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

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Nicholas Husin:

Patch Set 4: Code-Review+1

(1 comment)


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

@gopherbot

Copy link
Copy Markdown
Contributor

Message from Nicholas Husin:

Patch Set 4: Code-Review+1


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

gopherbot pushed a commit that referenced this pull request Nov 11, 2026
CL 798420 switched peer-controlled strings in error messages to %q,
but a few sites still print them unquoted:

  - Waitmsg.String (and so ExitError.Error) prints the signal name
    and message from the server's exit-signal request.
  - parsePubKey prints the algorithm name read from the key blob.
  - The PublicKey.Verify implementations print the signature format.
  - The server's error for a service requested before authentication
    prints the service name sent by the client.

A malicious peer can use these to put control characters into a
client's terminal or logs. Quote them with %q like the other
messages. Signal, Msg and Lang still return the raw values.

Updates golang/go#80301

Change-Id: I1b0020bb6892d481b3b22129990043c3c805c5d5
GitHub-Last-Rev: 1ca8daf
GitHub-Pull-Request: #381
Reviewed-on: https://go-review.googlesource.com/c/crypto/+/861081
LUCI-TryBot-Result: golang-scoped@luci-project-accounts.iam.gserviceaccount.com <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
Reviewed-by: Nicholas Husin <nsh@golang.org>
Reviewed-by: Nicholas Husin <husin@google.com>
Reviewed-by: Nicola Murino <nicola.murino@gmail.com>
@gopherbot

Copy link
Copy Markdown
Contributor

This PR is being closed because golang.org/cl/861081 has been merged.

@gopherbot gopherbot closed this Nov 11, 2026
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