Sitelet https://github.com/angular/angular/pull/70363
Skip to content

prevent forged i18n marker injection & refresh namespace for i18n placeholders - #70363

Open
SkyZeroZx wants to merge 2 commits into
angular:mainfrom
SkyZeroZx:fix/i18n-marked
Open

prevent forged i18n marker injection & refresh namespace for i18n placeholders#70363
SkyZeroZx wants to merge 2 commits into
angular:mainfrom
SkyZeroZx:fix/i18n-marked

Conversation

@SkyZeroZx

@SkyZeroZx SkyZeroZx commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

fix(core): prevent forged i18n marker injection

Treat translated text as untrusted instead of allowing it to become compiler-generated i18n structure. Without validation, forged structural and binding markers can target declaration slots or expressions outside the source message and leave runtime metadata inconsistent with the DOM.

Reject reserved delimiters at the translation boundary and validate placeholder structure, node slots, and binding ranges before applying i18n opcodes. Preserve legitimate placeholder reordering, interpolations, and structural directive cases.

fix(core): refresh namespace for i18n placeholders

i18n predeclares TNode placeholders before element instructions select their final namespace. Promoting an SVG placeholder without refreshing this field leaves HTML metadata attached to an SVG DOM element, so SVG-specific binding validation can use the wrong security context.

Refresh the namespace from the current instruction state when adopting a placeholder and cover security-sensitive SMIL href animation bindings.

More context https://issuetracker.google.com/u/1/issues/550667019

What is the new behavior?

Translated literals can no longer contain Angular's reserved U+FFFD runtime marker.

loadTranslations({
  [messageId]: '�#0�Ready�/#0�',
});

The translation is rejected before rendering. Runtime validation also throws NG0700 if a structural marker targets an occupied declaration slot, preventing TNode corruption and the iframe[srcdoc] sanitization bypass.


Nowlements created from i18n placeholders now receive the namespace selected by their element instruction.

@Component({
  template: `
    <section i18n>
      Open profile
      <svg>
        <a>
          <set attributeName="href" [attr.to]="payload"></set>
        </a>
      </svg>
    </section>
  `,
})
class Profile{
   payload = 'javascript:alert("evil")';
}

Angular recognizes <set> as an SVG element, throws NG0910, and does not write the unsafe to attribute.

@angular-robot angular-robot Bot added the area: core Issues related to the framework runtime label Aug 24, 2026
@ngbot ngbot Bot added this to the Backlog milestone Aug 24, 2026
Treat translated text as untrusted instead of allowing it to become compiler-generated i18n structure. Without validation, forged structural and binding markers can target declaration slots or expressions outside the source message and leave runtime metadata inconsistent with the DOM.

Reject reserved delimiters at the translation boundary and validate placeholder structure, node slots, and binding ranges before applying i18n opcodes. Preserve legitimate placeholder reordering, interpolations, and structural directive cases.
i18n predeclares TNode placeholders before element instructions select their final namespace. Promoting an SVG placeholder without refreshing this field leaves HTML metadata attached to an SVG DOM element, so SVG-specific binding validation can use the wrong security context.

Refresh the namespace from the current instruction state when adopting a placeholder and cover security-sensitive SMIL href animation bindings with an acceptance regression.
@SkyZeroZx SkyZeroZx changed the title fix(core): prevent forged i18n marker injection prevent forged i18n marker injection & refresh namespace for i18n placeholders Aug 24, 2026
@SkyZeroZx
SkyZeroZx marked this pull request as ready for review August 24, 2026 05:09
@pullapprove
pullapprove Bot requested a review from kirjs August 24, 2026 05:09
@JeanMeche
JeanMeche requested review from alan-agius4 and removed request for kirjs August 25, 2026 10:37
@pullapprove
pullapprove Bot requested a review from kirjs August 25, 2026 10:37
@alan-agius4
alan-agius4 requested review from alxhub and removed request for alan-agius4 and kirjs August 25, 2026 12:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area: core Issues related to the framework runtime

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant