Skip to content

tskagent: fix incorrect comment parsing from key files#1

Merged
creachadair merged 1 commit into
mainfrom
mjf/fix-comment-parsing
Jun 6, 2026
Merged

tskagent: fix incorrect comment parsing from key files#1
creachadair merged 1 commit into
mainfrom
mjf/fix-comment-parsing

Conversation

@creachadair
Copy link
Copy Markdown
Member

The code to pull comments out of key data made some heuristic (but incorrect)
assumptions about the organization of the key. In particular, for keys where no
comment is defined, it could incorrectly grab an earlier field (e.g., one of
the key parameters) which would confuse a client expecting printable text.
Correctly process the fields we care about, so that when an empty comment is
set we don't grab the wrong thing by mistake.

Also, update the tests to cover RSA as well as ED25519 keys, and generate test
keys randomly. I ran the new tests 50,000 times under "stress" and was not able
to produce any new failures.

Thanks to @andrew-d for reporting this and for providing a failing test to
debug from.

Co-authored-by: Andrew Dunham andrew@tailscale.com

@creachadair creachadair requested a review from andrew-d June 6, 2026 00:12
The code to pull comments out of key data made some heuristic (but incorrect)
assumptions about the organization of the key. In particular, for keys where no
comment is defined, it could incorrectly grab an earlier field (e.g., one of
the key parameters) which would confuse a client expecting printable text.
Correctly process the fields we care about, so that when an empty comment is
set we don't grab the wrong thing by mistake.

Also, update the tests to cover RSA as well as ED25519 keys, and generate test
keys randomly. I ran the new tests 50,000 times under "stress" and was not able
to produce any new failures.

Thanks to @andrew-d for reporting this and for providing a failing test to
debug from.

Co-authored-by: Andrew Dunham <andrew@tailscale.com>
@creachadair creachadair force-pushed the mjf/fix-comment-parsing branch from 9f352e7 to 29cd974 Compare June 6, 2026 00:30
Copy link
Copy Markdown
Member

@andrew-d andrew-d left a comment

Choose a reason for hiding this comment

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

Thank you!

Comment thread internal_test.go
},
{
name: "RSA/Comment",
input: mustGenerateKey(t, genRSA, "what year is it"),
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

🤣

Comment thread tskagent.go
@creachadair creachadair merged commit 9c5cdbb into main Jun 6, 2026
1 check passed
@creachadair creachadair deleted the mjf/fix-comment-parsing branch June 6, 2026 01:44
creachadair added a commit that referenced this pull request Jun 6, 2026
As noted in #1, we rely on the keys not being passphrase locked, since the
agent has no way to prompt a user for the passphrase. Also add an example.
creachadair added a commit that referenced this pull request Jun 6, 2026
As noted in #1, we rely on the keys not being passphrase locked, since the
agent has no way to prompt a user for the passphrase. Also add an example.
creachadair added a commit that referenced this pull request Jun 6, 2026
As noted in #1, we rely on the keys not being passphrase locked, since the
agent has no way to prompt a user for the passphrase. Also add an example.
creachadair added a commit that referenced this pull request Jun 6, 2026
As noted in #1, we rely on the keys not being passphrase locked, since the
agent has no way to prompt a user for the passphrase. Also add an example.
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