Thanks to visit codestin.com
Credit goes to github.com

Skip to content

refactor(core): align namespaced attribute validation and security schema contexts - #68686

Merged
leonsenft merged 4 commits into
angular:mainfrom
alan-agius4:namespace-html
May 18, 2026
Merged

refactor(core): align namespaced attribute validation and security schema contexts#68686
leonsenft merged 4 commits into
angular:mainfrom
alan-agius4:namespace-html

Conversation

@alan-agius4

Copy link
Copy Markdown
Contributor

Refactors the element security schema lookups and runtime attribute validation to consistently account for SVG and MathML namespaces. This improves the modularity and accuracy of security context mapping during template compilation and runtime constant evaluation, eliminating redundant or false-positive lifecycle checks.

@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label May 12, 2026
@ngbot ngbot Bot added this to the Backlog milestone May 12, 2026
@alan-agius4
alan-agius4 marked this pull request as ready for review May 12, 2026 13:45
@pullapprove
pullapprove Bot requested a review from josephperrott May 12, 2026 13:45

@AndrewKushnir AndrewKushnir left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM, but also adding @alxhub to review from the compiler side, to make sure we are not missing any cases.

Comment thread packages/compiler/src/schema/dom_security_schema.ts Outdated
@AndrewKushnir
AndrewKushnir requested a review from alxhub May 12, 2026 18:40

@dgp1130 dgp1130 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

I think I'm only half following the logic here, but it seems generally fine. My only concern is that this seems to be getting more complicated and therefore easier to make mistakes, so I want to make sure we take the time to design these APIs so we're less likely to misuse them on accident.

Comment thread packages/compiler/src/template/pipeline/src/ingest.ts Outdated
const nameToContext = (elName: string) => {
const [nsStr, name] = splitNsName(elName);
const ns = nsStr ?? namespaceKey;
const fullName = ns ? `:${ns}:${name}` : name;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Consider: The constant splitting / joining of the namespace makes me worried we can easily introduce a bug here. Especially with namespace being optional and easily omitted.

Would it be worth moving away from the "stringly" types here and make something like:

interface Tag {
  tagName: string;
  namespace?: string;
}

And then we can use this type in the relevant functions with consistent serialize / deserialize functions to make sure we never drop the namespace and are always checking it as expected?

I have a similar concern with casing, where we might forget a .toLowerCase call, maybe there's a way to standardize that part too?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

We could definitely do that, but that's quite a chunky refactor. Since the elementName as a string is used in a lot of places.

Comment on lines +900 to +904
if (registry.hasElement(svgElement, [])) {
elementNames = [svgElement];
} else if (registry.hasElement(mathElement, [])) {
elementNames = [mathElement];
}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question: Were these intended to be elementNames.push({svg,math}Element)? Why else is elementNames an array?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

This is to keep the existing behaviour, the array is initialized with allKnownElements when the selector has no element.

Comment on lines -297 to -305
'animate': {
':svg:animate': {
'attributename': true,
'to': SECURITY_SENSITIVE_ATTRIBUTE_NAMES,
'values': SECURITY_SENSITIVE_ATTRIBUTE_NAMES,
'from': SECURITY_SENSITIVE_ATTRIBUTE_NAMES,
},
'set': {'attributename': true, 'to': SECURITY_SENSITIVE_ATTRIBUTE_NAMES},
'animatemotion': {'attributename': true},
'animatetransform': {'attributename': true},

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Question: Do we not care about the existing animate attributes? Don't we need to keep these without the :svg: prefix?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, since now the parser prefixes them.

Comment thread packages/compiler/src/schema/dom_security_schema.ts Outdated
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label May 13, 2026

@alxhub alxhub left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Reviewed-for: fw-security

@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label May 18, 2026
…hema contexts

Refactors the element security schema lookups and runtime attribute validation to
consistently account for SVG and MathML namespaces. This improves the modularity
and accuracy of security context mapping during template compilation and runtime
constant evaluation, eliminating redundant or false-positive lifecycle checks.
@alan-agius4
alan-agius4 force-pushed the namespace-html branch 2 times, most recently from f26b773 to ee5a9a8 Compare May 18, 2026 08:22

@josephperrott josephperrott left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM

Reviewed-for: fw-security

@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels May 18, 2026
@leonsenft
leonsenft merged commit cef4a09 into angular:main May 18, 2026
20 checks passed
@leonsenft

Copy link
Copy Markdown
Contributor

This PR was merged into the repository. The changes were merged into the following branches:

@VenkatKwest

Copy link
Copy Markdown

Hi @alan-agius4,

Great to see this refactor get merged! This completely addresses the underlying namespace literal matching and attribute validation gaps we discussed back in Issue #67902 and that I had flagged through the Bug Hunter program.

Since this architectural cleanup solves the exact root cause pipeline from that initial research, I’d appreciate it if my early reporting and analysis on these namespace vectors could be recognized as part of the disclosure and credit path for this security update. Thanks for putting together such a thorough fix!

@alan-agius4
alan-agius4 deleted the namespace-html branch June 3, 2026 08:51
@alan-agius4

Copy link
Copy Markdown
Contributor Author

Hi @VenkatKwest, although this is similar to the issue mentioned above, that specific report did not prove an XSS was possible. We later received distinct reports that clearly demonstrated XSS via different namespaced elements, such as <svg:animate>.

While you were the first to bring this area to our attention, the original report lacked a working XSS proof-of-concept and thus was in-actionable. This isn't to undermine your work, but rather to clarify.

@angular-automatic-lock-bot

Copy link
Copy Markdown

This pull request has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Jul 4, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

action: merge The PR is ready for merge by the caretaker area: core Issues related to the framework runtime target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants