Summary
Angular SSR: Path Traversal to Sibling Directories in CommonEngine on Windows
A Path Traversal vulnerability exists in the prerendered (SSG) page retrieval logic of CommonEngine in @angular/ssr/node (and @angular/ssr in earlier versions). When deployed on Windows, an attacker can craft a request path with backslash directory traversal sequences that causes CommonEngine to serve prerendered pages from sibling output directories.
The vulnerability occurs due to how relative URLs and Windows file paths are resolved and validated:
- A request URL containing a backslash parent traversal segment (e.g.,
/..\app-admin) is passed toCommonEngine.render({ url }). - The engine parses the URL using
new URL(url, 'resolve://'). Becauseresolve://is a non-special scheme under the WHATWG URL standard, backslashes are not normalized to forward slashes, leaving thepathnameunnormalized as/..\app-admin. - The engine constructs the candidate file path using
join(publicPath, pathname, 'index.html'). On Windows,path.jointreats\as a path delimiter, resolving the parent segment (..\) out ofpublicPath(e.g.,dist\app) into a sibling directory (e.g.,dist\app-admin\index.html). - The containment check (
pagePath.startsWith(normalize(publicPath))) performs a prefix match without a trailing path delimiter. Because the sibling folder name starts with the configured public folder name (e.g.,dist\app-adminstarts withdist\app), the check erroneously succeeds. - If the target file exists and contains the Angular SSG marker (
ng-server-context="...ssg..."),CommonEnginereads and serves the sibling page instead of rendering the requested route.
Attack Preconditions
- The application must use
CommonEnginefrom@angular/ssr/node(or@angular/ssrin v17–v18). - The application must be hosted on Windows (where Node's
path.joinresolves\as a path separator). - The application passes a relative request URL (such as
req.urlorreq.originalUrlwithout origin) intoCommonEngine.render({ url }). - A sibling directory exists whose name starts with the same prefix as the configured
publicPathdirectory (e.g.,dist\app-adminalongsidedist\app). - The targeted sibling directory contains prerendered HTML output containing the Angular SSG marker.
Affected Versions
>= 22.0.0, < 22.1.7>= 21.0.0, < 21.2.23>= 20.0.0, < 20.3.36<= 19.2.27
Workarounds
Until a patch is applied, developers using CommonEngine on Windows can sanitize request URLs in server.ts before passing them to CommonEngine.render, ensuring backslashes are replaced or that an absolute HTTP URL is constructed:
server.use((req, res, next) => {
const { protocol, originalUrl, headers } = req;
// Normalize backslashes or construct a full HTTP URL (which forces WHATWG URL normalization)
const sanitizedUrl = `${protocol}://${headers.host}${originalUrl.replace(/\\/g, '/')}`;
commonEngine
.render({
bootstrap,
documentFilePath: indexHtml,
url: sanitizedUrl,
publicPath: distFolder,
})
.then((html) => res.send(html))
.catch((err) => next(err));
});
Alternatively, migrate from the deprecated CommonEngine to AngularNodeAppEngine, which relies on manifest-based route matching rather than direct filesystem path resolution.
Impact
This vulnerability allows unauthorized access to prerendered static pages from adjacent applications or build outputs:
- Information Disclosure: Prerendered HTML pages located in sibling directories sharing the same name prefix as the public directory (e.g., an internal administration app
app-adminadjacent toapp) can be accessed by unauthorized users. - Limited Scope: Only HTML files matching the Angular SSG marker regex are served. Arbitrary non-Angular files, secrets, or configuration files without the SSG context attribute cannot be read through this mechanism.
Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files. Typical impact: unauthorized file read or write outside the intended directory.
Affected versions
Security releases
Kodem intelligence
Severity tells you how bad this could be in the worst case. It does not tell you whether you are exposed. Exploitability and impact are functions of runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A vulnerable package can sit in your dependency tree and never run.
Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter. Kodem's runtime-powered SCA identifies whether this CVE is reachable in your applications.
Already deployed Kodem?
See it in your environmentNew to Kodem? Get a demo →Remediation advice
22.1.721.2.2320.3.36
Versions <= 19.2.27 have reached End of Support / LTS expiration and will not be patched.
Frequently Asked Questions
- What is CVE-2026-104871? CVE-2026-104871 is a medium-severity path traversal vulnerability in @angular/ssr (npm), affecting versions >= 22.0.0, < 22.1.7. It is fixed in 22.1.7, 21.2.23, 20.3.36. Input manipulates file paths to reach files outside the intended directory, such as configuration or credential files.
- Which versions of @angular/ssr are affected by CVE-2026-104871? @angular/ssr (npm) versions >= 22.0.0, < 22.1.7 is affected.
- Is there a fix for CVE-2026-104871? Yes. CVE-2026-104871 is fixed in 22.1.7, 21.2.23, 20.3.36. Upgrade to this version or later.
- Is CVE-2026-104871 exploitable, and should I be worried? Whether CVE-2026-104871 is exploitable in your environment depends on whether the vulnerable code is present and reachable. A CVSS score is a worst-case rating; it does not account for your specific deployment, configuration, or usage patterns. Kodem, an Intelligent Application Security platform, uses runtime intelligence to show which vulnerabilities actually execute in production, so you can focus on the ones that represent real risk. Get a demo
- What actually determines whether CVE-2026-104871 is exploitable, and how bad it is? Exploitability and impact are not fixed properties of a CVE. They depend on runtime truth: whether the vulnerable code is present, reachable, and actually executes in your application. A high CVSS score on a dependency that never runs is not the same as real risk. Kodem, an Intelligent Application Security platform, uses runtime intelligence to reveal which vulnerabilities actually execute in production, so teams prioritize the ones that genuinely matter.
- How do I fix CVE-2026-104871?
- Upgrade
@angular/ssrto 22.1.7 or later - Upgrade
@angular/ssrto 21.2.23 or later - Upgrade
@angular/ssrto 20.3.36 or later
- Upgrade