Skip to content

fix(core): validate the migrations path before extracting package migrations - #36887

Open
FrozenPandaz wants to merge 2 commits into
masterfrom
feature/nxc-4925-migrate-path-traversal
Open

fix(core): validate the migrations path before extracting package migrations#36887
FrozenPandaz wants to merge 2 commits into
masterfrom
feature/nxc-4925-migrate-path-traversal

Conversation

@FrozenPandaz

Copy link
Copy Markdown
Contributor

Current Behavior

readNxMigrateConfig returned the nx-migrations.migrations value from a package manifest without validating it. Consumers joined that value onto a directory and used the result as a write destination, so the field was trusted to be package-relative without anything enforcing it.

The same containment rule was already implemented locally in prompt-files.ts for the sibling prompt field, so there were two copies of the idea and only one of them was applied.

Expected Behavior

The value is validated where it is read. A migrations path must be relative and must resolve within its own package; anything else fails closed with an error naming the offending package and version. Both the object form and the string shorthand are covered, so every consumer of the field is gated at the point the value is parsed rather than at each use.

The containment check now lives in utils/path.ts as isContainedRelativePath and replaces the duplicate local helper in prompt-files.ts, leaving one rule for the whole migrate path.

Related Issue(s)

Security report supplied privately.


View Polygraph session ↗

…rations

`readNxMigrateConfig` now rejects an `nx-migrations.migrations` value that is
absolute or escapes its own package, in both the object and string shorthand
forms, so the value is validated at the point it is read rather than at each
use. The containment check lives in `utils/path.ts` as
`isContainedRelativePath` and replaces the duplicate local helper in
`prompt-files.ts`.

Details supplied privately.
@netlify

netlify Bot commented Sep 1, 2026

Copy link
Copy Markdown

Deploy Preview for nx-docs ready!

Name Link
🔨 Latest commit e7fcf90
🔍 Latest deploy log https://app.netlify.com/projects/nx-docs/deploys/6a9730ea0489910008177b5a
😎 Deploy Preview https://deploy-preview-36887--nx-docs.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@netlify

netlify Bot commented Sep 1, 2026

Copy link
Copy Markdown

Deploy Preview for nx-dev ready!

Name Link
🔨 Latest commit e7fcf90
🔍 Latest deploy log https://app.netlify.com/projects/nx-dev/deploys/6a9730ea41913e00080257e9
😎 Deploy Preview https://deploy-preview-36887--nx-dev.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@nx-cloud

nx-cloud Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

View your CI Pipeline Execution ↗ for commit e6b2083

Command Status Duration Result
nx affected --targets=lint,oxlint,test,build,e2... ✅ Succeeded 13m 26s View ↗
nx run-many -t check-imports check-lock-files c... ✅ Succeeded 4s View ↗
nx-cloud record -- pnpm nx-cloud conformance:check ✅ Succeeded 55s View ↗
nx build workspace-plugin ✅ Succeeded <1s View ↗
nx-cloud record -- nx sync:check ✅ Succeeded 18s View ↗
nx-cloud record -- nx format:check ✅ Succeeded 1s View ↗

☁️ Nx Cloud last updated this comment at 2026-09-01 20:26:51 UTC

@FrozenPandaz
FrozenPandaz marked this pull request as ready for review September 1, 2026 19:36
@FrozenPandaz
FrozenPandaz requested a review from a team as a code owner September 1, 2026 19:36

@nx-cloud nx-cloud Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nx Cloud has identified a flaky task in your failed CI:

🔂 Since the failure was identified as flaky, we triggered a CI rerun by adding an empty commit to this branch.

Nx Cloud View detailed reasoning in Nx Cloud ↗

🔔 Heads up, your workspace has pending recommendations ↗ to auto-apply fixes for similar failures.


🎓 Learn more about Self-Healing CI on nx.dev

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