Skip to content

fix(@angular/ssr): ensure public directory containment in CommonEngine - #33958

Merged
alan-agius4 merged 1 commit into
angular:21.2.xfrom
alan-agius4:fix-common-engine-path-containment-21.2.x
Aug 28, 2026
Merged

fix(@angular/ssr): ensure public directory containment in CommonEngine#33958
alan-agius4 merged 1 commit into
angular:21.2.xfrom
alan-agius4:fix-common-engine-path-containment-21.2.x

Conversation

@alan-agius4

Copy link
Copy Markdown
Collaborator

Ensure that paths resolved in retrieveSSGPage strictly remain within the configured publicPath by checking relative() containment before evaluating the static file.

Previously, a string startsWith() check was used, which could match sibling directories that share the same name prefix as publicPath.

@alan-agius4
alan-agius4 requested a review from clydin August 28, 2026 07:38
@alan-agius4 alan-agius4 added action: review The PR is still awaiting reviews from at least one requested reviewer target: lts This PR is targeting a version currently in long-term support labels Aug 28, 2026

@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 refactors the path traversal prevention logic in the Angular SSR CommonEngine by replacing the startsWith(normalize(publicPath)) check with a check using relative(publicPath, pagePath). It also moves this validation step to run before checking if the page is pre-rendered. The feedback highlights a potential issue where checking relativePath.startsWith('..') can cause false positives for valid files or directories starting with .. (e.g., ..hidden), and suggests a more robust check that accounts for path separators.

Comment thread packages/angular/ssr/node/src/common-engine/common-engine.ts
Ensure that paths resolved in `retrieveSSGPage` strictly remain within the configured `publicPath` by checking `relative()` containment before evaluating the static file.

Previously, a string `startsWith()` check was used, which could match sibling directories that share the same name prefix as `publicPath`.
@alan-agius4
alan-agius4 force-pushed the fix-common-engine-path-containment-21.2.x branch from c45c6c3 to 523e60d Compare August 28, 2026 07:57
@alan-agius4 alan-agius4 added action: merge The PR is ready for merge by the caretaker and removed action: review The PR is still awaiting reviews from at least one requested reviewer labels Aug 28, 2026
@alan-agius4
alan-agius4 merged commit 645e41a into angular:21.2.x Aug 28, 2026
34 of 35 checks passed
@alan-agius4
alan-agius4 deleted the fix-common-engine-path-containment-21.2.x branch August 28, 2026 15:45
@alan-agius4

Copy link
Copy Markdown
Collaborator Author

This PR was merged into the repository. The changes were merged into the following branches:

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

Labels

action: merge The PR is ready for merge by the caretaker area: @angular/ssr target: lts This PR is targeting a version currently in long-term support

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants