34848 Commits

Author SHA1 Message Date
Pawel Kozlowski a1eeeb89d4 release: cut the v20.3.23 release v20.3.23 2026-05-28 16:27:26 +02:00
Alan Agius d40acc6431 fix(compiler): prevent namespaced SVG <style> elements from being stripped
Updates the template preparser to exclude namespaced SVG style tags (':svg:style') from the style elements set.

Previously, ':svg:style' elements were incorrectly classified as PreparsedElementType.STYLE, which caused them to be completely stripped from the final template DOM tree during the Render3 template transform and pushed into standard component stylesheets. By limiting the style element parsing to standard 'style' tags, namespaced SVG style tags remain safely in the template AST as normal DOM elements, preserving local SVG styling.

Closes #68977
2026-05-28 15:50:52 +02:00
Alex Rickabaugh db20819ddc release: cut the v20.3.22 release v20.3.22 2026-05-27 15:55:09 -07:00
Matthieu Riegler af04936045 fix(core): sanitize meta selectors
Ensure that property/name are correctly escaped and doesn't break out of the intended selector.
2026-05-27 15:00:26 -07:00
SkyZeroZx e617fa06eb fix(service-worker): Preserves HTTP cache mode in asset group requests
Ensures explicit HTTP cache mode from incoming requests is forwarded and maintained when creating fetch requests for assets, aligning with expected fetch behavior and preventing unintended cache handling.
2026-05-27 11:01:02 -07:00
SkyZeroZx 83b022f2d0 fix(service-worker): Preserves explicit 'credentials: omit' in asset requests
Ensures that explicitly provided `credentials: 'omit'` options are preserved
when creating new requests, preventing unintended credential inclusion.
2026-05-27 11:01:02 -07:00
Matthieu Riegler 3d135ce59b fix(common): add upper bounds for digitsInfo
The prevents the `roundNumber` function from allocating a large array.
2026-05-27 10:33:05 -07:00
Matthieu Riegler 39a4b4cc8e fix(common): sanitize placeholder
The placeholder should be sanitized to prevent CSS/content injection.
2026-05-27 10:29:56 -07:00
Alan Agius 7ae6381a48 test(compiler-cli): align ngtsc sanitization expectations with modern DOM schema (#68926)
Removes the legacy profile property/attribute from the directives hostBindings specs to align with modern DOM security schema changes. Also cleans up minor redundant formatting lines in the compiler and core targets.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius 6595409248 test(core): update golden symbols and host bindings sanitization spec (#68926)
Synchronizes the golden symbols for router bundling and updates the host bindings sanitization integration test to use a[href] instead of blockquote[cite].

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius d86e4e7b2a fix(core): reject script element as a dynamic component host (#68926)
To enhance application security and prevent accidental or malicious script execution, this change ensures that dynamically mounting a component via createComponent directly onto a <script> element throws a runtime error in development mode. SVG <script> elements are also rejected. The error message is designed to be fully tree-shakable under production builds where ngDevMode is disabled.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius b8f1f72765 test(core): remove obsolete blockquote cite host binding tests (#68926)
Removes the obsolete blockquote[cite] sanitization expectations in host_binding_spec.ts.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius 36200bd81a test(core): update spec files to match 20.3.x limits and actual contexts (#68926)
Updates spec files to replace modern Eager change detection and remove obsolete ins[cite] expectations.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius 823b37f046 test(compiler): remove obsolete schema_extractor import (#68926)
Removes the unused import of extractSchema in dom_element_schema_registry_spec.ts.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius 81e70d3ea7 refactor(core): resolve merge conflicts in sanitization.ts (#68926)
Resolves missing definitions and JIT compiler errors in sanitization.ts.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius 909ef047b3 fix(core): synchronize core sanitization schema with compiler (#68926)
Synchronizes the core's copy of the DOM security schema with the compiler-side schema definitions, and removes the write_source_file target.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius e345a58069 fix(core): normalize tag names in runtime i18n attribute security context lookup (#68926)
Normalize namespaced tag names (e.g., :xhtml:a to a) inside i18nResolveSanitizer before looking up their security context. This ensures custom namespaced tag attributes undergo correct translation sanitization at runtime.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius 8f35b182b1 fix(compiler): normalize tag names with custom namespaces in DomElementSchemaRegistry (#68926)
Custom XML/XHTML namespaced elements (e.g., <xhtml:a>) fall back to the standard HTML namespace during element creation at compile-time/runtime. However, their property and security context lookups inside the schema registry were incorrectly performed using the full namespaced tag name (e.g., :xhtml:a), which bypassed the default a|href sanitization registry and incorrectly returned SecurityContext.NONE instead of SecurityContext.URL.

This commit introduces tag name normalization inside DomElementSchemaRegistry for custom namespaces (other than the built-in svg and math namespaces). Custom namespaced tag names are now normalized to their simple HTML element counterparts for all registry queries, ensuring that correct property schema validation and dynamic security sanitization rules (such as URL sanitization) are enforced at runtime.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius 64a89e917a fix(compiler): sanitize dynamic href and xlink:href bindings on SVG a elements (#68926)
Dynamic bindings to `href` and `xlink:href` attributes on SVG `<a>` elements (`<svg:a>`) were previously unmapped in the DOM security schema. As a result, they bypassed sanitization completely, creating a potential XSS vulnerability if bound to untrusted user inputs (e.g., `javascript:` URLs).

This fix mitigates this risk by:

1. Registering `href` and `xlink:href` on `<svg:a>` elements under the `SecurityContext.URL` context in both the compiler and core DOM security schemas.

2. Enabling template compilation to output runtime URL sanitization checks (`ɵɵsanitizeUrl`) on these attributes.

3. Adding regression and verification test cases to ensure dynamic SVG link bindings are safely sanitized at runtime while static values are correctly allowed.

PR Close #68926
2026-05-27 10:28:46 -07:00
leonsenft 09344ea457 test(core): remove obsolete SVG script sanitization translation test (#68926)
Removes the `should throw error on translated SVG script ResourceURL
attributes` integration test from `security_integration_spec.ts`.

This test is now obsolete because SVG `<script>` elements are stripped during
template compilation (implemented in 90494cd909). As a result, they are no
longer present in the compiled template to trigger runtime sanitization,
causing this test (which expected a sanitization error to be thrown) to fail.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius 6404edfe0a fix(compiler): strip namespaced SVG script elements during template compilation (#68926)
Ensures that namespaced <script> elements (such as :svg:script) are correctly classified as PreparsedElementType.SCRIPT by the template preparser and stripped during compilation to prevent potential XSS vulnerabilities. Consequently, obsolete security schema mappings and runtime sanitization checks for <script> attributes have been removed since these elements are never present in compiled template outputs.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius dc631efa96 fix(core): support prefix-insensitive DOM schema lookups and compile-time i18n attribute validation (#68926)
Updates `DomElementSchemaRegistry` to strip `:svg:` and `:math:` namespace prefixes
from tag names before querying `SECURITY_SCHEMA` at compile-time. This allows SVG
and MathML attributes to correctly match their security contexts during compilation.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius 3b66843ed2 refactor(core): align namespaced attribute validation and security schema contexts (#68926)
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.

PR Close #68926
2026-05-27 10:28:46 -07:00
Alan Agius 49a60f6045 fix(platform-server): secure location and document initialization against SSRF and path hijack
Normalizes the URL and path parsing logic inside platform-server by consolidating security checks and normalizations into a single, unified parseUrl helper function.

This includes:
- Collapsing multiple consecutive leading slashes and backslashes (e.g., // or /\) to a single forward slash to avoid protocol-relative parsing of path-like & relative inputs.
- Rejecting malformed absolute URLs that are otherwise accepted by lenient DOM parsers like Domino but rejected by standard WHATWG parsers, preventing SSRF / allowedHosts validation bypasses.
- Ensuring parseDocument gets the fully parsed and normalized URL instead of raw, unvalidated configuration values, preventing virtual document hostname adoption/origin hijack.
- Moving parseUrl unit tests into a dedicated url_spec.ts test file to keep platform_location_spec.ts clean and decoupled.
2026-05-27 10:27:30 -07:00
Yenya030 de7b2a62e7 fix(http): exclude withCredentials requests from transfer cache
Update the transfer cache check to safely exclude all requests sent with the `withCredentials` flag.

By default, the HTTP transfer cache avoids caching user-specific responses to prevent sensitive data exposure or incorrect caching. While requests with explicit headers like `Cookie` or `Authorization` are excluded by default, requests can also be sent with credentials via the `withCredentials` flag without having those headers explicitly declared on the request object.

To keep user-specific responses from being cached, exclude `withCredentials` requests unconditionally, even when the `includeRequestsWithAuthHeaders` option is set to true.
2026-05-27 10:25:28 -07:00
Yenya030 4233188d8e fix(http): skip TransferCache for cookie-bearing requests by default
Treat requests with a Cookie header like other auth-bearing requests and skip TransferCache caching them by default.

This preserves the explicit opt-in path via includeRequestsWithAuthHeaders, adds regression coverage for cookie-bearing requests, and updates the SSR guide to document the behavior.
2026-05-27 10:25:28 -07:00
Yenya030 9b5f8c20b5 refactor(service-worker): remove unnecessary cast in mock redirect check
Use the typed Response.redirected property directly in the service-worker test mock instead of casting to any.
2026-05-27 10:24:51 -07:00
Yenya030 5fdfd8a998 fix(service-worker): preserve redirect policy on reconstructed asset requests
Preserve the redirect mode when rebuilding asset requests in newRequestWithMetadata(). This keeps explicit redirect:error semantics intact across service-worker redirect handling.

Update the worker test mocks to model redirect defaults correctly and add focused regression coverage for redirected lazy assets with redirect:error.
2026-05-27 10:24:51 -07:00
Matthew Beck 591fa53bd2 release: cut the v20.3.21 release v20.3.21 2026-05-12 10:11:35 -07:00
Alan Agius f584840e2e fix(platform-server): add allowedHosts option to renderModule and renderApplication
In server-side rendering (SSR) setups, passing request URLs directly to the lower-level rendering APIs `renderModule` or `renderApplication` can expose applications to Server-Side Request Forgery (SSRF) or Host Header Injection attacks via absolute-form request URLs.
To mitigate these vulnerabilities at the framework layer, this commit introduces the `allowedHosts` option to `PlatformConfig` (supporting exact hostnames, wildcards like `*.example.com`, or `*` to allow all).

During platform initialization inside `createServerPlatform`, the hostname of the request `url` is validated against the `allowedHosts` list. If the hostname is not authorized, bootstrap immediately throws a host validation error, preventing unauthorized rendering and silent SSRF bypasses.

Closes #68436
2026-05-07 16:22:46 -06:00
Alex Rickabaugh 4aee7440a0 release: cut the v20.3.20 release v20.3.20 2026-05-06 15:08:37 -07:00
Alan Agius 25e4e07238 fix(platform-server): ensure origin has a trailing slash when parsing url (#68468)
The origin did not have a trailing slash, which caused parsing issues for relative URLs.

Fixes #68322

PR Close #68468
2026-05-06 14:43:10 -07:00
Alan Agius a9bcffdbc7 fix(core): disallow event attribute bindings in host bindings unconditionally (#68468)
Moves the event attribute validation check outside of `ngDevMode` in the `elementAttributeInternal` instruction to ensure that bindings to event attributes like `on*` are always blocked at runtime.

Previously, this check was only performed when `ngDevMode` was `true`, which could allow attacker-controlled CMS data to be bound to event attributes in production mode, causing browser-executed XSS.

Fixes #68419

PR Close #68468
2026-05-06 14:43:10 -07:00
Alan Agius 97eeb45cfa fix(core): validate security-sensitive attributes in i18n bindings (#68468)
Ensures that security-sensitive attributes (e.g., sandbox, allow) are correctly validated when applied through i18n-* dynamic attribute bindings, preventing potential policy bypasses.

Closes #68418

PR Close #68468
2026-05-06 14:43:09 -07:00
kirjs b9ec542153 release: cut the v20.3.19 release v20.3.19 2026-04-16 01:08:27 +03:00
Alan Agius 303d4cd580 fix(platform-server): prevent SSRF bypasses via protocol-relative and backslash URLs
The `parseUrl` function in `ServerPlatformLocation` uses `new URL(urlStr, origin)` to parse incoming request URLs during SSR. Per the WHATWG URL specification, protocol-relative URLs (`//evil.com`) and backslash-prefixed URLs (`/\evil.com`) can override the hostname component of the base URL.

This vulnerability typically manifests in SSR setups (e.g., Express) where `req.url` is passed directly to `renderApplication` or `renderModule`:

```typescript
// Example usage in an Express server handling: http://localhost:4000//evil.com
app.get('*', async (req, res) => {
  const html = await renderApplication(bootstrap, {
    document: template,
    url: req.url, // req.url is "//evil.com"
  });
  res.send(html);
});
```
2026-04-15 19:41:53 +03:00
Matthew Beck cef3164f97 release: cut the v20.3.18 release v20.3.18 2026-03-12 13:22:39 -06:00
Kristiyan Kostadinov 02fbf08890 fix(compiler): disallow translations of iframe src
Fixes that the compiler was allowing translations of `src` attributes in iframes which can be a security issue.
2026-03-12 12:30:55 -06:00
Kristiyan Kostadinov 626bc8bc20 fix(core): sanitize translated form attributes
Fixes that we weren't sanitizing the `form` and `formaction` attributes when they're used together with translations.
2026-03-12 12:30:55 -06:00
Kristiyan Kostadinov 72126f9a08 fix(core): sanitize translated attribute bindings with interpolations
Fixes that we weren't sanitizing attribute bindings with interpolations if they're marked for translation, for example: `<a href="{{evilLink}}" i18n-href></a>`.

Also adds a bit more test coverage for our sanitization.
2026-03-12 12:30:55 -06:00
Jessica Janiuk 043125cc56 release: cut the v20.3.17 release v20.3.17 2026-02-25 12:05:55 -08:00
Doug Parker 7f9de3c118 fix(core): block creation of sensitive URI attributes from ICU messages
Translators are not allowed to write HTML which creates URI attributes. I opted to ban any values going into an attribute at all, to prevent even links to malicious content, rather than just sanitizing URIs.

I also converted this blocklist into an allowlist. Now, we only allowing setting known attributes (while sanitizing URI attributes). This significantly reduces risk of missing a vulnerable attribute and does not require an exhaustive list of all potential attributes.

BREAKING CHANGE: Angular now only applies known attributes from HTML in translated ICU content. Unknown attributes are dropped and not rendered.

(cherry picked from commit 03da204b6d)
2026-02-25 08:22:14 -08:00
kirjs f76d891b8b release: cut the v20.3.16 release v20.3.16 2026-01-07 17:18:31 -05:00
Alan Agius c2c2b4aaa8 fix(core): sanitize sensitive attributes on SVG script elements
This commit updates the DOM security schema and sanitization logic to properly recognize and sanitize `href` and `xlink:href` attributes on SVG `<script>` elements.
2026-01-06 15:54:47 -05:00
Kristiyan Kostadinov 4755bbd949 release: cut the v20.3.15 release 20.3.15 2025-12-01 12:46:42 +01:00
Alan Agius d1ca8ae043 fix(compiler): prevent XSS via SVG animation attributeName and MathML/SVG URLs
This commit implements a security fix to prevent XSS vulnerabilities where SVG animation elements (`<animate>`, `<set>`, etc.) could be used to modify the `href` or `xlink:href` attributes of other elements to `javascript:` URLs.

The fix introduces a runtime validation step:
- A new [ɵɵValidateAttribute](cci:1://file:///usr/local/google/home/alanagius/git/angular/packages/core/src/sanitization/sanitization.ts:276:0-288:1) instruction is used when `attributeName` is bound on SVG animation elements.
- If executed, a `RuntimeError` is thrown, preventing the binding.
- The compiler now identifies `attributeName` on SVG animation elements as security-sensitive and injects this validation.

Additionally, the DOM security schema has been updated to include a comprehensive list of MathML and SVG elements that accept `href` or `xlink:href` attributes, ensuring they are correctly treated as `SecurityContext.URL` and sanitized. This prevents malicious URLs from being bound to these attributes.

http://b/463880509
2025-12-01 10:29:30 +01:00
kirjs 136e9232c4 release: cut the v20.3.14 release 20.3.14 2025-11-25 15:14:26 -05:00
Alan Agius 0276479e7d fix(http): prevent XSRF token leakage to protocol-relative URLs
The XSRF interceptor previously failed to detect protocol-relative URLs (starting with `//`) as absolute URLs. This allowed requests to such URLs to include the XSRF token, potentially leaking it to external domains.

This change updates the interceptor to correctly identify protocol-relative URLs as absolute and exclude them from receiving the XSRF token.
2025-11-25 13:54:57 -05:00
Jessica Janiuk edcbe2259b release: cut the v20.3.13 release 20.3.13 2025-11-19 09:41:29 -08:00
kirjs 24c999a56e fix(docs-infra): add moduleResolution to TypeScript compiler options for playground
This fixes signal forms, but idk if it breas other things

(cherry picked from commit 040af1aaa1)
2025-11-19 16:26:23 +00:00