crypto,config: guard against nil PublicKey in decoded signatures #396

Merged
brianmcgee merged 1 commits from fix/crypto-nil-handling into main 2026-04-08 11:15:23 +00:00
Owner

PublicKey.String(), URLEncoded(), Bytes(), and Equal() all panic when called on a nil receiver. A peer can exploit this by sending a Manifest with a missing network_id or signed_by, causing a nil-pointer panic in the stream-handler goroutine that crashes the daemon.

Add nil-receiver guards to PublicKey methods and an early nil-check
in SignatureAuth.Authorize() so malformed signatures are rejected
with an error rather than crashing the process.

`PublicKey.String()`, `URLEncoded()`, `Bytes()`, and `Equal()` all panic when called on a `nil` receiver. A peer can exploit this by sending a Manifest with a missing `network_id` or `signed_by`, causing a nil-pointer panic in the stream-handler goroutine that crashes the daemon. Add nil-receiver guards to `PublicKey` methods and an early nil-check in `SignatureAuth.Authorize()` so malformed signatures are rejected with an error rather than crashing the process.
brianmcgee requested review from pinpox 2026-04-08 10:04:30 +00:00
pinpox reviewed 2026-04-08 10:13:33 +00:00
@@ -51,6 +51,10 @@ func NewSignatureAuth(cfg *Config) *SignatureAuth {
}
func (sf *SignatureAuth) Authorize(sig *model.Signature) error {
if sig.NetworkID == nil || sig.SignedBy == nil {
Owner

what about sig == nil? (Not sure if that can happen here)

what about `sig == nil`? (Not sure if that can happen here)
brianmcgee marked this conversation as resolved
brianmcgee added 1 commit 2026-04-08 11:10:46 +00:00
crypto,config: guard against nil PublicKey in decoded signatures
buildbot/nix-eval Build done.
PR Size Review Check / pr-size-review-gate (pull_request) Successful in 56s
sizelint / sizelint (pull_request) Successful in 1m13s
buildbot/nix-build Build done.
gitea-mq/buildbot/nix-eval Build done.
gitea-mq/buildbot/nix-build Build done.
gitea-mq Merge queue passed
c7840edca5
`PublicKey.String()`, `URLEncoded()`, `Bytes()`, and `Equal()` all panic when called on a `nil` receiver. A peer can exploit this by sending a Manifest with a missing `network_id` or `signed_by`, causing a nil-pointer panic in the stream-handler goroutine that crashes the daemon.

Add nil-receiver guards to `PublicKey` methods and an early nil-check
in `SignatureAuth.Authorize()` so malformed signatures are rejected
with an error rather than crashing the process.
brianmcgee force-pushed fix/crypto-nil-handling from d2cdea2584 to c7840edca5 2026-04-08 11:10:46 +00:00 Compare
brianmcgee scheduled this pull request to auto merge when all checks succeed 2026-04-08 11:13:40 +00:00
brianmcgee merged commit b1df24ef80 into main 2026-04-08 11:15:23 +00:00
brianmcgee deleted branch fix/crypto-nil-handling 2026-04-08 11:15:23 +00:00
Sign in to join this conversation.