Skip to content

fix(fs): Contain Link reads within the mapped target subtree - #1707

Open
devtomtom wants to merge 1 commit into
mainfrom
fix-fs-link-containment
Open

devtomtom wants to merge 1 commit into
mainfrom
fix-fs-link-containment

Conversation

@devtomtom

Copy link
Copy Markdown
Member

A Link rewrites a requested path by replacing linkPath with targetPath and forwards the result to the backing reader. The backing reader normalizes the path, so a request that contains ".." segments can resolve to a resource outside targetPath. The returned ResourceFacade then exposes that resource under the link namespace.

Normalize the rewritten POSIX path and confirm it stays within targetPath before calling the backing reader. Recheck the returned resource's own path before wrapping it in a ResourceFacade, in both byPath and byGlob, and drop glob results that resolve outside the subtree.

The normalization lives in resolvePath so the containment check also applies to the resolved path recorded by MonitoredReader, which this monorepo relies on for build-dependency tracking. The trailing slash that _validatePathMapping requires on targetPath keeps the boundary check segment-aware, so a sibling such as "/resources/application/" is not accepted for "/resources/app/". createFlatReader builds a Link with a trailing-slash targetPath, so it inherits the same containment.

JIRA: CPOUI5FOUNDATION-1402

A Link rewrites a requested path by replacing linkPath with targetPath and
forwards the result to the backing reader. The backing reader normalizes the
path, so a request that contains ".." segments can resolve to a resource
outside targetPath. The returned ResourceFacade then exposes that resource
under the link namespace.

Normalize the rewritten POSIX path and confirm it stays within targetPath
before calling the backing reader. Recheck the returned resource's own path
before wrapping it in a ResourceFacade, in both byPath and byGlob, and drop
glob results that resolve outside the subtree.

The normalization lives in resolvePath so the containment check also applies
to the resolved path recorded by MonitoredReader, which this monorepo relies
on for build-dependency tracking. The trailing slash that _validatePathMapping
requires on targetPath keeps the boundary check segment-aware, so a sibling
such as "/resources/application/" is not accepted for "/resources/app/".
createFlatReader builds a Link with a trailing-slash targetPath, so it
inherits the same containment.

JIRA: CPOUI5FOUNDATION-1402
@devtomtom
devtomtom requested a review from matz3 November 23, 2026 09:51

This branch has not been deployed

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

⌂ Proxy