Repository navigation
fix(alerts): sign the webhook's timestamp with its body (#38, release gate) - #39
Merged
angela-helios merged 8 commits intoNov 24, 2026
Conversation
Every attempt carries X-HIE-Timestamp, and X-HIE-Signature is the
HMAC-SHA256 of "{timestamp}.{body}": a captured delivery can no longer be
replayed later to a receiver that pruned its event ids. Receivers enforce
a tolerance, 5 minutes by default. No release signed the body alone, so
there is no compatibility mode. The webhook secret is trimmed when read.
Refs HeliosSoftware#38
A fired event parked for an earlier URL, or failed, was hidden behind a cleared event delivered to the current one. GET /api/alerts keeps the latest event's fields in webhook and adds webhook.events, every event of the alert oldest first, read with the page in one statement. Refs HeliosSoftware#38
Gordex2014
marked this pull request as draft
November 24, 2026 15:31
Gordex2014
marked this pull request as ready for review
November 24, 2026 15:36
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.
Part of #38: item 1 (decided before the next release) and the #30 minors. This PR is the release gate. The rest of #38 follows in a second PR stacked on this one.
What changes
Item 1: the webhook signature covers a timestamp.
X-HIE-Timestamp: the Unix seconds when that attempt was sent, decimal digits only. It is sent signed or not.X-HIE-Signature: sha256=<hex>is the HMAC-SHA256 of{X-HIE-Timestamp}.{raw body}, as Stripe-style webhooks do, in HIE's own headers. The header name and thesha256=form are unchanged; only what is signed changes.event_id, stamped and signed again when it leaves. The receiver's tolerance therefore never has to cover the retry backoff.docs/sources.mdnow has a Verifying step:., and the body received, in constant time, before parsing;event_idfor at least twice the tolerance. A request stamped one tolerance ahead stays valid for two.git show v0.2.0:src/alerts.rshas no signature code). The docs and the amendment say so.docs/decisions.md: an amendment to decision 40. Its Chosen, Why and Cost lines that the amendment changes are marked.#30 minors.
alerts.webhook_secretandHIE_ALERT_WEBHOOK_SECRETare trimmed of leading and trailing whitespace when read. A secret file that ends in a newline now signs with the secret it holds. The untrimmed buffer is wiped.firedhidden behind a latercleared.GET /api/alertskeepswebhookas the latest event, with the same fields. It addswebhook.events: every event of the alert, oldest first, each withevent,event_id,state,attempts,last_error,last_statusanddelivered_at. The page of alerts and their events are read in one statement, so a page still counts alerts, not events.firedandcleared, and the claim leases. It is left for you to decide.In plain words
A receiver can now reject an old delivery that someone captured and sends again, without remembering every event it has ever seen. The API also shows a webhook event that is stuck for an earlier URL, even after a later event for the same alert went through.
Side effects checked
{timestamp}.{body}. No release shipped the old form, so no released receiver breaks.webhook.eventsis additive.webhookkeeps its fields, and staysnullfor alerts from before events were recorded.hie.yaml, and a blank variable still leaves the file's value.How to verify
The CI commands, with
CI=trueand default parallelism, on this tree (Linux):The changed suites (
--lib,alert_webhook,alerts,check) ran once more on SQLite and twice against a throwaway PostgreSQL 16. On PostgreSQL the only failures were the twosecrets::keytests that fail there before this change too.tests/alert_webhook.rs):{timestamp}.{body};tests/alerts.rs): checked against the timestamp header.src/alerts.rs):hmac.src/config.rs): a trailing newline is trimmed, from the environment and from a YAML block scalar.webhook.events(tests/alerts.rs):firedparked for another URL is still listed after itsclearedwas delivered to this one;Links