Skip to content

docs: add Events security notes for HEAD, redirects, and data classes - #752

Merged
JuroOravec merged 1 commit into
mainfrom
docs/events-security-notes
Nov 18, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
docs/events-security-notes

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

What changed

Docs and two docstrings. No code behavior changes.

  • HEAD and OPTIONS handlers (security.md, events/routes.md, both migration guides). These are read-only methods in HTTP, and Django's CSRF token check skips them. Citry still runs its own header checks and any _csrf function. A handler that accepts HEAD or OPTIONS must only read data, and that includes a head or options method on a ViewEvents class. The section heading is now "Keep GET, HEAD read-only", and its anchor stays the same. The component-view guide's sentence "Django's CSRF middleware still applies" now has a separate warning about these methods next to it.
  • Redirect checks outside Django (security.md, the Redirect warning in events/actions.md). Flask and FastAPI apps can call Django's url_has_allowed_host_and_scheme, because it needs no Django settings. A hand-written check must read the URL as written and again with \ changed to /. The page lists the URL forms that a check based only on urlsplit().hostname lets through. Citry's own redirect handling is unchanged.
  • __Host- CSRF cookie name under "Use Django's token": the Django settings and the Citry.configure call it needs, and what fails if the call is missing.
  • Blocking page framing: a new short section, "Block page framing", covering X-Frame-Options and frame-ancestors.
  • Pydantic model data classes accept "5" and true for an int and drop unknown fields, while dataclasses and plain classes refuse them. The page says how to refuse unknown fields with extra="forbid", and why strict=True breaks form posts.
  • RouteResponse from a bundle=False handler: a new section, "Send your own response". Citry does not check its header names, header values, or content_type.
  • Dispatch (Decide whether Dispatch refuses names of standard DOM events #704): the docstring and docs page say the name must come from app code. They also say that in Firefox a submit event on a form root submits the form. Decide whether Dispatch refuses names of standard DOM events #704 stays open for the planned deprecation.
  • format_attrs (Decide whether format_attrs refuses the names c-bind refuses #700): the docstring and the HTML attributes page now name Citry's marker names in the rule. The trust_boundaries.md rows for format_attrs, Dispatch and RouteResponse are updated, and the Decide whether format_attrs refuses the names c-bind refuses #700 open-question row is removed.

Closes #700

Checks

  • I checked each claim against code on main. I also ran probes against citry 1.0.1, Pydantic 2.14.3 and Django 6.1.3:
    • Django's check without settings.configure(), on 13 URL forms;
    • Pydantic model, dataclass, plain class, model_base and strict=True binding, through validate_args;
    • format_attrs with marker names.
  • The security reviewer ran the Firefox submit behavior in Firefox, Chromium and WebKit builds.
  • ruff check and ruff format --check pass on the two Python files.
  • Headings are at most 24 characters, and code lines at most 70 characters.
  • I did not run the docs build: the worktree is sparse.
  • Independent reviews: a security review, a prose pass and a cold read. I applied their findings:
    • a neutral HEAD wording that names _csrf;
    • OPTIONS covered on every page;
    • the single-slash and /// URL forms added;
    • the __Host- cookie needs on Domain and Path;
    • the framing and RouteResponse notes in their own sections;
    • the Dispatch warning moved into an admonition.

Versioning

Nothing the 1.x promise covers changes. The change only edits docs and docstrings, so it needs no changelog entry.

🤖 Generated with Claude Code

https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED

- Say that a handler accepting HEAD or OPTIONS, including a ViewEvents
  head or options method, skips Django's CSRF token check and must only
  read data.
- Show how a Flask or FastAPI app can call Django's redirect URL check,
  and which URL forms a hand-written check must refuse.
- Add short notes on the __Host- CSRF cookie name and on blocking page
  framing with frame-ancestors.
- Note that a Pydantic model data class accepts "5" for an int and drops
  unknown fields, and that RouteResponse headers are unchecked.
- Dispatch: choose the name in app code; in Firefox a submit event on a
  form root also submits the form.
- format_attrs: name Citry's marker names in the rule.

Closes #700

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
@JuroOravec
JuroOravec merged commit 23f9700 into main Nov 18, 2026
34 checks passed
@JuroOravec
JuroOravec deleted the docs/events-security-notes branch November 18, 2026 09:51
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.

Decide whether format_attrs refuses the names c-bind refuses

1 participant