Skip to content

fix(ui): refuse Citry's reserved data-* names in every Citry UI attrs map - #722

Merged
JuroOravec merged 2 commits into
mainfrom
fix/citry-ui-marker-names-716
Nov 15, 2026
Merged

JuroOravec merged 2 commits into
mainfrom
fix/citry-ui-marker-names-716

Conversation

@JuroOravec

Copy link
Copy Markdown
Member

Closes #716.

What changes

Every Citry UI attrs= and *_attrs= map now runs one shared check, reject_citry_ui_reserved_attr in citry_ui/components/_attrs.py. It raises ValueError for a name that starts with data-citry-, data-cui-, data-cev or data-cid, compared after lowercasing ASCII letters only, as browsers compare names.

  • About 68 components already refused data-citry-, data-cev and data-cid with their own copy of the loop. Those copies now call the shared check.
  • CButton, CCombobox, CDialog, CDrawer, CField, CForm, CSidebar, CTable and CTabs refused only the names they set themselves. reject_owned_attrs now calls the shared check, which covers them. CTabs and CTable have their own helpers, which call it too.
  • data-cui-* is new for every component. Citry UI's browser code reads data-cui-* names too, and the independent review found that data-cui-listbox-option-disabled from data on a CListboxOption made the option behave as disabled.
  • Eight components (CCalendar, CDatePicker, CDateRange, CNumberInput, CPinInput, CRating, CSlider, CTimePicker) did not refuse data-cev; they do now. Their own extra prefixes (data-cni and so on) stay.

Slot attrs keep working

Some components hand their own marker names to the caller in slot data, for example CDialog's activator_attrs holds data-citry-dialog-trigger, and the documented pattern spreads it onto a button: <c-CButton c-attrs="activator_attrs">. A plain list of allowed names would let request data name data-citry-dialog-close too, which is the case in the issue.

So the components that hand out such names now write the value as CitryUiOwnedValue, a str subclass. The check accepts a data-citry-* name only with such a value (or None/False, which write no attribute). Request data and JSON only produce a plain str, and string operations drop the subclass. Merging your own keys ({**activator_attrs, 'title': 'More'}) keeps it. I checked that the value survives slot data into CButton on static pages and on a State-backed (Vue) page.

CContextMenu(target_attrs=) keeps accepting data-citry-context-menu-native, its documented escape that only turns the custom menu off, and re-marks it so it can reach a <c-CButton> in the target slot.

Why the whole prefix, not a list from the browser code

The browser code builds some names at run time (dataset[...], names made from a part or action), so a list read from the source would miss names and go stale with the next component. Refusing the prefix covers names a later release starts reading. A test scans the shipped source (component js, runtime.source.js, templates, CSS, dataset.citryX properties) for every data-citry-*/data-cui-* name and fails if the check stops refusing one.

Tests

  • packages/py/citry_ui/tests/test_reserved_attr_names.py: the shared check (prefixes, ASCII case, non-ASCII lookalike passes, None/False, owned value, data-cid never unlocked, extra prefixes); the source scan; CButton with the issue's case; Dialog and Popover slot attrs on a CButton (also with keys added); the ContextMenu escape; one render case each for CDialog, CDrawer, CForm, CField, CSidebar, CTabs (attrs, tab_list_attrs), CCombobox input_attrs, a CTable cell, a CListboxOption data-cui-* name; and a source check that every component module with an attrs input calls the shared check.
  • About 40 component tests matched the old per-component messages ("reserved Citry runtime attribute" and variants); they now match the shared message. The behaviour they test is unchanged.

Checks

  • Citry UI unit suite: 3761 passed, 2 failed. Both failures (test_distribution_metadata_and_resources_use_only_the_citry_ui_namespace, test_the_editor_accepts_digit_inputs_as_text_or_numbers) fail the same way on main in my local environment.
  • ruff check, ruff format --check (repo), scripts/validate.py: pass.
  • mypy on citry_ui and --platform linux: pass.
  • Not run locally: the full gate (it builds Rust, which this change does not touch), docs_site/tests (the local environment lacks lxml), and the browser e2e tests. CI covers them.

Review

An independent reviewer (technical, Mechanism 7 security brief: attribute names and markers for Citry's browser code, Mechanism 8 advisory survey) ran a harness that injected a probe name into every attrs/*_attrs input of every quality scenario: all 171 public inputs reached the check with the real value. Findings and what I did:

  • data-cui-* names reach the browser code from data (CListboxOption). Fixed: prefix added, test added.
  • Static guard can be satisfied by one call per module. Kept as a cheap guard for new components; the probe result above is the evidence for today. A render-based guard needs a hook into Citry's private input handling, so it is left out.
  • Source scan only covered data-citry-. Fixed: it covers data-cui- and names one such name.
  • CField, CSidebar, CTabs, ContextMenu refusal and None had no component-level test. Fixed.
  • Docs and comments missed data-cui-; "storage cannot produce one" was too strong; data-cni and similar extra prefixes are read by no browser code. Fixed wording; extra prefixes kept as they were.
  • An owned value is not tied to its name, so app code could move it to a key chosen by data. Author-only, recorded in trust_boundaries.md.
  • "CTabs tab_list_attrs attrs" doubled label. Fixed.
  • Mechanism 8: the survey classes that apply (attribute-name XSS, spread, hydration markers, trust by type, cache keys) are not introduced; the cache key encoder refuses a str subclass, so no collision.

A docs cold read and prose pass (docs-cold-reader) asked to move the CButton rule under "Configure Button", say how to add keys to slot attrs, put "rename the key" first in the error message, add an upgrade action to the changelog, reflow lines, and fix several comments and docstrings. All applied.

🤖 Generated with Claude Code

JuroOravec and others added 2 commits November 15, 2026 18:16
Every Citry UI attrs= and *_attrs= input now runs one shared check,
reject_citry_ui_reserved_attr, which refuses a name that starts with
data-citry-, data-cev or data-cid. Most components already refused these
prefixes with their own copy of the loop; CButton, CCombobox, CDialog,
CDrawer, CField, CForm, CSidebar, CTable and CTabs refused only the names
they set themselves.

A data-citry-* name passes only with a CitryUiOwnedValue, which Citry UI
writes into slot data such as activator_attrs, so the documented
<c-CButton c-attrs="activator_attrs"> composition keeps working.

Closes #716

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Citry UI's browser code also reads data-cui-* names, such as
data-cui-listbox-option-disabled on a listbox option, so the shared
check refuses that prefix as well. The error message now puts "rename
the key" first, the docs say how to add keys to slot attrs, and the
trust boundary rows cite the moved line numbers.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JuroOravec JuroOravec added this to the 1.0.0 milestone Nov 15, 2026
@JuroOravec
JuroOravec merged commit e5b57c6 into main Nov 15, 2026
31 checks passed
@JuroOravec
JuroOravec deleted the fix/citry-ui-marker-names-716 branch November 15, 2026 18:12
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.

Citry UI: refuse Citry UI's own data-citry-<component>-* names in attrs= and c-bind

1 participant