Skip to content

fix(security): suppress the CodeQL password-hash false positive on sha256Hex - #5982

Merged
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/codeql-hash-suppression
Jul 27, 2026
Merged

fix(security): suppress the CodeQL password-hash false positive on sha256Hex#5982
TheodoreSpeaks merged 1 commit into
stagingfrom
fix/codeql-hash-suppression

Conversation

@TheodoreSpeaks

Copy link
Copy Markdown
Collaborator

Summary

CodeQL fails #5963 (the v0.7.46 release PR) with 2 high-severity js/insufficient-password-hash alerts on packages/security/src/hash.ts:12 and :14. Both are false positives, but the check is required, so the release is blocked.

Why they appeared now. d362e6816e (setup wizard) added sha256Base64Url to this file. Touching it made every pre-existing taint path that ends here count as "new code changed by this pull request" — CodeQL's own summary hints at this ("Alerts not introduced by this pull request might have been detected because the code changes were too large"). The flagged lines are in sha256Hex, which was not modified, and neither were any of its callers.

Why they're false positives. Neither taint source is a human-chosen password:

Caller What it passes
hashApiKey(plainKey) An API key built from generateSecureToken(24) = randomBytes(24) — 192 bits. A fast digest is the correct construction for an indexed WHERE key_hash = $1 lookup; a slow KDF would run on every authenticated request and buy nothing against a keyspace that cannot be searched.
passwordSlot(encryptedPassword) An already-encrypted value, hashed to an 8-char discriminator so deployment auth tokens invalidate when the password changes. Not credential storage.

User credentials never reach this helper — Better Auth owns them and applies its own KDF. I verified there is no other password-shaped caller.

Approach

Inline // lgtm[js/insufficient-password-hash] on the two flagged lines, matching the convention this repo already uses for the same class of judgement (uuidV5 in apps/sim/ee/workspace-forking/lib/remap/block-identity.ts suppresses js/weak-cryptographic-algorithm the same way; there are currently 0 open alerts for that rule, so the mechanism works).

The sha256Hex doc comment now states the invariant — high-entropy secrets and content digests only, genuine passwords go to Better Auth — so a future caller has the rule in front of them rather than inheriting a silent suppression.

sha256Base64Url is deliberately left unannotated even though it is the same primitive: it was not flagged, and a speculative suppression there would hide a real finding later.

Type of Change

  • Bug fix (unblocks a failing required check)

Testing

packages/security suite passes (35 tests), bun run lint clean. No behavior change — comments only.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

CodeQL fails #5963 (the v0.7.46 release PR) with 2 high-severity js/insufficient-password-hash alerts on packages/security/src/hash.ts. Both are false positives that surfaced now because d362e68 added sha256Base64Url to this file — touching it made every pre-existing taint path ending here count as 'new code changed by this pull request'. The flagged lines and all their callers are unchanged.

Neither taint source is a human password:
- hashApiKey passes an API key built from generateSecureToken(24) — 192 bits of randomBytes. A fast digest is the right construction for indexed lookup; a slow KDF would run on every authenticated request and buy nothing against an unsearchable keyspace.
- passwordSlot passes an already-encrypted value, hashed to an 8-char discriminator that invalidates deployment auth tokens when the password changes — not credential storage.

User credentials never reach this helper; Better Auth owns them and applies its own KDF.

Suppress with the inline lgtm comments this repo already uses for the same class of judgement (see uuidV5 in ee/workspace-forking/lib/remap/block-identity.ts), and document the invariant on sha256Hex so a future caller knows a genuine password belongs in Better Auth, not here. Only the two flagged lines are suppressed — sha256Base64Url is left unannotated so a real finding there would still surface.
@vercel

vercel Bot commented Jul 27, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Jul 27, 2026 9:07pm

Request Review

@cursor

cursor Bot commented Jul 27, 2026

Copy link
Copy Markdown

PR Summary

Low Risk
Comment-only and suppression annotations; hashing logic is unchanged.

Overview
Unblocks a required CodeQL check that flagged sha256Hex with js/insufficient-password-hash on the hash.update calls (false positives from taint on high-entropy API keys and encrypted-password slots, not user passwords).

Adds inline // lgtm[js/insufficient-password-hash] on both hash.update paths in sha256Hex, matching the repo’s existing CodeQL suppression style. Expands the sha256Hex doc comment to state the invariant: fast SHA-256 is for high-entropy secrets and digests only; human passwords stay in Better Auth’s KDF. No runtime behavior change.

Reviewed by Cursor Bugbot for commit 491c318. Bugbot is set up for automated code reviews on this repo. Configure here.

@greptile-apps

greptile-apps Bot commented Jul 27, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR documents the intended non-password uses of sha256Hex and adds targeted CodeQL suppression annotations to its two input branches.

  • Clarifies that human-chosen passwords require a slow KDF.
  • Documents current high-entropy, encrypted-value, and content-digest use cases.
  • Adds no runtime behavior changes.

Confidence Score: 5/5

The PR appears safe to merge because it changes only comments and accurately preserves the helper’s existing runtime behavior and usage contract.

The documented invariant matches current callers, and the inline annotations do not alter hashing inputs, outputs, control flow, or security boundaries.

Important Files Changed

Filename Overview
packages/security/src/hash.ts Adds accurate usage guidance and targeted static-analysis suppressions without changing hashing behavior.

Reviews (1): Last reviewed commit: "fix(security): suppress the CodeQL passw..." | Re-trigger Greptile

@TheodoreSpeaks
TheodoreSpeaks merged commit 334c7c8 into staging Jul 27, 2026
20 checks passed
@TheodoreSpeaks
TheodoreSpeaks deleted the fix/codeql-hash-suppression branch July 27, 2026 22:03
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.

1 participant