Skip to content

fix(http): send nosniff on the JSON response lanes - #219

Closed
katsugtgz wants to merge 1 commit into
flop-labs:mainfrom
katsugtgz:fix/nosniff-json
Closed

katsugtgz wants to merge 1 commit into
flop-labs:mainfrom
katsugtgz:fix/nosniff-json

Conversation

@katsugtgz

@katsugtgz katsugtgz commented Aug 25, 2026 •

Copy link
Copy Markdown

What

text() and humans() always send X-Content-Type-Options: nosniff. Three emitters build Response(...) directly and never did: the ?format=json branch of respond(), _document(), and stats(). This adds the header to all three. The agent-surface test now fetches /r/lobby?format=json, /rooms?format=json and /openapi.json.

Why

The JSON bodies carry stored user text: message text, and topic. Anyone can set a topic on any room through /kv/topic/<room>. design.md 4.1 says every agent surface is nosniff, but test_agent_surfaces_are_never_html fetched only the plain-text variants. The JSON lanes drifted with no CI signal. application/json is not sniffed by current browsers, so this is hygiene, not an open sink.

sz-baseline.json caps record the deliberate five-line growth (app.py 977 to 982), same precedent as the 0.9.0 bump.

Checks

  • Extended test fails without the fix (KeyError: 'x-content-type-options'). Passes with it.
  • uv run python -m pytest tests/http/test_docs.py -q: 47 passed
  • ruff check, ruff format --check, ty check, sz.py --check

text() and humans() always sent X-Content-Type-Options: nosniff, but
three emitters build Response(...) directly: the ?format=json branch of
respond(), _document() and stats(). Their bodies carry stored user text
(message bodies, topics anyone can set on any room through
/kv/topic/<room>). design.md 4.1 says every agent surface is nosniff.
But the regression test fetched only the plain-text variants, so the
JSON lanes drifted with no CI signal.

One shared JSON_HEADERS for the two identical sets, one inline addition
for the cached document lane. The test now fetches /r/lobby?format=json,
/rooms?format=json and /openapi.json. sz caps record the deliberate
five-line growth, following the 0.9.0 precedent.
@sv sv added the bug Something isn't working label Aug 27, 2026 — with Claude
@katsugtgz katsugtgz closed this by deleting the head repository Sep 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants