Skip to content

docs: map who may supply each input that reaches the page - #707

Merged
JuroOravec merged 5 commits into
mainfrom
docs/trust-boundary-603
Nov 15, 2026
Merged

JuroOravec merged 5 commits into
mainfrom
docs/trust-boundary-603

Conversation

@JuroOravec

@JuroOravec JuroOravec commented Nov 15, 2026 •

Copy link
Copy Markdown
Member

Closes #603.

To know whether request data may reach a Citry API, an app developer had to read the security page, the docstring, and often the code. This PR adds one design doc that answers it for every input that reaches the page, and adds the missing "never from request data" notes to the public docs.

What changes

  • docs/design/trust_boundaries.md (new). One table per area: template text, attributes (values, names, URLs), tags, slots and markers, template source and the sandbox, component data and assets, Vue and translated text, Events actions and requests, routes and responses, extension hooks and the render cache, the opt-in output checks, Citry UI, and Citry's browser runtime. Each row says who may supply the input (request data OK, app code, author only, or undecided with an issue link), what the browser does with it, which function checks it (file:line) on which render paths, and which page says so. Every row was taken from the code, then checked against the code by two independent security reviewers (see Review).
  • Links: section 2 of docs/design/security-hardening.md, docs/agent/INDEX.md, and Mechanism 7 step 6 in CLAUDE.md point to it.
  • A check for missing rows: scripts/validators/trust_boundary_rows.py fails when the doc does not name a public Extension method, a hook fired by name (emit("..."), _extensions_with_hook("...")), an Events action, or a security_* setting. It runs in the validators phase of scripts/check.py (fast and full profiles) and takes about half a second. New template syntax and keyword arguments still rely on the security pass; a wider list (every function that returns Markup) was left out because it would need hand-kept exceptions.
  • Author-only and app-code notes added where the code makes an input unsafe for request data but no page said so:
    • syntax/attributes.md (c-style), advanced/html-attributes.md (style, format_attrs names), advanced/dynamic-components.md (c-is), advanced/js-and-css-dependencies.md (css_data() url(...)), advanced/dependency-files.md (library URLs, Script/Style), syntax/vue.md (v-html, :innerHTML, :srcdoc, URL bindings, :style, <component :is>, :onclick), i18n/rich-messages.md (tr() in a URL attribute), advanced/extensions.md (hooks that return source, hook-set URLs, on_dependencies), events/actions.md (Dispatch names), reference/browser-apis.md (applyActions), ui-library/index.md (Citry UI URL schemes, attribute maps and style).
    • Docstrings: Component.template_file, Script, Style, format_attrs, RouteResponse, I18nService.tr/resolve, I18nExtension.tr/resolve, Extension.on_slot_rendered, and the ValueError of Extension.on_attrs_resolved.
    • Two Citry UI pages (cmenu/api.md, csplitbutton/api.md) called a checked URL "trusted"; they now state the scheme rule.

No code behaviour changes. No changelog entry: the user-visible part is docs and docstrings.

security.md

#695 has merged, so this PR also edits docs_site/content/security.md: "Check URL attributes" now names the content of <meta http-equiv="refresh"> and the to, from, by, and values of SVG <set> and <animate>, and a new section, "Protect the render cache", says that whoever can write the cache store can put HTML into the page. README.md, SECURITY.md and _nav.yml need no change.

Undecided rows and the issues they link

None of these lets request data run script, as far as the reviews found.

The Citry UI section has one "known exception" row for the four inputs #697 fixes; delete it when #697 merges. The ui-library/index.md note states the URL rule without that exception, so it is exact once #697 is in; both are planned for the same release.

Checks

  • scripts/validate.py: all validators pass, including the new one.
  • pytest packages/py/citry/tests/test_trust_boundary_rows_validator.py: 7 passed.
  • ruff check, ruff format --check, mypy (also --platform linux) on the changed Python.
  • CI was not waited on (docs-only PR). Not run locally: the full fast gate (it would create a new environment and build the Rust crates in this worktree) and the docs build-check (the shared environment lacks the docs extra). CI runs both.

Review

Three independent reviews ran on the change, plus a separate prose pass.

  • Security review, two agents (sections 1-7 and 8-14 of the doc). Each listed the routes every input can take to the page and checked the doc's rating against the code. Neither found a way for request data to run script in a released version. Both read the advisory survey (Mechanism 8) and checked the bug kinds that apply (attribute-name injection, URL schemes, dynamic tags, CSS injection, prototype keys, DOM clobbering, header injection, cache poisoning). Fixed during the review: the cache-hit claim, the HTML comment and script_json claims, the ratings of the marker names and of Dispatch names, missing rows (<component :is>, :style, on_event, on_event_error, security_script_integrity, CORS and Cache-Control), the validator now also covering hooks fired by name, and many file:line references. The findings that need a code decision became Refuse Citry's own marker names in c-bind keys #699 to Decide whether Dispatch refuses names of standard DOM events #704.
  • Prose pass. Applied: plain wording for the rating labels and render paths, coined terms removed, the "docs gaps" list turned into the "Docs still to add" section, issue titles reworded.
  • Docs cold read of every changed page and docstring. Applied: corrected what on_template_foreign_spans and on_messages_loaded return, moved the tr() URL note under its own heading, stated the <component :is> behaviour from the bundled Vue source, removed an unproven nonce claim from applyActions, defined "request data" on each page, listed the Citry UI scheme rules, split the dense csplitbutton and extensions paragraphs, and renamed the csplitbutton heading. Not applied: the cmenu "Trust boundary" heading and an older TypeError sentence in on_attrs_resolved, which this change does not touch, and the URL list on security.md, which docs: add the Versioning and support page #695 owns.

🤖 Generated with Claude Code

JuroOravec and others added 5 commits November 15, 2026 13:51
Correct what two extension hooks return, give the tr() URL note its own
heading, define request data on each page, list the Citry UI URL
schemes, drop an unproven nonce claim, and update the design doc's line
references.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec merged commit f89cabd into main Nov 15, 2026
32 checks passed
@JuroOravec
JuroOravec deleted the docs/trust-boundary-603 branch November 15, 2026 14:23
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.

Write a trust-boundary design doc for the template and extension APIs

1 participant