VerifyHMAC rejects uppercase-hex signatures, so some senders cannot be verified #1550

Closed
opened 2026-10-27 13:40:50 +00:00 by sam · 0 comments
Owner

internal/webhookguard/hmac.go:23 compares the computed digest against the supplied one as a case-sensitive hex string, having trimmed an optional sha256= prefix at :20-22. Hex digests are case-insensitive by convention and senders differ, so an uppercase-hex signature from any provider fails verification - and the failure looks like a wrong secret rather than a formatting mismatch.

internal/webhookguard is a shared helper imported by all three inbound surfaces (forge intake, the chat webhook gateway, capture intake), so one uppercase sender breaks whichever surface it targets.

Fix: decode both sides to bytes and compare with hmac.Equal. That is constant-time and case-insensitive, unlike strings.EqualFold over the encoded text. Add a table case for an uppercase digest. Found 2026-09-22 during the webhook evaluation.

Close reason

Shipped in 76563112: VerifyHMAC decodes the supplied signature and the computed digest to raw bytes and compares them with hmac.Equal, so hex case no longer matters. hex.DecodeString accepts either case; a non-hex signature is rejected outright; wrong-length digests cannot match. Red-first: the two uppercase cases failed against the old encoded-text comparison (verified failing from the assertion before implementing). 13 table cases, plus the four consumer packages green (forge/webhook, channels/webhook, captureintake, webhookguard) and task check clean.


Imported from beads archie-core-rl04 · GitHub #1121 · type bug · priority P2 · created 2026-09-21 · closed 2026-10-02

internal/webhookguard/hmac.go:23 compares the computed digest against the supplied one as a case-sensitive hex string, having trimmed an optional sha256= prefix at :20-22. Hex digests are case-insensitive by convention and senders differ, so an uppercase-hex signature from any provider fails verification - and the failure looks like a wrong secret rather than a formatting mismatch. internal/webhookguard is a shared helper imported by all three inbound surfaces (forge intake, the chat webhook gateway, capture intake), so one uppercase sender breaks whichever surface it targets. Fix: decode both sides to bytes and compare with hmac.Equal. That is constant-time and case-insensitive, unlike strings.EqualFold over the encoded text. Add a table case for an uppercase digest. Found 2026-09-22 during the webhook evaluation. ### Close reason Shipped in 76563112: VerifyHMAC decodes the supplied signature and the computed digest to raw bytes and compares them with hmac.Equal, so hex case no longer matters. hex.DecodeString accepts either case; a non-hex signature is rejected outright; wrong-length digests cannot match. Red-first: the two uppercase cases failed against the old encoded-text comparison (verified failing from the assertion before implementing). 13 table cases, plus the four consumer packages green (forge/webhook, channels/webhook, captureintake, webhookguard) and task check clean. --- _Imported from beads `archie-core-rl04` · GitHub #1121 · type bug · priority P2 · created 2026-09-21 · closed 2026-10-02_
sam added the mediumbug labels 2026-10-27 13:40:50 +00:00
sam self-assigned this 2026-10-27 13:40:50 +00:00
sam closed this issue 2026-10-27 13:40:50 +00:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sam/archie#1550