Skip to content

Commit 8cb57fb

Browse files
committed
fix(@angular/ssr): avoid caching non-SSG page lookups
Only cache CommonEngine SSG lookup results after the target file is confirmed to be a prerendered SSG page. Missing pages and static files without the SSG marker can be derived from request URLs, so retaining those negative results allows attacker-controlled paths to grow the process cache without bound.
1 parent 5875b60 commit 8cb57fb

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/angular/ssr/node/src/common-engine/common-engine.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,15 +167,15 @@ export class CommonEngine {
167167

168168
if (pagePath === resolve(documentFilePath) || !(await exists(pagePath))) {
169169
// View matches with prerender path or file does not exist.
170-
this.pageIsSSG.set(pagePath, false);
171-
172170
return undefined;
173171
}
174172

175173
// Static file exists.
176174
const content = await fs.promises.readFile(pagePath, 'utf-8');
177175
const isSSG = SSG_MARKER_REGEXP.test(content);
178-
this.pageIsSSG.set(pagePath, isSSG);
176+
if (isSSG) {
177+
this.pageIsSSG.set(pagePath, true);
178+
}
179179

180180
return isSSG ? content : undefined;
181181
}

0 commit comments

Comments
 (0)