Skip to content

github-backup(worker): POST /github crashes on a signed JSON null body, and an unset/empty webhook secret crashes every delivery naming nothing #6951

Closed

Description

@dezren39

Problem

The github-backup queue Worker's webhook endpoint (POST /github in infra/github-backup/worker/src/index.js) trusts two things it should guard, and both failures escape the handler as unhandled throws instead of responses. Sibling endpoints in the same file were covered by #6882 (/queue/ack body shape, corrupt KV on GET /queue); the /github handler was not.

File: infra/github-backup/worker/src/index.js (verified on origin/main @ 86afa3b8b6; the file is unchanged since 63f83bef5a).

1. A signed JSON null body crashes the handler (:45-47)

let payload = {};
try { payload = JSON.parse(body); } catch { /* ping has form encoding sometimes */ }
...
const repo = payload.repository && payload.repository.full_name;

The try/catch guards only the parse. A body of null parses successfully to null, and payload.repository then throws TypeError: Cannot read properties of null (reading 'repository'). Every other non-object body behaves sanely today ([], "hi", 123, and non-JSON all get 202 no repository in payload), and the ping path returns before the deref — null is the one shape that crashes the receiver for a legitimately signed delivery.

2. An unset/empty GITHUB_WEBHOOK_SECRET crashes every delivery, naming nothing (:38-41)

const expect = await hmacHex(env.GITHUB_WEBHOOK_SECRET, body);

hmacHex encodes the secret and calls crypto.subtle.importKey with it. With the secret unset or empty, the key is zero-length and importKey throws DOMException: Zero-length key is not supported — for every POST, signed or not, before the signature comparison. A misconfigured deployment (secret not provisioned, or provisioned empty) therefore takes the webhook receiver down with a bare 500 whose error names neither the endpoint nor the missing configuration, instead of an explicit fail-closed configuration error.

Evidence

Verified this run on the laptop, probe ~/git/fleet/probe-ghb-github (real src/index.js verbatim, md5 931e7df400d74fb6d60d38698205f2c4 matching origin/main, node v24.21.0, stub KV, HMACs computed with node:crypto):

Case Result today
secret set, correct signature, repo payload 202 queued, 1 KV write (control OK)
secret set, wrong signature / no signature 401 bad signature, 0 KV writes (control OK)
secret set, correct signature, body null throws TypeError: Cannot read properties of null (reading 'repository')
secret set, correct signature, body [] / "hi" / 123 / non-JSON 202 no repository in payload (controls OK)
secret set, event ping, body null 200 pong (returns before the deref)
secret unset or "", any signature (even a correct empty-key HMAC) or none throws DOMException: Zero-length key is not supported

The existing suite (infra/github-backup/worker/test/index.test.mjs, 5 tests) has no /github coverage at all.

Why it matters

Acceptance criteria

  • POST /github with a correctly signed JSON null body returns 202 no repository in payload (same as the other non-object shapes); no exception escapes the handler for any parsed JSON value.
  • POST /github with GITHUB_WEBHOOK_SECRET unset or empty returns an explicit 5xx whose body names the missing configuration, for every request; no exception escapes, no KV write occurs, and no signature (including an empty-key HMAC) is accepted.
  • Well-formed deliveries are unchanged: correct signature + repository payload → 202 queued with the event stored; wrong/missing signature → 401; ping → 200 pong.
  • New tests in infra/github-backup/worker/test/index.test.mjs cover: signed null body, unset secret, empty secret; the existing 5 tests still pass (node --test infra/github-backup/worker/test/index.test.mjs).

Activity

  1. developing-today commented on Nov 7, 2026

    @developing-today
    Contributor
  2. added
    kind/bugSomething isn't working (prefixed form of the classic bug label)
    kind/securitySecurity issue or security hardening
    source/creatorFiled by the new-issue-creator job
    work/self-assignedAn agent grabbed this item directly, outside the queue
    priority/normalOrdinary priority (the default)
    effort/xsTrivial: expected under 30 minutes of work
    app/github-backupinfra/github-backup estate mirror system
    task/small-fixQueue packet kind: bounded fix with reproduction and targeted tests
    on Nov 7, 2026
  3. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · state: filed

  4. added a commit that references this issue on Nov 7, 2026
  5. dezren39 commented on Nov 7, 2026

    @dezren39
    MemberAuthor

    🤖 Agent note · state: done

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    app/github-backupinfra/github-backup estate mirror systemeffort/xsTrivial: expected under 30 minutes of workkind/bugSomething isn't working (prefixed form of the classic bug label)kind/securitySecurity issue or security hardeningpriority/normalOrdinary priority (the default)source/creatorFiled by the new-issue-creator jobstatus/in-progressQueue worker lifecycle statestatus:donetask/small-fixQueue packet kind: bounded fix with reproduction and targeted testswork/self-assignedAn agent grabbed this item directly, outside the queue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions