Packages / @angular/platform-server / Security
@angular/platform-server: SSRF via Hostname Hijacking
Affected releases · @angular/platform-server
- 21.x21.0.0 – 21.2.12Fixed in 21.2.13
- 20.x20.0.0 – 20.3.20Fixed in 20.3.21
- 19.x19.0.0 – 19.2.21Fixed in 19.2.22
- 18.x and older2.0.0 – 18.2.14No fix, no longer updated
On 21.x, the newest line:
npm install @angular/platform-server@21.2.13Not affected
22.0.0 – 22.2.3
22 releases, latest
Affected
21.0.0 – 21.2.12
30 releases
Fixed
21.2.13 – 21.2.25
13 releases
Affected
20.0.0 – 20.3.20
42 releases
Fixed
20.3.21 – 20.3.34
14 releases
Affected
19.0.0 – 19.2.21
39 releases
Fixed
19.2.22 – 19.2.25
4 releases
Affected
18.0.0 – 18.2.14
29 releases
Affected
17.0.0 – 17.3.12
32 releases
Affected
16.0.0 – 16.2.12
30 releases
Affected
15.0.0 – 15.2.10
22 releases
Affected
14.0.0 – 14.3.0
26 releases
Affected
13.0.0 – 13.4.0
30 releases
Affected
12.0.0 – 12.2.17
30 releases
Affected
11.0.0 – 11.2.14
28 releases
Affected
10.0.0 – 10.2.5
28 releases
Affected
9.0.0 – 9.1.13
22 releases
Affected
8.0.0 – 8.2.14
23 releases
Affected
7.0.0 – 7.2.16
27 releases
Affected
6.0.0 – 6.1.10
20 releases
Affected
5.0.0 – 5.2.11
22 releases
Affected
4.0.0 – 4.4.7
29 releases
Affected
2.0.0 – 2.4.10
24 releases
Is your project affected?
Paste your package.json, or type the range you declare for @angular/platform-server. It is read in your browser and sent nowhere.
What happens
Impact
A Server-Side Request Forgery (SSRF) vulnerability exists in @angular/platform-server. The issue stems from how the server-side rendering (SSR) engine processes the request URL provided to the rendering entry points.
When an absolute-form URL (e.g., http://evil.com) is passed to the rendering engine, the internal ServerPlatformLocation can be manipulated into adopting the attacker-controlled domain as the "current" hostname.
Consequently, any relative HttpClient requests or PlatformLocation.hostname references are redirected to the attacker controlled server, potentially exposing internal APIs or metadata services.
Fix Information
The vulnerability is mitigated by introducing an Allowlist Mechanism directly into the core rendering APIs. The renderModule and renderApplication functions now include an allowedHosts configuration option. The rendering engine validates the hostname extracted from the request URL against this list before proceeding. If the hostname does not match an allowed entry, the engine prevents the hostname hijacking, ensuring that HttpClient requests remain restricted to trusted domains.
Patches
22.0.0-next.12
21.2.13
20.3.21
19.2.22
Workarounds
Developers unable to update immediately should implement strict URL validation in their server entry point (e.g., server.ts). Ensure that req.url is validated against a known list of trusted hostnames or normalized to a relative path before being passed torenderApplication or renderModule.
// Example manual normalization in Express
app.get('*', (req, res, next) => {
const trustedHost = 'localhost:4000';
// Ensure the request target matches expectations
if (req.headers.host !== trustedHost) {
return res.status(403).send('Forbidden');
}
next();
});