fix(devframe): contain remote asset materialization - #328
Merged
Conversation
Validate every provider-listed path before fetching or writing it during RemoteAssetsStore.materialize(): reject absolute paths, backslashes, and any suffix whose resolved destination would escape the target directory. A compromised or buggy custom provider could otherwise list a path that traverses outside the requested build directory.
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
antfu
approved these changes
Sep 1, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RemoteAssetsStore.materialize()trusted provider-listed paths after checking only a string prefix. A compromised or buggy customRemoteAssetsProvidercould list a prefixed path whose suffix traverses outside the requested build directory, letting build materialization write files outsidetargetDir.Changes
materializeTarget()inpackages/devframe/src/utils/remote-assets.ts: validates each provider-listed path before any fetch or filesystem write — rejecting absolute paths, backslashes (never normalized into a separator), and any suffix whose resolved destination would land outside the target directory (or equal it exactly, since that names the directory itself, not a writable file).materialize()now resolves each destination through this helper instead of joining the raw provider path, and silently skips (does not fetch) any entry that fails validation or falls outside the selectedpathprefix — matching the existing behavior for ordinary out-of-scope package files (e.g.package.json).Verification
pnpm exec vitest run packages/devframe/src/utils/remote-assets.test.ts— all 29 tests pass.pnpm --filter devframe typecheck— exit 0.pnpm --filter devframe test(fullpackages/devframesuite viavitest run packages/devframe, including thetsdown-stale-guardAPI snapshot) — 578 tests pass.pnpm lint(eslint --cache) — clean.pnpm knipand the monorepo-widepnpm build/pnpm typecheckcurrently fail on this environment for reasons unrelated to this change (verified identically on an unmodified checkout ofmain): knip can't resolvestarter/'s workspace-linkeddist/output, andplugins/git's Next.js build hits a pre-existingEACCESon a stray file permission in this sandbox.This PR was created with the help of an agent.