14172 Commits

Author SHA1 Message Date
Alan Agius 3db26e2544 fix(platform-server): update domino to latest version
Updates the domino dependency to the latest version as used in the main branch.
2026-09-09 16:29:06 +02:00
Alan Agius 9339a7a2de fix(platform-server): avoid stripping unicode whitespace during url resolution
Avoid trimming urlStr with String.prototype.trim() in parseUrl to ensure URL parsing and resolution align with the WHATWG URL standard.
2026-08-25 10:00:53 -07:00
Alan Agius 89b20568df fix(platform-server): update domino to latest version
Updates the domino dependency to the latest version as used in the main branch.
2026-08-24 10:41:57 -07:00
SkyZeroZx 7538744c10 fix(platform-browser): disallow event handler attributes in Meta
Prevent arbitrary MetaDefinition properties from writing on* handlers directly to meta elements. Browser events can execute these handlers, including on meta elements rendered in the document body.

Reject handler attributes case-insensitively before matching or mutating tags.

Fixes #70126
2026-08-17 13:43:29 -07:00
Jaime Burgos e4c416c20a fix(http): run root interceptors in the terminal request chain
Represent withRequestsMadeViaParent() with an internal delegating backend so the interceptor handler can distinguish delegated clients from independent child configurations.
2026-07-31 15:12:52 -07:00
SkyZeroZx 969133d426 fix(http): match header values exactly when deleting
Normalize value-specific HttpHeaders deletions before filtering. The string overload previously used String#indexOf and removed shorter values contained within the requested deletion value, potentially widening outgoing request metadata.

Preserve delete-all behavior only when no value is supplied, and cover string, array, and empty-string deletion.
2026-07-31 15:12:52 -07:00
SkyZeroZx 29dd26bd71 fix(http): preserve immutability of materialized clones
Prevent lazy HttpHeaders and HttpParams clones from reusing value arrays owned by a materialized source. Append and value-specific delete operations previously mutated those shared arrays, violating the immutable API contract and allowing request metadata to bleed into later requests.

Share value arrays until an update mutates a specific header or parameter, then copy only that array. Cover the affected append and delete paths with regression tests that materialize the source first.
2026-07-31 15:12:52 -07:00
Jaime Burgos 2f96c8020f fix(core): sanitize host bindings on concrete hosts
Compute host binding security contexts against concrete hosts, including host directives, inheritance, dynamic directives, and createComponent hostElement usage.
2026-07-30 08:42:54 -07:00
Alan Agius db0d4a1a39 fix(compiler): restrict possible event handler check to property names longer than 2 characters
Previously, the compiler disallowed translation of any attribute starting with 'on' for security reasons. This incorrectly disallowed translation of the 'on' attribute itself, which is not an event handler.

This commit introduces `isPossibleEventHandler` to verify that the property name has a length greater than 2 in addition to starting with 'on'. This allows attributes like 'on' to be translated while still correctly disallowing actual event handlers like 'onerror', 'onclick', etc.
2026-07-29 08:51:21 -07:00
Hexix23 a64e2883e9 fix(http): distinguish repeated transfer cache params
Serialize transfer cache request parameters without comma-joining repeated values so distinct HttpClient requests cannot reuse the same cached response.
2026-07-29 08:51:21 -07:00
Hexix23 5dbcd0ee16 fix(compiler): disallow i18n event attributes
Reject translated event-handler attributes so localization cannot bypass Angular event-attribute validation.
2026-07-29 08:51:21 -07:00
SkyZeroZx 6f80cca0b8 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/32.
2026-07-29 08:44:16 -07:00
SkyZeroZx baa093ba68 fix(service-worker): preserve referrer policy in asset requests
Preserve explicit referrer policy when the service worker reconstructs asset requests for cache-busted and redirected asset fetches.

For example, an application can load a script or image with referrerPolicy: 'same-origin' or 'origin' to limit referrer data. Dropping that policy can expose more of the current URL to that resource host.

(cherry picked from commit a7f52e5c30)
2026-07-08 11:15:15 -07:00
SkyZeroZx 1fdf234168 fix(service-worker): preserve referrer in asset requests
Preserve referrer metadata when the service worker reconstructs asset requests for cache-busted and redirected asset fetches.

For example, an attacker with access to asset host logs could receive a reset token embedded in a page URL if the reconstructed request falls back to default referrer behavior instead of carrying referrer: ''.

(cherry picked from commit 99ad47e58f)
2026-07-08 11:15:15 -07:00
SkyZeroZx b963f61028 fix(http): prevent caching of responses with Set-Cookie headers
Skip HttpTransferCache serialization for HTTP responses that contain a
Set-Cookie header.

Cookie-setting responses commonly represent session-specific,
user-specific, or security-sensitive state. Serializing their bodies into
SSR TransferState can embed sensitive data into the generated HTML, where
it may be reused during hydration or replayed by a shared cache/CDN.

(cherry picked from commit 80795defc6)
2026-07-07 10:12:06 -07:00
Alan Agius 406aaa31e6 fix(compiler-cli): update babel dependencies to latest v7
Update babel dependencies to v7.29.7 to address CVE-2026-49356.

Fixes #69608
2026-07-06 13:38:02 -07:00
SkyZeroZx 8eb7aea08b fix(core): reject dynamic script host elements
The previous fix for GHSA-692r-grfm-v8x7 was incomplete because it rejected script tags only when locating an explicit host element. Dynamic component instantiation can also infer the host element from the component selector.

Move the script-host rejection to the point where ComponentFactory has resolved the host element for either path, so createComponent rejects script hosts consistently.

(cherry picked from commit 135f3755b4)
2026-06-30 17:42:07 -07:00
SkyZeroZx 26831d0cbd fix(core): avoid caching missing locale data
Only cache locale data loaded from the global locale registry when an actual locale entry is found.

This prevents attacker-controlled missing locale identifiers from being retained indefinitely in SSR when locale lookup falls back to a parent locale or the built-in English locale, avoiding unbounded process memory growth in locale-aware pipes and formatters.

(cherry picked from commit ea8277ae37)
2026-06-24 14:36:24 -04:00
Jaime Burgos ca48b4728d fix(core): validate lowercase SVG animation attribute names (#69270)
Normalize SVG animation attributeName lookup to also recognize lowercase attributename before allowing dynamic animation value bindings.

Add runtime and platform-server SSR regression coverage for lowercase attributename retargeting.

(cherry picked from commit d5e689af80)
2026-06-10 09:51:20 -07:00
Alan Agius d55c94ad81 refactor(platform-server): deprecate ServerXhr (#69256)
XHR support in `@angular/platform-server` is deprecated because the underlying `xhr2` library does not safely handle redirects. Specifically, it can forward `Authorization` headers on cross-origin redirects (which leaks credentials) and is susceptible to denial-of-service (DoS) via redirect loops.

DEPRECATED: XHR support in `@angular/platform-server` is deprecated. Use standard `fetch` APIs instead.
2026-06-09 10:07:02 -07:00
SkyZeroZx 06be298267 fix(http): preserve empty referrer option in HttpRequest
Preserve referrer: '' when constructing and cloning HttpRequest.

An empty string is a valid Fetch referrer value and is documented by

Angular as the way to omit referrer information for sensitive requests.

The previous truthy checks treated it as if the option was not provided,

causing requests to fall back to the browser default referrer behavior.

(cherry picked from commit 1e54b8f5ec)
2026-06-08 15:41:49 -07:00
SkyZeroZx 9f443bc24c fix(common): Limits date format string length
Introduces a maximum length of 256 characters for date format strings.

This prevents potential Denial of Service (DoS) attacks by throwing an
`INVALID_DATE_FORMAT` error if an excessively long format string is
provided to `formatDate` or `DatePipe`, safeguarding against performance
degradation or application crashes.

(cherry picked from commit 35de6b368c)
2026-06-08 14:52:22 -07:00
SkyZeroZx fa940e1f4d fix(http): Rejects non-HTTP(S) URLs in JSONP requests
Prevents JSONP requests from using URLs with unsupported protocols
for improved security.

Fixes  angular#68832
2026-06-08 13:39:22 -07:00
SkyZeroZx d65a5f457b fix(service-worker): Strips sensitive headers on cross-origin redirects
Removes `Authorization`, `Cookie`, and `Proxy-Authorization` headers when a request is redirected to a different origin. This aligns with the Fetch API's redirect algorithm to prevent sensitive information from being sent to third-party origins.

(cherry picked from commit 423a109404)
2026-06-08 13:13:33 -07:00
Alan Agius 1a62130a6b fix(common): use cryptographically secure SHA-256 for transfer cache key generation
Replace the custom 64-bit non-cryptographic combined DJB2 hashing implementation in HttpTransferCache with a robust, pure JavaScript, synchronous SHA-256 algorithm.

Using DJB2 is vulnerable to pre-image and second-preimage attacks due to its small 64-bit keyspace and mathematical simplicity. An attacker could craft colliding request inputs to poison the cache, potentially causing a CDN or the application to serve the wrong cached response to legitimate users.

SHA-256 provides strong cryptographic collision resistance, preventing cache key collision attacks. A custom synchronous implementation is required because the Web Crypto API (`crypto.subtle.digest`) is asynchronous, whereas the transfer cache state lookup and interceptor flow must operate synchronously.

Also, update the unit tests to dynamically verify the custom SHA-256 output against the native Web Crypto API.
2026-06-05 10:38:42 -07:00
Alan Agius 49368c1859 fix(platform-server): harden platform location origin validation during SSR
Align ServerPlatformLocation state modification behavior (replaceState and pushState) with the browser's HTML5 History API by enforcing same-origin validation.

In a browser environment, calling replaceState/pushState with a cross-origin URL throws a SecurityError. Previously, the emulated ServerPlatformLocation in platform-server silently allowed cross-origin state changes. If application code passed untrusted input to replaceState/pushState during SSR, this could cause the base URL to be changed, resulting in potential SSRF and credential leaks for relative HTTP requests.

To mitigate this:
1. Add an `allowOriginChange` option to `ParseUrlOptions`. If false, `parseUrl` validates that the resolved URL's origin matches the base URL's origin.
2. Update `ServerPlatformLocation.replaceState` to call `parseUrl` with `allowOriginChange: false`.
2026-06-05 10:17:42 -07:00
Alan Agius fc7ea0b736 refactor(platform-server): replace standard Error with RuntimeError
Update platform-server to use Angular 's native `RuntimeError` class.
This aligns error throwing patterns in platform-server with other packages of the framework such as core, common, and platform-browser.

For URL and host errors, the error messages are configured to return only the raw dynamic URL when `ngDevMode` is false (in production) to aid in troubleshooting without bloating production bundles.
2026-06-05 10:17:42 -07:00
SkyZeroZx a68ec702a0 fix(compiler): sanitize two-way properties
Apply schema-derived sanitizer resolution to TwoWayProperty ops so native two-way DOM bindings emit the same sanitizer as one-way property bindings.

Add compiler compliance coverage for innerHTML, srcdoc, URL, resource URL, and security-sensitive attribute cases.

(cherry picked from commit 9ca51ab0e4)
2026-06-04 11:19:51 -07:00
SkyZeroZx 566ad05f20 fix(common): skip transfer cache for uncacheable HTTP traffic
Do not store HTTP transfer cache entries when either the request or response uses `Cache-Control: no-store`, `Cache-Control: private`, or `Cache-Control: no-cache`.

Also skip transfer cache when requests use the Fetch API `cache` option with `no-store` or `no-cache`.

Because transfer cache serializes SSR HTTP responses into the rendered HTML, Angular now treats these directives conservatively to avoid exposing sensitive or explicitly uncacheable data through `TransferState`.

(cherry picked from commit 4d150156ca)

(cherry picked from commit 64ce11fcd4)
2026-06-03 11:00:26 -07:00
SkyZeroZx e2ef1ce72a fix(http): skip transfer cache for fetch credentialed requests
Treat HttpClient requests using `credentials: 'include'` and `same-origin` as credentialed when deciding whether a response can be stored in the HTTP transfer cache.

The transfer cache already skips requests with `withCredentials`, `Cookie`, `Authorization`, or `Proxy-Authorization` because those responses may contain user-specific data. Fetch-backed requests can express the same credentialed behavior through the `credentials` option, so these responses must not be serialized into the SSR HTML.

This keeps credentialed SSR responses out of TransferState and aligns the cache eligibility check with the fetch request options supported by HttpClient.

(cherry picked from commit 8ec01970d2)
2026-06-03 11:00:26 -07:00
Matthieu Riegler 768a349e6e fix(core): harden TransferState restoration against DOM clobbering
Reject non-script elements when reading the SSR transfer state payload by id.
This prevents attacker-controlled elements with a clobbered id from spoofing
hydration state.
2026-06-02 14:18:13 +02:00
Alan Agius 6ca433e56b 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-01 20:42:01 +02:00
Alan Agius c99d9f07a1 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-01 20:42:01 +02:00
Alan Agius 8680b5152f 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:20:46 +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
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