32859 Commits

Author SHA1 Message Date
Pawel Kozlowski 6d1753b46b release: cut the v19.2.25 release v19.2.25 2026-06-02 13:20:10 +02:00
Alan Agius e2fb854d55 fix(platform-server): throw on suspicious URLs and restrict protocol-relative URLs
Backports the security fixes from:

- https://github.com/angular/angular/pull/68973

- https://github.com/angular/angular/pull/69018
2026-06-02 12:21:41 +02:00
Alan Agius a0193fa1bc refactor(platform-server): extract parseUrl regex and add comments for URL parsing behavior
Extracts the regular expression for matching malformed absolute URLs to a module-scoped constant in url.ts.

Additionally, adds comprehensive inline documentation to clarify:
- The path normalization behavior of LEADING_SLASHES_REGEX which collapses consecutive slashes and backslashes.
- The rationale for using 'http://localhost' as the fallback base URL for virtual document initialization in server.ts.
2026-06-02 12:21:41 +02:00
Alan Agius 0a8befb493 fix(platform-server): update domino to latest version
Updates the domino dependency to the latest version as used in the main branch.

This update contains fixes for https://github.com/angular/domino/pull/29.
2026-05-29 14:24:25 +02:00
Pawel Kozlowski a497a3e3b6 release: cut the v19.2.24 release v19.2.24 2026-05-28 16:44:17 +02:00
Alan Agius 6ea6379123 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:54:46 +02:00
Alex Rickabaugh 7801eaac2a release: cut the v19.2.23 release v19.2.23 2026-05-27 15:48:17 -07:00
Matthieu Riegler 3960b21558 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:13:35 -07:00
SkyZeroZx 5619120931 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:02:13 -07:00
SkyZeroZx 97f796203f 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:02:13 -07:00
Matthieu Riegler 62dd27d6af fix(common): add upper bounds for digitsInfo
The prevents the `roundNumber` function from allocating a large array.
2026-05-27 10:32:20 -07:00
Matthieu Riegler 17326725ba fix(common): sanitize placeholder
The placeholder should be sanitized to prevent CSS/content injection.
2026-05-27 10:30:45 -07:00
Alan Agius c75f60ef8a 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:26:12 -07:00
Alan Agius c5b6d735a0 refactor(core): prevent runtime error when root element is null during tag check
This ensures that when rootElement is undefined no error occures.
2026-05-27 10:26:12 -07:00
Alan Agius e8d35f9693 Revert "revert: revert all changes until fdc1b48f32e52da7684583811a6a3090f6418d5e"
This reverts commit 4747fe207d.
2026-05-27 10:26:12 -07:00
Alan Agius 4747fe207d revert: revert all changes until fdc1b48f32
This reverts all changes from fdc1b48f32 to the previous branch tip (d31f84116c) due to repository force-push restrictions.
2026-05-27 10:53:37 +00:00
Alan Agius d31f84116c fix(core): wrap i18n dynamic element property updates in active index states
Ensure that the elementPropertyInternal call in i18n_apply.ts is wrapped within a setSelectedIndex(nodeIndex) try/finally block. This coordinates input/property reflection lookups with the correct element node at runtime, preventing ICU and renderer element dynamic update errors.

Additionally, apply a safe guard to locateHostElement to check for defined targets during dynamic targetless testing contexts, and update the integration payload tracking sizes golden file.
2026-05-27 08:12:57 +00:00
Alan Agius e2caa08ef2 test(core): update core packaging golden symbols to match security schema refactor
Update the golden symbols files for animations-standalone, defer, forms_reactive, forms_template_driven, and hydration tests.

These symbol list updates align with the newly backported security schema refactor, where a generic RESOURCE_MAP was introduced and individual resource tag collections were combined.
2026-05-27 07:58:39 +00:00
Alan Agius 08422de793 refactor(http): export CACHE_OPTIONS to support test suite requirements
Export the CACHE_OPTIONS injection token from transfer_cache.ts to resolve compilation failures in the unit test specs.

On the 19.2.x branch, the CACHE_OPTIONS token was previously a local private constant. However, the newly cherry-picked testing configurations import this token directly, requiring it to be exported.
2026-05-27 07:57:12 +00:00
Alan Agius 7dab3e376c test(core): update router golden symbols to match security schema refactor
Update golden file and schema tests
2026-05-27 07:32:55 +00:00
Yenya030 9940ffd781 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 07:23:09 +00:00
Yenya030 0f67f0b962 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 07:22:42 +00:00
Alan Agius d187e8aeda fix(platform-server): normalize path parsing in ServerPlatformLocation
Normalizes request path parsing in ServerPlatformLocation by collapsing multiple consecutive leading slashes and backslashes (e.g. // or /\) down to a single forward slash. This ensures consistent resolution of relative path segments and prevents unexpected absolute path overrides during URL parsing.
2026-05-27 07:21:57 +00:00
Yenya030 afe690ec07 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 07:21:55 +00:00
Yenya030 37ee9ffd9e 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 07:21:53 +00:00
Alan Agius ce6acbf5c1 test(compiler-cli): align ngtsc sanitization expectations with modern DOM schema
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.
2026-05-27 07:21:48 +00:00
Alan Agius de74480496 test(core): update golden symbols and host bindings sanitization spec
Synchronizes the golden symbols for router bundling and updates the host bindings sanitization integration test to use a[href] instead of blockquote[cite].
2026-05-27 07:21:19 +00:00
Alan Agius c6bb0692e2 fix(core): reject script element as a dynamic component host
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.
2026-05-27 07:21:12 +00:00
Alan Agius 5e399a24da test(core): remove obsolete blockquote cite host binding tests
Removes the obsolete blockquote[cite] sanitization expectations in host_binding_spec.ts.
2026-05-27 07:21:10 +00:00
Alan Agius dc3a544a74 test(core): update spec files to match 20.3.x limits and actual contexts
Updates spec files to replace modern Eager change detection and remove obsolete ins[cite] expectations.
2026-05-27 07:21:09 +00:00
Alan Agius dfeffe6198 test(compiler): remove obsolete schema_extractor import
Removes the unused import of extractSchema in dom_element_schema_registry_spec.ts.
2026-05-27 07:21:07 +00:00
Alan Agius 51714f3753 refactor(core): resolve merge conflicts in sanitization.ts
Resolves missing definitions and JIT compiler errors in sanitization.ts.
2026-05-27 07:21:05 +00:00
Alan Agius 620230dac4 fix(core): synchronize core sanitization schema with compiler
Synchronizes the core's copy of the DOM security schema with the compiler-side schema definitions, and removes the write_source_file target.
2026-05-27 07:21:00 +00:00
Alan Agius 3bfa4ee03b fixup! fix(core): normalize tag names in runtime i18n attribute security context lookup 2026-05-27 07:20:48 +00:00
Alan Agius 7b74351310 fix(core): normalize tag names in runtime i18n attribute security context lookup
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.
2026-05-27 07:20:46 +00:00
Alan Agius 932e0728db fix(compiler): normalize tag names with custom namespaces in DomElementSchemaRegistry
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.
2026-05-27 07:20:44 +00:00
Alan Agius 2e3d0371ab fix(compiler): sanitize dynamic href and xlink:href bindings on SVG a elements
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.
2026-05-27 07:20:42 +00:00
leonsenft bdda6866a8 test(core): remove obsolete SVG script sanitization translation test
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.
2026-05-27 07:20:39 +00:00
Alan Agius fe1207e8c5 fix(compiler): strip namespaced SVG script elements during template compilation
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.
2026-05-27 07:20:37 +00:00
Alan Agius 3632fa4b69 fix(core): support prefix-insensitive DOM schema lookups and compile-time i18n attribute validation
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.
2026-05-27 07:20:34 +00:00
Alan Agius 8a814aed96 refactor(core): align namespaced attribute validation and security schema 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.
2026-05-27 07:19:58 +00:00
Matthew Beck fdc1b48f32 release: cut the v19.2.22 release v19.2.22 2026-05-12 14:46:45 -07:00
Alan Agius 8569db8875 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:30:48 -06:00
Alan Agius 103f0dddc4 build: update dev-infra github actions to 442c2fcbf06a321b5196b4c5fc70e78a49242958 (#68469)
Update dev-infra to latest version for github actions

PR Close #68469
2026-05-07 15:25:14 -07:00
Alan Agius 837a710217 fix(platform-server): ensure origin has a trailing slash when parsing url (#68469)
The origin did not have a trailing slash, which caused parsing issues for relative URLs.

Fixes #68322

PR Close #68469
2026-05-07 15:25:14 -07:00
Alan Agius 83a640516f fix(core): disallow event attribute bindings in host bindings unconditionally (#68469)
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 #68469
2026-05-07 15:25:14 -07:00
Alan Agius 24a0103a98 fix(core): validate security-sensitive attributes in i18n bindings (#68469)
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 #68469
2026-05-07 15:25:14 -07:00
kirjs c3f88e217c release: cut the v19.2.21 release v19.2.21 2026-04-16 01:20:39 +03:00
Alan Agius f3a5bfb949 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:20 +03:00
Joey Perrott 2c51d98dd4 release: cut the v19.2.20 release v19.2.20 2026-03-12 14:42:12 -06:00