csharp: Accept a valid signature when it is last in a multi-sig header#2393
Merged
svix-james merged 1 commit intoJun 15, 2026
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What's broken
In the C# SDK,
Webhook.Verifysilently drops the last signature in a space-separatedsvix-signature/webhook-signatureheader. If the only signature matching your secret is last in the list, verification throwsWebhookVerificationException("No matching signature found")and a legitimate webhook is rejected. Multiple signatures in one header occur in normal operation during signing-secret rotation, so this rejects valid traffic.Why it happens
The signature loop is a
do { ... } while (spaceIndex >= 0)that computes the current segment from the previous iteration'sspaceIndexand updatesspaceIndexinside the body. When the second-to-last segment is processed,spaceIndexbecomes-1, so the loop exits before the final segment is ever evaluated. The existingTestMultiSigPayloadIsValiddoesn't catch it because its valid signature sits in the middle of the list, never last.Fix
Replace the
do/whilewith awhile (!signaturePtr.IsEmpty)loop that recomputes the next space boundary from the remaining span on each iteration and handles the trailing segment explicitly. Behavior is otherwise identical (samev1filtering andSecureCompare).Test
Added
TestMultiSigPayloadValidSignatureLastIsValid, which places the valid signature last of two. It fails before the change (No matching signature found) and passes after; the full webhook suite stays green (18/18).