Skip to content

bug(security): a CodeQL high appears only on the merge result, so main's required checks are red #1311

Backlog

Description

@HugoXK

Written-by: Fledge Platform Product

Summary

main at 14d835abcda38fcb9f90ebfc82ef6d241551835c carries two red required checks that were green on the commit before it and green on the pull request's own head: Analyze JavaScript/TypeScript and codeql-required. The CodeQL gate reports one new high result on the merge result, in a file the merged pull request did not touch.

This card records the merge-result-only red. It is not a confirmed vulnerability: the Security Lead is verifying the finding independently, and this card deliberately carries no reproduction of the data flow at exploit level.

  • Expected: main's required checks are green, or they are red for a reason a maintainer can read off the card and the check.
  • Actual: main is red at 2026-11-25T00:53:38Z (Analyze JavaScript/TypeScript) and 00:53:47Z (codeql-required) with codeql-gate: new high result js/insufficient-password-hash at src/lib/secrets.ts:99.

Because ci-ok aggregates the required set, every pull request cut from this main inherits the red until it is resolved.

Environment

  • Repository HugoXK/fledge, ref main at 14d835abcda38fcb9f90ebfc82ef6d241551835c (committed 2026-11-25T00:51:22Z, subject feat(audit): hash-chain the audit log and add a verify command (#1233) (#1288)); SHA and the response Date: Wed, 25 Nov 2026 01:14:08 GMT were read from the GitHub API for this card.
  • GitHub Actions run 45521328476, job 138893637546 (Analyze JavaScript/TypeScript), job 138893712003 (codeql-required).
  • No local server, database or SMTP was used; this is a CI-only reproduction.

Minimal reproduction

  1. Read the two check runs on 14d835ab (API commits/14d835ab.../check-runs): Analyze JavaScript/TypeScript failure, started 00:51:28Z, completed 00:53:38Z; codeql-required failure, started 00:51:38Z, completed 00:53:47Z.
  2. Read the log of job 138893637546, step Run node base/scripts/codeql-gate.mjs --sarif codeql-results --baseline base/.github/agent/codeql-baseline.json, at 00:53:32Z:
    • codeql-gate: new high result js/insufficient-password-hash at src/lib/secrets.ts:99
    • codeql-gate: parsed 7 result(s), 1 high/critical, 1 added; the baseline at b85777cc68a5b4ca4bced910baf2414c5a9b2ea9 holds 7
  3. Compare the same two checks on the predecessor and on the pull request head:
    • 93307f5b7cb1c1bcb058492298d9b60322fbcc6b: Analyze JavaScript/TypeScript success 14:45:42Z→14:49:03Z; codeql-required success 14:45:53Z→14:49:06Z.
    • 3f5d06302b693a9fe969fa9047fcf0bb62b35400 (#1288 head): Analyze JavaScript/TypeScript success 08:23:00Z→08:24:44Z; codeql-required success 08:23:20Z→08:24:52Z; CodeQL success 08:24:32Z→08:24:36Z.
  4. Read #1288's file list: 8 files, none of them src/lib/secrets.ts — changelog.d/1233.security.md, docs/architecture.md, docs/security.md, package.json, scripts/audit-verify.ts, src/db.ts (+37/−2), src/lib/auditChain.ts (+77), test/auditChain.test.ts.

So the flagged line was unchanged by the merge and green on both sides of it; the analysis only sees the result once the new files and the new call path exist in the same tree.

Where the new path is

  • The sink CodeQL names is the shared helper, sha256Hex in src/lib/secrets.ts:98-99 — a general SHA-256 helper used across the app, not a password store.
  • The new caller is the audit chain: src/lib/auditChain.ts:1 imports sha256Hex, and auditHash at src/lib/auditChain.ts:20-24 interpolates row.detail into the hashed string.
  • detail is caller-supplied free text written by Store.audit at src/db.ts:8389 (the auditHash(...) write is src/db.ts:8399).
  • The result is one new high/critical result on the merge tree while the baseline holds 7 unchanged.

Scope note for the fixer, not a cause: src/lib/secrets.ts is untouched by #1288, the hash-chain guarantee is docs/security.md and docs/architecture.md as merged, and nothing in this card should be read as a claim about the algorithm — the audit chain hashes with SHA-256 on purpose and that is not what the rule objects to.

Proposed red test

This is a data-flow finding, so no unit test in test/ reproduces it: CodeQL's engine is the only thing that can, and the red half of the evidence is the check itself (step 2 above, log line quoted verbatim).

The acceptance test is therefore at two levels, and both must hold at the fix's own tip:

  1. CI level (red now, must go green): Analyze JavaScript/TypeScript and codeql-required are success on the fix's head and on main after the merge. The pull request body carries the before/after codeql-gate: line, not a narrative.
  2. Offline level (new, cheap, and runnable by the Reviewer): a test/ case that feeds scripts/codeql-gate.mjs a two-result SARIF fixture — one baselined result and one added high — and asserts the exact codeql-gate: new high result … exit and message, so the behaviour the merge changed is pinned by a test rather than only by CI. That case must fail against a gate that ignores the baseline and pass against the merged gate unchanged.

Optional and preferred where it is cheap: if the fix removes the data flow instead of baselining it, add one assertion that the audit chain still verifies — test/auditChain.test.ts as merged is the reference and must stay byte-identical and green.

Smallest mergeable slice

One pull request, one week at most, that leaves main green and the audit chain unchanged:

  • Analyze JavaScript/TypeScript and codeql-required green at the fix's own head; main green after the merge.
  • test/auditChain.test.ts byte-identical to the merged file and green, and verifyAuditChain's behaviour unchanged — the #1233 guarantee is not traded for a green check.
  • The fix is one of two admissible outcomes, and the choice is the Dev's, recorded on this card: the new flow no longer reaches the flagged sink, or exactly one baseline entry carries a comment naming the path, the reason and the Security Lead's verdict.

Non-goals

  • No change to the audit-chain format, the auditHash input, or the verify command's output; no backfill (the chain-start anchor question is separate).
  • No widening of the CodeQL baseline beyond this one added result, and no expiry change.
  • No reproduction of the data flow at exploit level in this card, its comments, the pull request body or the commit message.
  • Not the aggregate-gate logic (#1304, #585, #1032, #422, #284), not the baseline expiry (#928, #645), not the arch-gate regression (#1309), and not the ci:main-red tracker (#1308).
  • No UI face. Nothing user-visible changes; this restores the required checks.

Priority

High: a required check on main is red, so every pull request's aggregate ci-ok is red until this lands. Priority label is the Lead's to set; this card asks for review first.

Dedupe

Searched open and closed issues for codeql, CodeQL baseline, insufficient and main-red. The nearest cards are all about the gate's mechanics or the baseline's lifecycle (#884, #1304, #585, #1032, #422, #284, #928, #645) or about the arch gate (#1309, #1308); none records a new high that appears only on the merge result, and none names this data flow. #1288's pull request is merged, so this is not a review comment on it.

Open question for review

If the Security Lead's verification says the rule is right about something real, this card's slice stays the same but the urgency and the doc obligation change (docs/security.md owns the chain). If it says the flow is benign, the second admissible outcome (one commented baseline entry) is the whole fix. Either way the card should not be closed on "the check is green" alone.

Activity

  1. added
    bug
    area:security
    needs-review
    on Nov 25, 2026
  2. HugoXK commented on Nov 25, 2026

    @HugoXK
    OwnerAuthor

    Written-by: Fledge Platform Product

    Evidence update for the seat, comment only — the body stays byte-identical (96490ca2bfc7), so nothing is voided and this is not a new claim.

    The red is still real; it is only unobserved on scheduled runs. On 14d835ab (live main, read at API Date: Wed, 25 Nov 2026 04:56:24 GMT) there are two runs of the same tree:

    • Push run 45521328437 (2026-11-25T00:51:26Z): Analyze JavaScript/TypeScript 138893637546 failure 00:51:28Z→00:53:38Z, codeql-required 138893712003 failure 00:51:38Z→00:53:47Z. This is the red the body describes.
    • CI schedule run 45537064667 (03:01:41Z): codeql-required 138946213119 success 03:01:55Z→03:02:02Z, and no Analyze JavaScript/TypeScript job exists in that run. Its log line 136 says why: codeql-required: schedule: the weekly analysis observes, it does not gate a merge.

    So GET /commits/14d835ab/check-runs?filter=latest now returns codeql-required: success while Analyze JavaScript/TypeScript is still failure, and the bot comment on the main-red tracker #1308 at 03:05:43Z lists only test as failing. Neither means the finding cleared: the scheduled run deliberately does not gate, and the only analysis of this tree is the failing push run at 00:51Z.

    Nothing else changed on the card; no label touched, no scope added.

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

    area:securitybugneeds-review

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions