Repository navigation
Description
Problem
The github-ci Worker (pkgs/github-ci/worker/src/index.ts, #5693) is the GitHub webhook receiver: its header comment states the gate plainly — "Gate: HMAC-SHA256 over the raw body, X-Hub-Signature-256 header, verified with Web Crypto against GITHUB_WEBHOOK_SECRET … the HMAC is the gate" (:3-9), and the README calls it the "HMAC-SHA256 gate". The secret is a required deployment secret per wrangler.toml ("HMAC gate; NEW value minted for this Worker, vaulted in BWS").
The implementation only verifies when a secret happens to be present:
// src/index.ts:73-80 @ def55caf48
const secret = env.GITHUB_WEBHOOK_SECRET ?? "";
if (secret) {
const given = (req.headers.get("x-hub-signature-256") ?? "").replace("sha256=", "");
const expected = await hmacHex(secret, raw);
if (!timingSafeEqual(given, expected)) {
return new Response("bad signature", { status: 401 });
}
}When GITHUB_WEBHOOK_SECRET is empty or the binding is missing — a deploy before wrangler secret put lands, a renamed/mistyped binding, a preview/dev deployment (workers_dev = true in wrangler.toml) — the gate is skipped entirely and every POST is processed as if it were an authentic GitHub delivery, including the writes behind the gate:
workflow_run→INSERT OR IGNORE INTO ci_eventsin fleet-platform Turso (failure conclusions keep the raw forged payload for forensics),- fleet-repo
push→ advancesagent_repo_snapshots.head_shato an attacker-chosen SHA + appends a sink event, - fleet-repo
pull_request/issues→ sink event +dirty:<repo>watermark.
The sibling atlas-search Worker fails closed on the same condition (gateOk: if (!presented || !env.GATE_TOKEN) return false). This Worker fails open.
Evidence (verified this run, laptop @ def55ca)
Probe ~/git/fleet/probe-ghci-gate/probe.ts imports the real src/index.ts (bun) with a stub Turso pipeline server that records statements:
Controls — secret configured:
- unsigned
ping→401 bad signature - validly signed
ping→200 pong - bad-signature
ping→401 bad signature
Defect — no signature presented at all:
GITHUB_WEBHOOK_SECRET: "", unsignedping→200 pong- secret binding missing entirely, unsigned
ping→200 pong GITHUB_WEBHOOK_SECRET: "", unsigned completedworkflow_runfordeveloping-today/code→200 {"ok":true,"repo":"developing-today/code","run_id":999,"conclusion":"success"}, and the stub recorded 1 pipeline call containingINSERT OR IGNORE INTO ci_events— an unauthenticated request reached the Turso write.
Existing tests (test/worker.test.ts) always run with the secret bound (vitest.config.ts bindings) and cover only the bad-signature case; there is no missing/empty-secret case.
Related: #5693 (the Worker's tracking issue), #6925 (same Worker's sink reachability).
Why it matters
A webhook receiver whose only authentication silently disables itself on a configuration miss is a forge-anything endpoint: CI history, repo snapshot heads, and agent events/watermarks are all downstream of these writes, and a forged push head_sha or failure workflow_run payload is indistinguishable from a real delivery once stored. The failure mode is silent — nothing logs that the gate was skipped — so a misconfigured deploy would not be noticed until forged data is found downstream. Fail-closed is the house pattern for exactly this condition (atlas-search gateOk, cold-store, pkgs/id fail-closed fixes).
Acceptance criteria
- With
GITHUB_WEBHOOK_SECRETunset or empty, every POST (includingping) is rejected with a 5xx configuration error (e.g. 500/503 "webhook secret not configured") and no Turso/sink write is attempted; the rejection is logged server-side without logging any credential value. - With the secret configured, behavior is unchanged: valid signature processes normally, missing/bad signature → 401 (existing tests keep passing).
- The GET liveness response stays unauthenticated (it exposes no data and takes no writes) — or, if it is also gated, the README/wrangler notes say so explicitly.
- New worker tests cover the unset-secret and empty-secret cases for at least
pingand one writing event (workflow_runorpush), asserting rejection and zero Turso pipeline calls. - Header comment / README wording and the code agree: the HMAC is the gate, unconditionally.
Activity
developing-today commentedon Nov 7, 2026
CODE-2185
dezren39 commentedon Nov 7, 2026
🤖 Agent note · filed
dezren39 commentedon Nov 10, 2026
🤖 Agent note · triaged
task/small-fix· priority/high · effort/s · kind/security (as filed)repo-health:v1:fix:developing-today/code:issue:6936→ queuerepo-health-code-pilot, task 14437 (enqueued by triage-step this run)11 remaining items
dezren39 commentedon Nov 10, 2026
agent-note:v1
lane: code-e
task: 14437
issue: #6936
state: handed_off
execution_lane: opencode (lane row 5649)
handoff_reason: scheduled shift is time-bounded; claimant is the persistent execution session
next: claimant launches the bound opencode session
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
dezren39 commentedon Nov 10, 2026
🤖 Agent note · handed off
fix(github-ci): HMAC gate fails closed when GITHUB_WEBHOOK_SECRET is …
dezren39 commentedon Nov 10, 2026
state: done
task: 14437
lane: code-w
issue: "#6936"
pr: "#8233"
Fixed by lane code-w (task 14437, direct per #8187) in PR #8233:
src/index.ts: unset/empty/whitespaceGITHUB_WEBHOOK_SECRET→ logged configuration error (no credential value) + 503 "webhook secret not configured" before any body read or Turso/sink write. Configured behavior unchanged (valid → process; bad/missing signature → 401). GET liveness stays unauthenticated.workflow_run(writing event) andping, asserting 503 and, via the fetchMock no-net-connect + no-pending-interceptors harness, zero Turso pipeline calls; wrong-secret 401 case added.npm test34/34 pass (4 files);npm run typecheckclean.Task 14437 completes as pr_opened (PR #8233, CI pending in the fleet stall).
dezren39 commentedon Nov 12, 2026
Suggestions-pass verification (2026-11-12): confirmed the fail-open branch in the current checkout.
pkgs/github-ci/worker/src/index.ts:71-78normalizes a missing binding to""and only checksx-hub-signature-256insideif (secret), so an empty/unbound secret skips authentication. The deployment docs say the secret is a required webhook secret (pkgs/github-ci/worker/README.md:52-56), and the worker header calls HMAC “the gate” (src/index.ts:4-8). Existing worker tests use the configured test binding (worker/vitest.config.ts) and cover bad signatures, but not the missing/empty binding path. No duplicate opened; this matches the existing issue.fix(github-ci): HMAC gate fails closed when GITHUB_WEBHOOK_SECRET is …