Patching PublicKeyCallback for CVE-2024-45337
- Dominant language
- Go
- Stars
- 4.2k
- Forks
- 509
- PR merge metrics
- No merged PRs in 30d
Description
From [[security] Vulnerability in golang.org/x/crypto](https://groups.google.com/g/golang-announce/c/-nPEi39gI4Q/m/cGVPJCqdAQAJ?utm_medium=email&utm_source=footer):
> For example, an attacker may send public keys A and B, and then authenticate with A. PublicKeyCallback would be called only twice, first with A and then with B. A vulnerable application may then make authorization decisions based on key B for which the attacker does not actually control the private key.
> golang.org/x/crypto@v0.31.0 enforces the property that, when successfully authenticating via public key, the last key passed to ServerConfig.PublicKeyCallback will be the key used to authenticate the connection.
I'm worried that this fix isn't sufficient given this package's use of PublicKeyCallback, because `applyConnMetadata` only ever sets context values on its first call:
https://github.com/gliderlabs/ssh/blob/adec695b0aa80b0a03f251e1f8c302f0ea192ef5/context.go#L114-L116
I.e., the fact that v0.31.0 makes additional calls to PublicKeyCallback won't actually help here, because only the values from the first call get stored in the ctx.
Does that seem correct? If so, should `applyConnMetadata` be patched so that we used the values from the _last_ call? Or would some other patch be appropriate?
Contributor guide
No contributing guide indexed for this repository
Assessment
This issue has not been assessed yet.