From d69cab4022f309337fdb0dccf4d211cad822efbd Mon Sep 17 00:00:00 2001 From: Andrew Lee <5784515+andyrewlee@users.noreply.github.com> Date: Mon, 30 Nov 2026 12:56:56 -0800 Subject: [PATCH] Document GitHub receipt identity and rotation uncertainty --- research/github-webhook-rotation/REPORT.md | 21 +++++++++++ .../github-webhook-rotation/evidence.json | 29 +++++++++++++++ .../github-webhook-rotation/reproduce.mjs | 36 +++++++++++++++++++ .../reproduce.test.mjs | 34 ++++++++++++++++++ 4 files changed, 120 insertions(+) create mode 100644 research/github-webhook-rotation/REPORT.md create mode 100644 research/github-webhook-rotation/evidence.json create mode 100644 research/github-webhook-rotation/reproduce.mjs create mode 100644 research/github-webhook-rotation/reproduce.test.mjs diff --git a/research/github-webhook-rotation/REPORT.md b/research/github-webhook-rotation/REPORT.md new file mode 100644 index 0000000..090db73 --- /dev/null +++ b/research/github-webhook-rotation/REPORT.md @@ -0,0 +1,21 @@ +# GitHub webhook receipt identity during signing-secret rotation + +## Observed code behavior + +The verifier authenticates the raw body and returns its verified MAC as the receipt ID. The synthetic probe authenticates the same body with two generated keys. Reusing a key produces the same receipt ID. Changing the signing key produces a different receipt ID. Changing unsigned delivery and event headers leaves the authenticated result unchanged. + +## Provider evidence + +GitHub documents how the signing secret and payload determine the MAC. Its redelivery guidance says the delivery header is retained. The REST reference describes editing webhook settings and redelivering a delivery. These sources leave the signing key for historical redeliveries after rotation unspecified. [Validating deliveries](https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries) · [Redelivery header](https://docs.github.com/en/webhooks/using-webhooks/best-practices-for-using-webhooks#use-the-x-github-delivery-header) · [Webhook REST reference](https://docs.github.com/en/rest/repos/webhooks) + +## Decision + +Provider behavior is inconclusive. Keep the existing receipt ID. The offline result establishes how this verifier would behave if an identical payload arrived under a different signing key. + +## Compatibility + +Hosts can persist the current signature-derived ID under a binding and provider namespace. A later identity migration would need to account for both legacy and new IDs over the host's replay-store retention window. A body-only digest could merge distinct deliveries with identical bytes. A design for different IDs should establish that behavior explicitly and calculate any candidate ID after authentication. The unsigned delivery header can help correlate observations. + +## Next experiment + +With separate authorization, use a disposable repository and webhook. Observe the same historical delivery before and after changing the test signing secret. Compare raw body equality and which key authenticates each attempt, then record whether the verified receipt remains the same. Record outcomes and provider scope without keeping secrets, signatures, or payloads in the report. diff --git a/research/github-webhook-rotation/evidence.json b/research/github-webhook-rotation/evidence.json new file mode 100644 index 0000000..a91e39a --- /dev/null +++ b/research/github-webhook-rotation/evidence.json @@ -0,0 +1,29 @@ +{ + "plannedAt": "19a98ac", + "providerStatus": "inconclusive", + "codeFacts": { + "sameSecretSameId": true, + "differentSecretDifferentId": true, + "unsignedHeadersDoNotChangeId": true + }, + "sources": [ + { + "url": "https://docs.github.com/en/webhooks/using-webhooks/validating-webhook-deliveries", + "retrievedAt": "2026-11-30", + "supports": "GitHub computes its signature from the payload and the signing secret." + }, + { + "url": "https://docs.github.com/en/webhooks/using-webhooks/best-practices-for-using-webhooks#use-the-x-github-delivery-header", + "retrievedAt": "2026-11-30", + "supports": "GitHub documents reuse of the delivery header on a redelivery." + }, + { + "url": "https://docs.github.com/en/rest/repos/webhooks#redeliver-a-delivery-for-a-repository-webhook", + "retrievedAt": "2026-11-30", + "supports": "GitHub exposes a redelivery operation and a separate operation for editing the webhook configuration." + } + ], + "providerEvidence": "The sources describe signing, configuration, and redelivery independently. They leave the key used for historical redelivery after a secret change unspecified.", + "recommendation": "Retain authenticated receipt IDs and qualify the redelivery assumption until a disposable, authorized observation resolves the provider behavior.", + "liveExperimentPerformed": false +} diff --git a/research/github-webhook-rotation/reproduce.mjs b/research/github-webhook-rotation/reproduce.mjs new file mode 100644 index 0000000..cf9ba5d --- /dev/null +++ b/research/github-webhook-rotation/reproduce.mjs @@ -0,0 +1,36 @@ +import { createHmac, randomBytes } from "node:crypto" +import { realpathSync } from "node:fs" +import { pathToFileURL } from "node:url" +import { verifyNativeWebhook } from "@checkfu/integrations/webhooks" + +export async function characterizeRotation() { + const firstKey = randomBytes(32).toString("base64url") + const secondKey = randomBytes(32).toString("base64url") + const body = Buffer.from(JSON.stringify({ + action: "opened", issue: { number: 1 }, repository: { id: 42 }, + })) + const sign = key => new Headers({ + "x-hub-signature-256": "sha256=" + createHmac("sha256", key).update(body).digest("hex"), + "x-github-delivery": "synthetic-delivery", + "x-github-event": "issues", + }) + const verify = (key, headers) => verifyNativeWebhook("github", body, headers, key) + const before = await verify(firstKey, sign(firstKey)) + const repeated = await verify(firstKey, sign(firstKey)) + const rekeyed = await verify(secondKey, sign(secondKey)) + const changedHeaders = sign(firstKey) + changedHeaders.set("x-github-delivery", "different-synthetic-delivery") + changedHeaders.set("x-github-event", "pull_request") + const changed = await verify(firstKey, changedHeaders) + const allAuthenticated = [before, repeated, rekeyed, changed].every(receipt => receipt.type === "event") + return { + allAuthenticated, + sameSecretSameId: allAuthenticated && before.id === repeated.id, + differentSecretDifferentId: allAuthenticated && before.id !== rekeyed.id, + unsignedHeadersDoNotChangeId: allAuthenticated && before.id === changed.id && before.event === changed.event, + } +} + +if (process.argv[1] && pathToFileURL(realpathSync(process.argv[1])).href === import.meta.url) { + console.log(JSON.stringify(await characterizeRotation())) +} diff --git a/research/github-webhook-rotation/reproduce.test.mjs b/research/github-webhook-rotation/reproduce.test.mjs new file mode 100644 index 0000000..c691d45 --- /dev/null +++ b/research/github-webhook-rotation/reproduce.test.mjs @@ -0,0 +1,34 @@ +import assert from "node:assert/strict" +import { readFileSync } from "node:fs" +import { test } from "node:test" +import { characterizeRotation } from "./reproduce.mjs" + +test("authenticated GitHub receipt identity depends on the signing key", async () => { + assert.deepEqual(await characterizeRotation(), { + allAuthenticated: true, + sameSecretSameId: true, + differentSecretDifferentId: true, + unsignedHeadersDoNotChangeId: true, + }) +}) + +test("the evidence packet separates provider observations from offline code facts", async () => { + const packet = JSON.parse(readFileSync(new URL("./evidence.json", import.meta.url), "utf8")) + const { allAuthenticated, ...facts } = await characterizeRotation() + assert.equal(allAuthenticated, true) + assert.deepEqual(packet.codeFacts, facts) + assert.match(packet.plannedAt, /^[a-f0-9]{7,40}$/u) + assert.ok(["inconclusive", "confirmed-rekeys", "confirmed-preserves"].includes(packet.providerStatus)) + assert.equal(packet.liveExperimentPerformed, false) + assert.ok(packet.providerEvidence.trim()) + assert.ok(packet.recommendation.trim()) + assert.ok(packet.sources.length > 0) + for (const { url, retrievedAt, supports } of packet.sources) { + assert.equal(new URL(url).origin, "https://docs.github.com") + assert.match(retrievedAt, /^\d{4}-\d{2}-\d{2}$/u) + assert.ok(supports.trim()) + } + if (packet.providerStatus !== "inconclusive") { + assert.ok(packet.sources.some(({ supports }) => supports.startsWith("Direct evidence of historical redelivery after a secret change:"))) + } +})