Skip to content

fix: refuse Citry's reserved attribute names as c-bind keys - #713

Merged
JuroOravec merged 1 commit into
mainfrom
fix/c-bind-marker-names-699
Nov 15, 2026
Merged

JuroOravec merged 1 commit into
mainfrom
fix/c-bind-marker-names-699

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

What changes

On an HTML element, a c-bind key may no longer be one of the attribute names Citry uses to find its own elements and placeholders in the page:

  • c-render-id, data-cid, data-citry
  • data-citry-key, data-citry-morph, data-citry-i18n, data-citry-i18n-binding
  • names starting with data-cid-, data-ccss-, data-cev-, data-citry-css-, data-citry-omit-handler-, data-citry-opaque-, data-citry-runtime-, data-citry-security-, data-citry-vue-

Before this change, a key taken from request data could, for example, put c-render-id="<another component's id>" on an empty <template>, and the server join step copied that component's HTML into a second place on the page.

The key raises ValueError in any ASCII letter case, the same error type as the existing refusal for onclick, innerHTML, outerHTML and srcdoc. The message names the attribute, says why, and says how to fix it. The Events names (data-cev-*, data-citry-runtime-control, data-citry-runtime-events) and data-citry-i18n-binding on an i18n element keep the RuntimeError they raise today, because their checks run first.

One check, reject_citry_marker_attr_name in citry/attrs.py, runs everywhere c-bind is applied to an element:

  • the node path
  • the Vue leaf programs, both the full merge and the fast root-spread plan
  • elements with a $c-tr binding
  • <c-element>: the component-tag spread and _resolve_element_attrs

Deliberate scope

  • Only the data-citry-* names that core Citry reads, not the whole prefix. Citry UI passes its own data-citry-<component>-* names through c-bind.
  • Names the template author writes on a plain element are still accepted, for example <div data-cid-x> and <div c-c-render-id="...">. They never reach this check, and they are author input.
  • <c-element> with c-is or c-bind refuses these names even when the template writes them. It cannot tell a written name from data, the same as for onclick. This is the same code path as the existing handler refusal. A static <c-element is="div" data-cid-x> compiles to a plain element and is still accepted.
  • on_attrs_resolved hooks may still add these names. A hook is extension code, and the Events extension adds data-cev-* this way.
  • format_attrs() is unchanged; that question is Decide whether format_attrs refuses the names c-bind refuses #700, moved to 1.1.
  • The issue's option 2 is not done. That option makes join_frames fill a placeholder only for the frame's own children. It stays listed in the trust-boundary doc's open questions.
  • data-allow-mismatch is not refused. It is Vue's own public attribute. The trust-boundary doc now explains why it is left out.

Compatibility

This refuses input that citry 0.9.0 accepted. That is allowed because 1.0.0 has not shipped, and the changelog lists it under "Upgrading from 0.9.x".

One existing test changed: test_component_dynamic.py expected a written data-citry-key on <c-element c-is> with #c-key to fail with the metadata-conflict message. It now fails earlier, with the reserved-name message. The metadata-conflict check still runs after hooks, and a new test covers that.

Docs

  • docs/design/trust_boundaries.md: updated the rows for c-bind keys, <c-element> names, render ids and placeholders, and Citry UI attribute maps, and marked the Refuse Citry's own marker names in c-bind keys #699 open question decided. The join_frames part stays open. Line references into the touched files were updated.
  • docs_site/content/advanced/html-attributes.md: new "Names Citry reserves" section.
  • docs_site/content/syntax/attributes.md and advanced/dynamic-components.md: short notes that link to that section.
  • CHANGELOG.md: an upgrade note.

