Skip to content

fix(security): promote unknown bare elements for element bindings - #490

Merged
Brooooooklyn merged 1 commit into
mainfrom
fix/element-binding-ns-promotion
Sep 23, 2026
Merged

Brooooooklyn merged 1 commit into
mainfrom
fix/element-binding-ns-promotion

Conversation

@Brooooooklyn

@Brooooooklyn Brooooooklyn commented Sep 22, 2026

Copy link
Copy Markdown
Member

Summary

Follow-up to #334. A post-merge adversarial review found one real divergence from the vendored v22.0.0 baseline: element bindings skip the unknown-element promotion that calcPossibleSecurityContexts applies.

Upstream createBoundElementProperty (binding_parser.ts) computes security via calcPossibleSecurityContexts(registry, elementSelector, …), which rewrites a bare element missing from the DOM schema to its :svg: / :math: form (animate:svg:animate) whenever the namespaced schema exists (19.2.23 / 20.3.22 / 21.2.14 / v22+). Our element-binding path passed the verbatim resolved name to the schema lookup, so <animate [attr.to]> resolved animate|to → miss → None, where upstream resolves :svg:animate|toAttributeNoBindingɵɵvalidateAttribute.

Changes

  • element_security_context_for() routes element bindings through the same selector machinery as host bindings (collect_namespaced_contexts / collect_bare_contexts), so both paths share the promotion, :ns: splitting, and :not handling.
  • Version gating is unchanged: promotion only applies to namespaced-schema profiles — upstream added the promotion block in the same releases that shipped the namespaced schema.

Upstream quirks preserved

  • Pre-namespaced versions have no splitNsName: the whole selector goes through CssSelector.parse, so :svg:animate parses to element animate and hits the bare animate|to key — <svg><animate [attr.to]> keeps ɵɵvalidateAttribute at 21.2.7.
  • :xml:iframe on pre-namespaced versions likewise parses to iframe and hits iframe|src. Namespaced versions split the prefix; only normalizer versions (19.2.23 / 20.3.22 / 21.2.15+) strip it back — 21.2.14 alone looks up :xml:iframe|src verbatim and misses.

Tests

  • New unit test test_element_binding_promotes_unknown_bare_element (promotion on/off by version, :math: local-name promotion, known-element passthrough).
  • New integration test test_svg_animation_attr_binding_validates_on_namespaced_schema asserting emitted ɵɵvalidateAttribute for <animate [attr.to]> on v22 and 21.2.14, and its absence on 21.0.1.
  • Corrected two existing tests that codified verbatim-lookup behavior for prefixed elements on pre-namespaced versions.
  • 1122 lib tests, 435 integration tests, 1264/1264 conformance — all green.

Out of scope (post-v22.0.0 upstream changes)

The same review flagged upstream changes that landed after our vendored v22.0.0 and are tracked separately: credentialless iframe sink (22.0.2), namespaced→default schema fallback (22.0.2), MathML *|href wildcard (22.0.1), concrete-host scan in calcHostBindingSecurityContexts (22.1.0), i18n on* rejection (22.1.0), :math:script stripping (22.1.2), bare→svg fallback in checkSecurityContext (22.1.5). None apply to the v22.0.0 baseline this repo vendors; covering them would need finer-grained angular_version gating and is a separate decision.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 22, 2026

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review Completed 2026-09-23T02:29:18.812140Z 6d45cec New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Comment thread crates/oxc_angular_compiler/src/schema/dom_security_schema.rs Outdated

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f428e5a7e1

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread crates/oxc_angular_compiler/src/schema/dom_security_schema.rs Outdated
@Brooooooklyn
Brooooooklyn force-pushed the fix/element-binding-ns-promotion branch from f428e5a to 69726e0 Compare September 22, 2026 17:22
Upstream routes element bindings through `calcPossibleSecurityContexts`
(`binding_parser.ts`), which promotes a bare element missing from the DOM
schema to its `:svg:`/`:math:` form — the same promotion our host-binding
path already applies for selectors. Our element-binding path looked up the
verbatim name, so `<animate [attr.to]>` missed `:svg:animate|to` and emitted
no `ɵɵvalidateAttribute`.

`security_context` now shares `collect_namespaced_contexts` /
`collect_bare_contexts` via `element_security_context_for`, which keeps the
numerically lowest context — matching upstream's `securityContexts[0]` after
its enum sort. That preserves `NONE` for `tagName === null` selectorless
hosts, which expand over every known element upstream.

Upstream quirks preserved:

- Promotion exists only alongside the namespaced schema (19.2.23 / 20.3.22 /
  21.2.14 / v22). On earlier versions the whole selector goes through
  `CssSelector.parse` verbatim, so `:svg:animate` still parses to element
  `animate` and hits the bare `animate|to` key — `<svg><animate [attr.to]>`
  keeps `ɵɵvalidateAttribute` at 21.2.7.
- `:xml:iframe` on pre-namespaced versions likewise parses to `iframe` and
  hits `iframe|src`; only namespaced versions split the prefix, and only
  normalizer versions (19.2.23 / 20.3.22 / 21.2.15+) strip it back —
  21.2.14 alone misses, matching upstream.
@Brooooooklyn
Brooooooklyn force-pushed the fix/element-binding-ns-promotion branch from 69726e0 to 6d45cec Compare September 23, 2026 02:24
@Brooooooklyn
Brooooooklyn merged commit 41a66ed into main Sep 23, 2026
10 checks passed
@Brooooooklyn
Brooooooklyn deleted the fix/element-binding-ns-promotion branch September 23, 2026 03:10
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