Skip to content

fix(ui): check CSkeleton sizes, refuse is and key in item attrs, send trusted strings as text - #757

Merged
JuroOravec merged 7 commits into
mainfrom
fix/citry-ui-hardening
Nov 18, 2026
Merged

JuroOravec merged 7 commits into
mainfrom
fix/citry-ui-hardening

Conversation

@JuroOravec

@JuroOravec JuroOravec commented Nov 18, 2026 •

Copy link
Copy Markdown
Member

What changed

Tightens several Citry UI inputs. Every change is in citry-ui, which is still 0.x, so the new refusals are allowed there and the changelog states each one.

  • CSkeleton sizes. width, height and last_line_width now take one positive CSS length or percentage (px, rem, em, ch, vw, vh, vmin, vmax or %), the units CGrid(min_col=) takes plus %. Anything else raises ValueError. Before, any text without ;, braces or a comment reached the CSS custom property.
  • is and key in item attrs. The root attrs of CListItem (and its surface_attrs), CTimelineItem, CTreeItem, CSortableItem, CTransferListItem, CVirtualListItem and the CNativeSelect root now refuse is and key in any letter case. They use the shared reject_data_item_vue_name helper, the same rule the table, grid, select and breadcrumb data items already follow. Before, key failed the render of four of these items with an unclear template error. The helper's message now fits every caller.
  • str subclass names. reject_citry_ui_reserved_attr calls str.translate on the class, so a str subclass name is read as its real text.
  • Trusted strings in browser data. CButton sends its href and a tabindex from attrs to the browser through attribute_text, and CAvatar does the same for img_attrs. A Markup or Django SafeString value no longer fails the render with a TypeError, and the browser code gets the same decoded text the server writes into the attribute.
  • Label placeholders. A new shared fill_label helper fills app-supplied label patterns on the server by replacing each exact {name} as plain text, the same way the browser code fills them. It replaces str.format in CTransferList (count_label), CSortable, CFormCollection, CTreeGrid, CRating, CCascader, CTagsInput and CToast. A format spec such as {total:>99} now stays in the label as typed instead of padding the text, so the server and the browser show the same label.
  • Docs: docs/design/trust_boundaries.md section 13 (the is/key sentence, the CSS row, a new label row, two stale line cites) and cskeleton/api.yml.

Why

Each input now gets a check that matches what its docs promise (CSkeleton sizes), one rule across every attribute map (is and key), and the same text on the server and in the browser (trusted strings, label placeholders).

Checks

  • New tests: 133 (CSkeleton sizes, item is/key, the str subclass name, Markup and SafeString in browser data, fill_label and two components that use it, the CTransferList count label). The independent reviewer ran them against the base commit: 84 fail there and test_fill_label.py fails at import.
  • citry-ui non-e2e suite: 4,406 passed, 6 skipped.
  • ruff check, ruff format --check (0.14.13): clean. mypy (1.20.2) on the touched modules and new tests: clean, also with --platform linux.
  • Not run: the e2e suites (one e2e test only changes the message it matches), the docs build, the full repository gate.

Review

An independent reviewer covered security (attribute names, CSS, URL attributes), checked the change against the kinds of bug in other frameworks' published advisories, and did a separate prose pass. Fixed during the review: a True tabindex now reaches the browser as "true", as the server writes it; end-to-end tests for the CTreeGrid and CSortable labels; changelog accuracy; comment wording; line cites.

Versioning

citry-ui 0.x only, nothing in citry or citry-core. The refusals and the label change are listed under [Unreleased] in packages/py/citry_ui/CHANGELOG.md; the next citry-ui minor release (0.7.0) covers them.

Addition: is and key in every attrs map

  • The shared reserved-name check that every attrs= and *_attrs= input calls (reject_citry_ui_reserved_attr) now also refuses is and key, in any ASCII letter case and with any value, with the same message as the data item maps. The layout components (CCard, CContainer, CGrid, CGridItem, CRow, CCol, CSidebar) now take their tag only from their fixed tag= list. Core's <c-element> tag checks apply as before.
  • Tests: tests/test_root_attrs_vue_names.py (59 cases over seven layout components, CButton and a non-root CCombobox.input_attrs, plus data-key and tag= controls) replaces tests/test_foreign_is_from_attrs.py, whose attrs={"is": ...} route is now refused; 16 new unit cases in test_reserved_attr_names.py. The existing source sweep there checks every component module with an attrs input calls the shared check. Whole non-e2e citry_ui suite: 4460 passed, 109 skipped; ruff and mypy (also --platform linux) clean on touched files.
  • Docs: the changelog entry, the trust_boundaries.md rows for attribute names and tags, and the "Pass request data safely" list on the Citry UI page.
  • Versioning: citry-ui is 0.x and this refuses input it used to accept, so it belongs in the next minor release (0.7.0), not a patch.
  • Independent review (technical, security and a separate prose pass): no missed path and no hole found; its prose and docstring suggestions are applied.
  • str subclass keys in every name check. Each attribute-name check, including reject_owned_attrs and the CButton formaction check, now reads a key through attr_name_text() as the plain text Citry writes, so a str subclass key gets the same checks as a plain str (13 new tests in tests/test_str_subclass_attr_names.py; citry_ui non-e2e suite 4468 passed, 109 skipped; independent review found no hole).

🤖 Generated with Claude Code

https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED

JuroOravec and others added 4 commits November 18, 2026 05:45
…send trusted strings to the browser as text

- CSkeleton width, height and last_line_width accept one positive CSS
  length or percentage, in the units CGrid min_col takes plus %.
- The root attrs of the list item components and of CNativeSelect refuse
  `is` and `key`, through the shared reject_data_item_vue_name helper.
- reject_citry_ui_reserved_attr reads a str subclass name as its real text.
- CButton href and tabindex, and CAvatar img_attrs, send the browser the
  same decoded text the server writes, so Markup and SafeString values no
  longer fail the render.
- Label patterns with placeholders are filled on the server by plain text
  replacement, as the browser code fills them (shared fill_label).

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
The shared reserved-name check, which every Citry UI attrs= and
*_attrs= input calls, now also refuses `is` and `key` in any ASCII
letter case, as the data item maps already do. The layout components
(CCard, CContainer, CGrid, CGridItem, CRow, CCol, CSidebar) choose
their tag only from their fixed tag= list.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
Resolve the conflicts in docs/design/trust_boundaries.md and
docs_site/content/ui-library/index.md. Main's refreshed rows (the
CNavigationMenuLink row, the longer list of attribute names a request can
still set, the form= and CTourStep id row) are kept. Where this branch
changes behavior, its text wins: every attribute map refuses is and key,
CSkeleton sizes are checked, and label patterns use fill_label. Line
numbers are checked against the merged code.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
Each Citry UI attribute-name check now reads the key through
attr_name_text(), which copies the stored characters into a plain str
before lower(), casefold(), startswith() or set membership runs. A key
of a str subclass now gets the same checks as a plain str key in the
shared owned-name check, CButton's formaction and link-only form
attribute checks, and the per-component attribute allowlists. Citry
already writes such a key into the page as its stored characters, so
the checks now compare the same text the browser gets.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
JuroOravec and others added 3 commits November 18, 2026 12:20
Resolves the conflict in docs/design/trust_boundaries.md. The label
pattern row and the CIcon row keep this branch's text and line numbers.
The id and name row keeps main's text about form members read past a
control with the same name, with this branch's validate_html_id line
number.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
The merge of main moved REFUSED_DYNAMIC_ELEMENT_TAGS in client.js from
line 888 to line 904, so the dynamic tag row cites the new line.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
Resolves the conflict in docs/design/trust_boundaries.md. The dynamic
element row keeps this branch's Citry UI wording (Citry UI refuses an
`is` key in its attribute maps) and takes the line numbers the merged
tree has for html.py, replay.py and client.js. The Citry-owned binding
row now points at attrs.py:140-143.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED
@JuroOravec
JuroOravec merged commit cb240f3 into main Nov 18, 2026
30 checks passed
@JuroOravec
JuroOravec deleted the fix/citry-ui-hardening branch November 18, 2026 12:23
JuroOravec added a commit that referenced this pull request Nov 18, 2026
)

* docs(security): add review records for #754, #755, #756, #757 and #759

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED

* docs(security): apply review findings to the 1.0.2 hardening records

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01KUhrHXH1mNfRCnPcsQt7ED

---------

Co-authored-by: Claude Opus 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.

1 participant