@angular/ssr
Affected
- introduced
22.0.0-next.0, fixed22.0.0-next.7(semver)
Fixed versions
22.0.0-next.7
Fix
- Fixed version
22.0.0-next.7npm install @angular/[email protected]
Advisory
Also known as: CVE-2026-44437
Angular SSR has Open Redirect and Request Steering via Encoded X-Forwarded-Prefix
Description
A vulnerability exists in the X-Forwarded-Prefix header processing logic within Angular SSR. The internal validation mechanism fails to properly account for URL-encoded characters, specifically dots (%2e%2e). This allows an attacker to bypass security filters by injecting encoded path traversal sequences that are later decoded and utilized by the application logic.
When an Angular SSR application is configured to trust proxy headers and is deployed behind a proxy that forwards the X-Forwarded-Prefix header without prior sanitization, an attacker can provide a payload such as /%2e%2e/evil.
The vulnerability manifests in two ways:
redirectTo). The decoded traversal payload manipulates the Location header, forcing the browser to an unintended path or external domain.HttpClient requests. This causes the server to make requests to unintended internal paths or external endpoints.Attack Preconditions
HttpClient requests.X-Forwarded-Prefix header to the SSR process without stripping or sanitizing it.Workarounds
Until the patch is applied, developers should manually sanitize the X-Forwarded-Prefix header in their server.ts. The workaround involves decoding the component to catch encoded traversal attempts before normalization:
app.use((req, res, next) => {
let prefix = req.headers['x-forwarded-prefix'];
if (Array.isArray(prefix)) prefix = prefix[0];
if (prefix) {
try {
// Decode the prefix to catch encoded characters like %2e (dots)
const decodedPrefix = decodeURIComponent(prefix);
// Sanitize: remove traversal attempts and ensure a safe leading slash
req.headers['x-forwarded-prefix'] = decodedPrefix
.replace(/\.\./g, '') // Remove any dot-dot sequences
.replace(/^[/\\]+/, '/'); // Ensure it starts with exactly one slash
} catch (e) {
// If decoding fails, remove the potentially malicious header entirely
delete req.headers['x-forwarded-prefix'];
}
}
next();
});
Configuring Trusted Proxy Headers
By default, Angular ignores all X-Forwarded-* headers. If your application is behind a trusted reverse proxy (like a load balancer) that sets these headers, you can configure Angular to trust them.
You can configure trustProxyHeaders when initializing the application engine:
const appEngine = new AngularAppEngine({
// Trust specific headers
trustProxyHeaders: ['x-forwarded-host', 'x-forwarded-proto', 'x-forwarded-prefix'],
});
const nodeAppEngine = new AngularNodeAppEngine({
// Trust all X-Forwarded-* headers
trustProxyHeaders: true,
});
Patches
Resources
Medium Basis: The source's own band: MODERATE
22.0.0-next.0, fixed 22.0.0-next.7 (semver)22.0.0-next.7
22.0.0-next.7npm install @angular/[email protected]21.0.0-next.0, fixed 21.2.9 (semver)21.2.9
21.2.9npm install @angular/[email protected]20.0.0-next.0, fixed 20.3.25 (semver)20.3.25
20.3.25npm install @angular/[email protected]19.0.0-next.0, fixed 19.2.25 (semver)19.2.25
19.2.25npm install @angular/[email protected]Fix commands are the export's own generic commands. Ojuju never runs them. Check them against your setup first.
Check your own computer: guard packages check
Source: GitHub Advisory Database (reviewed advisories) · CC BY 4.0