Skip to content

fix(@angular/build): restrict application builder output paths to output directory#33312

Open
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix-application-builder-output-scoping
Open

fix(@angular/build): restrict application builder output paths to output directory#33312
clydin wants to merge 1 commit into
angular:mainfrom
clydin:fix-application-builder-output-scoping

Conversation

@clydin
Copy link
Copy Markdown
Member

@clydin clydin commented Jun 4, 2026

Ensure all file writes and deletions produced by the application builder are strictly scoped to the configured outputPath base directory.

This prevents path traversal vulnerabilities (e.g. setting browser directory to .. or relative segments that escape the output base folder) by checking all generated paths against a refined isSubDirectory helper before any file system write or deletion is performed.

@clydin clydin marked this pull request as ready for review June 4, 2026 17:54
Copy link
Copy Markdown

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

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 introduces path traversal protection by ensuring that generated output files do not escape the configured output directory base. It wraps file emission and deletion processes in try-catch blocks to handle errors gracefully, and implements a robust isSubDirectory utility with corresponding unit and integration tests. The review comments point out a potential issue on Windows environments where using posix.relative directly can fail due to case-insensitive drive letter differences, and suggest using platform-specific relative instead.

Comment thread packages/angular/build/src/utils/path.ts
Comment thread packages/angular/build/src/utils/path.ts Outdated
…put directory

Ensure all file writes and deletions produced by the application builder are strictly scoped to the configured `outputPath` base directory.

This prevents path traversal vulnerabilities (e.g. setting `browser` directory to `..` or relative segments that escape the output base folder) by checking all generated paths against a refined `isSubDirectory` helper before any file system write or deletion is performed.
@clydin clydin force-pushed the fix-application-builder-output-scoping branch from d9a1c8a to 323e4a5 Compare June 4, 2026 18:01
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.

1 participant