Skip to content

fix(ui): mint the demo cookie without reading client input (CodeQL)#28

Merged
Neverdecel merged 1 commit into
masterfrom
claude/fix-codeql-demo-cookie
Jun 16, 2026
Merged

fix(ui): mint the demo cookie without reading client input (CodeQL)#28
Neverdecel merged 1 commit into
masterfrom
claude/fix-codeql-demo-cookie

Conversation

@Neverdecel

Copy link
Copy Markdown
Owner

Follow-up to #25.

CodeQL kept flagging "construction of a cookie using user-supplied input" on the
demo-mode session cookie (webui.py). The previous demo_session() returned a tuple
(existing_cookie, fresh_token), and CodeQL's tuple-taint tracking conflated the two —
treating the freshly minted token as tainted even though set_cookie only ever writes
the minted secret (a behavioural false positive, since the client value was only used
as the in-memory quota key).

Fix: replace it with mint_demo_cookie(request), which checks only whether the
cookie is present (never reads its value) and returns a fresh secrets token or
None. The client's cookie value is now used solely as the quota key and never flows
into a Set-Cookie header, so there is no request→cookie dataflow for CodeQL to follow.

  • Add a regression test asserting the demo cookie is server-minted on first visit and
    never reflected back when the client sends a crafted value.
  • Behaviour is otherwise unchanged: ruff / mypy / 14 web-UI tests pass.

https://claude.ai/code/session_01F6oNAiyr3AfD5dsZ7G2Vy4


Generated by Claude Code

CodeQL flagged "construction of a cookie using user-supplied input" on the
demo-mode session cookie. The previous demo_session() returned a tuple
(existing_cookie, fresh_token); CodeQL's tuple-taint tracking conflated the two
and treated the freshly minted token as tainted, even though set_cookie only
ever writes the minted secret.

Replace it with mint_demo_cookie(), which checks only whether the cookie is
present (never reads its value) and returns a fresh secrets token or None. The
client's cookie value is now used solely as the in-memory quota key and never
flows to Set-Cookie. Add a regression test asserting the cookie is server-minted
and never reflected.

https://claude.ai/code/session_01F6oNAiyr3AfD5dsZ7G2Vy4
@Neverdecel Neverdecel merged commit af6403d into master Jun 16, 2026
11 checks passed
@Neverdecel Neverdecel deleted the claude/fix-codeql-demo-cookie branch June 18, 2026 08:01
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.

2 participants