Checks

  • pytest over packages/py/citry/tests and packages/py/citry_ui/tests (not e2e, not qualification): 14714 passed. Two Citry UI tests fail, and they fail the same way on origin/main in the shared environment (test_distribution_metadata_and_resources_use_only_the_citry_ui_namespace, test_the_editor_accepts_digit_inputs_as_text_or_numbers).
  • New tests cover:
    • each reserved name through each path (plain, <c-element> static and dynamic, Vue, Vue-prepared, $c-tr element, Vue leaf rows)
    • mixed case
    • controls that must still render: data-x, data-cidr, data-citry-ui-part, and non-ASCII lookalikes
    • written names
    • hooks
  • A mutation check confirmed that the leaf-row tests fail when the leaf-program check is removed.
  • ruff check and ruff format --check pass. mypy passes for darwin and --platform linux. scripts/validate.py passes.
  • The docs-site tests could not run in the shared environment, which lacks the docs extras. CI runs them.

Independent review

A separate reviewer did a technical, security (Mechanism 7) and advisory-survey (Mechanism 8) pass. A docs cold reader did a prose pass.

Mechanism 7 result:

  • The hole was reproduced on origin/main: a c-bind key c-render-id copied another component's HTML, with and without Vue. It is closed on this branch.
  • These are refused: letter-case variants, str subclasses, UserDict and MappingProxyType mappings, and Citry UI attrs=.
  • Unicode lookalikes (U+0130, fullwidth, Kelvin, zero-width) render as different names. Citry's readers and browsers compare names using ASCII letters only, so these cannot stand in for a reserved name.

Mechanism 8 result: the reviewer read the advisory survey and checked these classes: xss-attrname, xss-spread, sanitizer-bypass, hydration, xss-dyntag, cache-xuser/deserialize, and dom-clobber. None is introduced.

Findings fixed during the review:

  • A first version also checked dynamic elements in the Vue writer. That refused a reserved name added by an on_attrs_resolved hook on a Vue page, but not on a page without Vue. The check was removed, so hooks behave the same on both. A test now covers it.
  • The leaf-program checks had no test of their own. Reserved names were added to ERROR_CASES in test_simple_vue_row_caches.py, and a mutation check confirmed the new cases fail when those checks are removed.
  • The docs gave the wrong error type for data-citry-runtime-* and for data-citry-i18n-binding. Both corrected.
  • The cold reader asked for these changes, all applied:
    • say that the rule applies to HTML elements, not component tags
    • define "reserved names" in plain words
    • point to the docs list from the error message
    • several comment and wording fixes

Closes #699

🤖 Generated with Claude Code

On an HTML element, a c-bind key may no longer be c-render-id,
data-cid, data-cid-*, data-ccss-*, or a data-citry-* name core Citry
reads, and a <c-element> that has c-is or c-bind refuses these names
whether the template wrote them or data passed them in. Citry uses
these names to find its own elements and placeholders in the page, so
a name taken from request data could make the server copy another
component's HTML into a second place on the page.

One check, reject_citry_marker_attr_name in citry/attrs.py, runs
everywhere c-bind is applied to an element: the node path, the Vue leaf
programs (full merge and the fast root-spread plan), elements with a
$c-tr binding, and <c-element>.

Closes #699

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec
JuroOravec merged commit a09203a into main Nov 15, 2026
33 checks passed
@JuroOravec
JuroOravec deleted the fix/c-bind-marker-names-699 branch November 15, 2026 16:27
JuroOravec added a commit that referenced this pull request Nov 16, 2026
* docs: record the security reviews of #713, #714, #718 and #722

Adds the Mechanism 7 step 7 records for four merged pull requests:
GHSA-x773 (#713, reserved attribute names as c-bind keys), #714
(out-of-date pages and the rolling-deploy check), #718 (one Rust URL
scheme reader), and GHSA-7fjh (#722, reserved data-* names in Citry UI
attribute maps). The two advisory records name the advisory and the
affected and fixed versions; the facts come from the pull requests.

Co-Authored-By: Claude Sonnet 5.5 <[email protected]>

* docs: link the #720 follow-up from the #714 review record

Co-Authored-By: Claude Opus 5.5 <[email protected]>

---------

Co-authored-by: Claude Sonnet 5.5 <[email protected]>
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.

Refuse Citry's own marker names in c-bind keys

1 participant