Skip to content

fix(@angular/ssr): avoid caching non-SSG page lookups#33365

Open
SkyZeroZx wants to merge 2 commits into
angular:mainfrom
SkyZeroZx:fix/common-DoS
Open

fix(@angular/ssr): avoid caching non-SSG page lookups#33365
SkyZeroZx wants to merge 2 commits into
angular:mainfrom
SkyZeroZx:fix/common-DoS

Conversation

@SkyZeroZx

@SkyZeroZx SkyZeroZx commented Jun 11, 2026

Copy link
Copy Markdown
Contributor

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. Over time, this can lead to unbounded memory growth and a denial of service.

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.

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request modifies the CommonEngine class in Angular SSR to optimize how SSG pages are tracked. It removes the logic that explicitly sets pageIsSSG to false when a file does not exist or matches the prerender path, and ensures that pageIsSSG is only set to true when the SSG marker is found in the static file. There are no review comments to evaluate, and I have no further feedback to provide.

const isSSG = SSG_MARKER_REGEXP.test(content);
this.pageIsSSG.set(pagePath, isSSG);
if (isSSG) {
this.pageIsSSG.set(pagePath, true);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As I understand, I don't see any use for it when is false. Additionally, I'm not sure if we would need a test, although I can't think of a way to perform one at the moment.

this.pageIsSSG.set(pagePath, true);
}

return isSSG ? content : undefined;

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NIT:

Suggested change
return isSSG ? content : undefined;
return undefined;

const isSSG = SSG_MARKER_REGEXP.test(content);
this.pageIsSSG.set(pagePath, isSSG);
if (isSSG) {
this.pageIsSSG.set(pagePath, true);

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
this.pageIsSSG.set(pagePath, true);
return content;

@SkyZeroZx SkyZeroZx Jun 12, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@alan-agius4
Q: The this.pageIsSSG.set(pagePath, true); is no longer necessary? or yes, as I understood it was necessary for this line

if (this.pageIsSSG.get(pagePath)) { 
// Serve pre-rendered page. 
return fs.promises.readFile(pagePath, 'utf-8'); 
}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I mean return in the if statement not removing the `this.pageIsSSG.set’

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought the same thing, I had my doubts, it's already updated in the fixup!

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A somewhat tangential request and sorry for the inconvenience.

I had two issue tracker reports that resulted in security advisories:

Both issues were closed (infeasible) , but since the corresponding advisories (including credits) were published, would it be possible to review them and update their status to Accepted/Fixed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants