fix: X-StellarGate-Event header is informational-only, route on signed body (#160) - #180
Merged
Manuel1234477 merged 2 commits intoJul 21, 2026
Conversation
…ned body (StellarGateLabs#160) The X-StellarGate-Event header is not covered by the HMAC signature — it can be altered in transit without invalidating the sig. This was a latent security issue: receivers that routed on the header rather than the signed body could be misled about the event type. The body already contains an authenticated `event` field (produced by build_payload and covered by the HMAC over "{timestamp}.{body}"), so no change to the signing scheme is needed. The fix is documentation, clear inline warnings, and tests that lock the contract. Changes: - webhook.rs module doc: list X-StellarGate-Event as a third header, explicitly marked NOT signed, with a note to route on the body field - sign() doc: note that the body already contains the event field, so event type is authenticated through the signature - dispatch() doc + inline comment: call out that the header is a convenience mirror of the body, not part of signed material - payments.rs redeliver_webhook(): same inline comment at the header send site - README: updated Verifying webhooks header table, added step 6 (read event from verified body), expanded Node.js example with a handleWebhook() that routes on body.event not the header - Tests: build_payload_includes_event_in_signed_body (unit) and event_field_in_body_matches_header_and_is_covered_by_signature (integration) lock the contract Also fixes pre-existing compile errors on main (parse_env missing ?, sqlx::Error conversion), updates anyhow 1.0.104 (RUSTSEC-2026-0190), spin 0.9.9 (yanked), and removes stale deny.toml entries. Fixes StellarGateLabs#160
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.
Summary
Pr Closes #160
The
X-StellarGate-Eventheader is not covered by the HMAC signature — it can be altered in transit without invalidating the signature. Receivers that routed on the header rather than the signed body could be misled about the event type.The
eventfield is already present in the signed JSON body (produced bybuild_payloadand covered by HMAC over"{timestamp}.{body}"), so no change to the signing scheme is required. The fix is documentation, clear inline warnings, and tests that lock the contract.Changes
src/webhook.rs— module doc: listsX-StellarGate-Eventas a convenience header, explicitly marked NOT signed, with a clear instruction to route on the bodyeventfield after verifying the signature.src/webhook.rs—sign()doc: notes that the body already contains theeventfield so the event type is fully authenticated by the HMAC.src/webhook.rs—dispatch(): updated doc comment and inline comment at the header send site.src/api/payments.rs—redeliver_webhook(): same inline comment at the header send site.README.md: updated the Verifying webhooks header table (added theX-StellarGate-Eventrow with its informational-only note), added step 6 (readeventfrom the verified body), and expanded the Node.js example with ahandleWebhook()function that routes onbody.event, not the header.build_payload_includes_event_in_signed_body(unit,webhook.rs) — asserts theeventfield is present in the serialised body for all event types.event_field_in_body_matches_header_and_is_covered_by_signature(integration,webhook_dispatch_tests.rs) — asserts the header mirrors the body, the body containsevent, and the signature is valid over the body.Acceptance criteria
✅ Met — the
eventfield is in the signed body; all documentation and inline comments instruct receivers to route on the authenticated body field only.Testing
All 128 tests pass (
cargo test). Also fixes pre-existing compile errors onmain(parse_envmissing?,sqlx::Errorconversion), updatesanyhowto 1.0.104 (RUSTSEC-2026-0190),spinto 0.9.9 (yanked), and removes staledeny.tomlentries.