Skip to content

fix: confine LocalDiskVFS file operations to the project root - #1196

Open
DZH166 wants to merge 3 commits into
Pythagora-io:mainfrom
DZH166:codex/confine-local-vfs-paths
Open

DZH166 wants to merge 3 commits into
Pythagora-io:mainfrom
DZH166:codex/confine-local-vfs-paths

Conversation

@DZH166

@DZH166 DZH166 commented Oct 31, 2026 •

Copy link
Copy Markdown

Fixes #1194

Check both the normalized absolute path and its resolved target against the project root. Reject relative traversal, absolute paths outside the root, sibling-directory prefix collisions and existing symlinks that resolve outside the root, before filesystem access. An outside alias pointing into the root is also rejected.

Keep returning the normalized absolute path rather than its resolved target. This preserves remove() behavior for an in-root file symlink: unlink the alias and leave its target intact. Normalized paths and absolute paths inside the root still work.

Testing

  • python -m pytest tests/disk --no-cov -o addopts="" -ra: 37 passed, 3 skipped. Windows does not permit creating the three real symlink fixtures, so those integration cases were not run successfully here.
  • Five additional regression cases simulate only Path.resolve() while exercising the public VFS operations on real temporary files. The removal test verifies that the alias is actually removed and its target is preserved; the other cases reject outside paths resolving inside the root. All five failed before the follow-up fix and pass afterward.
  • The traversal regressions failed in 12 cases on the unchanged implementation.
  • Ruff 0.3.5 check and format check on both changed files; git diff --check passed.

This is a path-containment check, not a complete sandbox: a malicious process replacing symlinks concurrently can still create a TOCTOU race.

Prepared with AI assistance; tests were run locally.

Follow-up regression coverage

Validate removal paths before applying ignore rules. IgnoreMatcher may stat or open a file; an outside path must be rejected before that inspection, including when a matching ignore rule would otherwise return early.

2 added regressions failed before the follow-up; 37 disk tests passed and 3 real symlink fixtures skipped on Windows. Ruff check/format and git diff --check passed.

@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

DZH166 commented Oct 31, 2026

Copy link
Copy Markdown
Author

The CLA Assistant link for this PR currently displays the ‘SAP Individual Contributor License Agreement’, naming SAP SE as the license recipient. Is this the intended agreement for Pythagora's GPT-Pilot, or should the configured CLA be updated?

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.

Path traversal in LocalDiskVFS allows LLM-controlled save_file.path to write outside the workspace root

2 participants