Skip to content

fix(@angular/build): assert that asset input paths are within workspace root#33222

Open
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:asset-validation
Open

fix(@angular/build): assert that asset input paths are within workspace root#33222
alan-agius4 wants to merge 1 commit into
angular:mainfrom
alan-agius4:asset-validation

Conversation

@alan-agius4
Copy link
Copy Markdown
Collaborator

Ensure that asset patterns defined as objects with an 'input' property are validated to be within the workspace root.

  • In '@angular/build', introduce a shared 'isSubDirectory' utility and apply it to both 'normalizeAssetPatterns' and 'resolveAssets'.
  • In '@angular-devkit/build-angular', apply similar validation during 'normalizeAssetPatterns'.
  • Add integration tests to prevent regressions from absolute and relative path traversal attempts.

@alan-agius4 alan-agius4 requested review from clydin and dgp1130 May 20, 2026 09:25
@alan-agius4 alan-agius4 added the target: patch This PR is targeted for the next patch release label May 20, 2026
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 validation to ensure that asset input paths are located within the workspace root, adding a new isSubDirectory utility and corresponding checks across the application and browser builders. Feedback was provided regarding the path validation logic, specifically noting that the current use of startsWith('..') could lead to false positives for files or directories with names starting with double dots. It is recommended to refine these checks by accounting for path separators to ensure more robust path resolution.

Comment thread packages/angular/build/src/utils/path.ts Outdated
Comment thread packages/angular_devkit/build_angular/src/utils/normalize-asset-patterns.ts Outdated
@alan-agius4 alan-agius4 added the action: review The PR is still awaiting reviews from at least one requested reviewer label May 20, 2026
@alan-agius4 alan-agius4 force-pushed the asset-validation branch 6 times, most recently from 8430535 to db9ee2a Compare May 20, 2026 13:55
…ce root

Ensure that asset patterns defined as objects with an 'input' property are validated to be within the workspace root.

- In '@angular/build', introduce a shared 'isSubDirectory' utility and apply it to both 'normalizeAssetPatterns' and 'resolveAssets'.
- In '@angular-devkit/build-angular', apply similar validation during 'normalizeAssetPatterns'.
- Add and update integration and E2E tests to prevent regressions from absolute and relative path traversal attempts.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

action: review The PR is still awaiting reviews from at least one requested reviewer area: @angular/build target: patch This PR is targeted for the next patch release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant