Skip to content

sanitize RemovePaths when exporting changeset results - #13222

Merged
sipsma merged 1 commit into
dagger:mainfrom
marcosnils:push-qxtuyosuxrqr
May 29, 2026
Merged

sipsma merged 1 commit into
dagger:mainfrom
marcosnils:push-qxtuyosuxrqr

Conversation

@marcosnils

Copy link
Copy Markdown
Contributor

Dagger's Windows client can remove files or directories outside the selected workspace/export root when applying a Changeset returned by a module.

The issue comes from a cross-platform path interpretation mismatch. The Linux engine can create a Changeset containing removed paths with backslashes, such as ..\outside-marker.txt, because backslash is a normal filename byte there. The Windows client later interprets the same string as parent traversal while processing RemovePaths during Changeset.export / CLI auto-apply.

The same sink also accepts absolute Windows paths in RemovePaths. A module can therefore return a Changeset containing a removed path such as <absolute Windows marker path>, and the Windows client will remove that absolute path during auto-apply.

credits to: JUNYI LIU

Dagger's Windows client can remove files or directories outside the selected
workspace/export root when applying a Changeset returned by a module.

The issue comes from a cross-platform path interpretation mismatch. The Linux
engine can create a Changeset containing removed paths with backslashes, such as
`..\outside-marker.txt`, because backslash is a normal filename byte there. The
Windows client later interprets the same string as parent traversal while
processing `RemovePaths` during `Changeset.export` / CLI auto-apply.

The same sink also accepts absolute Windows paths in `RemovePaths`. A module can
therefore return a Changeset containing a removed path such as
`<absolute Windows marker path>`, and the Windows client will remove that
absolute path during auto-apply.

credits to: JUNYI LIU

Signed-off-by: Marcos Nils <[email protected]>
@marcosnils
marcosnils requested review from sipsma and vito May 26, 2026 14:27
@marcosnils marcosnils added this to the v0.21.1 milestone May 28, 2026

@sipsma sipsma 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.

TBH I don't understand the explanation in the PR description and because there's no tests I can't tell what it's fixing. Can you clarify the situation this is fixing?

I understand tests are hard because we don't have any windows clients to test on in CI but would feel better if there was at least a manual test for now.

@marcosnils

Copy link
Copy Markdown
Contributor Author

I understand tests are hard because we don't have any windows clients to test on in CI but would feel better if there was at least a manual test for now.

I did run some manual tests. Sorry, forgot to mention that. Here's a repro test that triggers this issue.

func (m *Changesetescape) EscapeDelete() *dagger.Changeset {
	before := dag.Directory().WithNewFile(`..\outside-marker.txt`, "marker")
	after := dag.Directory()
	return after.Changes(before)
}

func (m *Changesetescape) EscapeEmptyDirDelete() *dagger.Changeset {
	before := dag.Directory().WithNewDirectory(`..\outside-empty-dir`)
	after := dag.Directory()
	return after.Changes(before)
}

func (m *Changesetescape) EscapeAbsoluteDelete(path string) *dagger.Changeset {
	before := dag.Directory().WithNewFile(path, "marker")
	after := dag.Directory()
	return after.Changes(before)
}

any of those functions will result in escaped module paths being deleted in the Windows client system.

@sipsma
sipsma merged commit b2f595b into dagger:main May 29, 2026
77 checks passed
@marcosnils
marcosnils deleted the push-qxtuyosuxrqr branch July 18, 2026 03:17
social4hyq pushed a commit to social4hyq/homebrew-core that referenced this pull request Sep 20, 2026
dagger 0.21.1

Created-by: HarmonybrewBot
Commit-by: HarmonybrewBot
Merged-by: HarmonybrewBot
Description: Created by `brew bump`

---

Created with `brew bump-formula-pr`.<details>
  <summary>release notes</summary>
  <pre>## v0.21.1 - 2026-05-29

### Added
- Add native GraphQL interfaces and unified object IDs in DagQL by @vito in dagger/dagger#12041 \
  Dagger now exposes objects through the standard `Node` interface and `ID` scalar, enabling APIs to accept generic Dagger objects while preserving SDK compatibility through legacy `FooID` and `loadFooFromID` views for older clients.

### Fixed
- Python SDK: fix unhandled module registration cases and bugs by removing the AST-based module analyzer and returning to runtime introspection by @eunomie in dagger/dagger#13251
- Fix Go module generation to avoid unnecessary dependency churn in generated `go.mod` and `go.sum` files by @sipsma in dagger/dagger#13244
- Fix registry authentication so `withRegistryAuth` credentials are not incorrectly skipped and authenticated publishes keep working after anonymous pulls to the same registry by @marcosnils + @sipsma in dagger/dagger#13255 dagger/dagger#13256
- Fix published image layer structure so `withDirectory` and `withFile` operations preserve expected layer boundaries instead of being squashed into a few large layers by @sipsma in dagger/dagger#13242
- Fix Dockerfile `RUN --mount=type=bind` conversion when the bind source selector points to a regular file, improving compatibility with file and directory bind mounts by @sipsma in dagger/dagger#13273
- Fix module source cache dependency retention, including ephemeral `missing shared result` errors after cache persistence or engine restarts by @sipsma in dagger/dagger#13243
- Fix a bug where some cache entries did not have their size calculated during background and shutdown pruning by @sipsma in dagger/dagger#13225
- Fix repeated `op://` 1Password secret reads by caching resolved 1Password secret values during a run, avoiding provider rate limits when the same secret is mounted or read multiple times by @matipan in dagger/dagger#13249
- Fix Windows Changeset exports so `RemovePaths` entries cannot remove files outside the selected export root through backslash or absolute-path interpretation by @marcosnils in dagger/dagger#13222
- Fix `dagger --x-release` for tagged releases so semver refs download release artifacts instead of looking in the main-build artifact namespace, and prevent local runner override environment from leaking into the re-executed CLI by @grouville in dagger/dagger#13259

### What to do next?
- Read the [documentation](https://docs.dagger.io)
- Join our [Discord server](https://discord.gg/dagger-io)
- Follow us on [Twitter](https://twitter.com/dagger_io)

</pre>
  <p>View the full release notes at <a href="https://github.com/dagger/dagger/releases/tag/v0.21.1">https://github.com/dagger/dagger/releases/tag/v0.21.1</a>.</p>
</details>
<hr>

See merge request: Harmonybrew/homebrew-core!9585
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.

2 participants