Skip to content

cmd/age: avoid int overflow in sshKeyType on 32-bit platforms#697

Open
sweis wants to merge 1 commit intoFiloSottile:mainfrom
sweis:claude/fix-sshkeytype-overflow-HXoHp
Open

cmd/age: avoid int overflow in sshKeyType on 32-bit platforms#697
sweis wants to merge 1 commit intoFiloSottile:mainfrom
sweis:claude/fix-sshkeytype-overflow-HXoHp

Conversation

@sweis
Copy link

@sweis sweis commented Mar 12, 2026

sshKeyType reads a uint32 length prefix and casts it to int for
cryptobyte.ReadBytes. On 32-bit platforms a value ≥ 2^31 becomes negative
and cryptobyte panics, so a malformed recipients file can crash the CLI.

Fix: check the length against the remaining buffer before the cast.

Test: go test ./cmd/age/ -run TestSSHKeyTypeOverflowLength -v
(uses recover() to catch the panic on 32-bit; on 64-bit it asserts graceful
rejection.)

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