Skip to content

fix(github-ci): HMAC gate fails closed when GITHUB_WEBHOOK_SECRET is unset (#6936) - #8233

Merged
dezren39 merged 2 commits into
mainfrom
queue/14437-6936-hmac-fail-closed
Nov 14, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/14437-6936-hmac-fail-closed

Conversation

@dezren39

@dezren39 dezren39 commented Nov 10, 2026 •

Copy link
Copy Markdown
Member

Fixes #6936 — queue task 14437, lane code-w. Resumes the uncommitted fix found in the task's existing opencode worktree (same branch), completed with the missing acceptance coverage.

The defect

pkgs/github-ci/worker/src/index.ts verified the webhook HMAC only if (secret): with GITHUB_WEBHOOK_SECRET unset or empty (a deploy before wrangler secret put, a mistyped binding, a workers_dev preview), every unsigned POST was processed as an authentic GitHub delivery — including the Turso writes behind the gate. The sibling atlas-search Worker fails closed on the same condition; this one failed open, silently.

The fix

  • src/index.ts: the secret check is now unconditional and first. Unset/empty/whitespace secret → console.error (no credential value) + 503 "webhook secret not configured", before the body is read and before any Turso/sink write. Configured behavior is byte-for-byte the old path: valid signature processes, missing/bad signature → 401. GET liveness stays unauthenticated, as the acceptance allows.
  • test/worker.test.ts: parametrized unset/empty cases for workflow_run (a writing event — rejection asserts 503 + the exact log line, with fetchMock net-connect disabled and assertNoPendingInterceptors, so any attempted Turso call would fail the test) and for ping; plus a wrong-secret 401 case. The post() helper now takes the secret (null deletes the binding).
  • README.md: the gate description now states the unconditional fail-closed behavior, so code, header comment ("the HMAC is the gate"), and README agree.

Verification

  • npm test (vitest, workerd): 34/34 pass across 4 files (worker.test.ts 12, incl. the 5 new gate cases).
  • npm run typecheck (tsc --noEmit): clean.
  • Oracle: the tests name it — a webhook is authentic only if a configured secret verifies its HMAC; no secret configured means no authentic webhook exists, so every POST rejects.

Note: the branch base is a few days of main behind (the resumed worktree's base); the diff touches only the three worker files and conflicts with nothing in current main.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 10, 2026 20:19
@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-11-10T20:19:19.585354Z
We couldn’t complete this review. Comment @codex review to try again.
a3e6f95 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@coderabbitai

coderabbitai Bot commented Nov 10, 2026 •

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 58 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 8d9bc3ea-2a59-4109-961d-c8ef0c938ac4
Commits

Reviewing files that changed from the base of the PR and between 66c5bb6 and e4d5723.

Files selected for processing: 3

  • pkgs/github-ci/worker/README.md
  • pkgs/github-ci/worker/src/index.ts
  • pkgs/github-ci/worker/test/worker.test.ts
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@dezren39

Copy link
Copy Markdown
Member Author

agent-note:v1
state: picked-up
task: 17241
lane: code-a
worker: repo-worker-code
What: Shepherding PR #8233 to a terminal outcome (90-day review open-PR pass). Verified fresh: PR #8233 OPEN, head a3e6f95, no held / user/owned / do-not-merge / do-not-auto-edit labels; issue #6936 OPEN; the fix is NOT on current main (origin/main pkgs/github-ci/worker/src/index.ts still verifies the HMAC only if (secret) — fail-open). Codex: the review run on this head FAILED on Codex usage limits and left no inline findings (the follow-up Codex comment is the usage-limits notice), so there are no Codex findings to disposition. PR body records npm test 34/34 pass and tsc clean at authoring.
Next: merge current main into the PR branch in a dedicated worktree, re-run the worker tests and typecheck, push, recheck, and merge on its merits.

@dezren39 dezren39 added work/assigned Queue worker lifecycle state queue/claimed Queue worker lifecycle state status/in-progress Queue worker lifecycle state labels Nov 14, 2026
@dezren39

Copy link
Copy Markdown
Member Author

agent-note:v1
state: merge-ready
task: 17241
lane: code-a
worker: repo-worker-code
What: Merging PR #8233 on its merits. Current main merged into the PR branch cleanly (head e4d5723); the PR diff against current main is exactly its three files (worker src/index.ts, test/worker.test.ts, README.md). Verification on the merged tree this shift: npm test — 68/68 pass across 6 files (including the new fail-closed gate cases); npm run typecheck (tsc --noEmit) clean. Codex disposition: the Codex review run on the original head failed on Codex usage limits and produced no inline findings, so there is nothing outstanding to disposition.

@dezren39
dezren39 merged commit fe2babd into main Nov 14, 2026
2 checks passed
@dezren39
dezren39 deleted the queue/14437-6936-hmac-fail-closed branch November 14, 2026 21:03
@dezren39 dezren39 removed status/in-progress Queue worker lifecycle state queue/claimed Queue worker lifecycle state work/assigned Queue worker lifecycle state labels Nov 14, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

github-ci(worker): HMAC gate fails open when GITHUB_WEBHOOK_SECRET is unset — unsigned POSTs are processed and written to Turso

1 participant