Skip to content

fix: prevent path-traversal sandbox escape in filesystem operations - #91

Merged
hashemix merged 2 commits into
mainfrom
fix/path-traversal-sandbox-bypass
Jul 26, 2026
Merged

fix: prevent path-traversal sandbox escape in filesystem operations#91
hashemix merged 2 commits into
mainfrom
fix/path-traversal-sandbox-bypass

Conversation

@hashemix

@hashemix hashemix commented Jul 26, 2026

Copy link
Copy Markdown
Member

📌 Summary

Fix path-traversal sandbox escape in filesystem operations. The normalize_path function fell back to raw (unsanitized) paths when canonicalize() failed for non-existent files, allowing .. components to bypass validate_path. This enables escaping the allowed directory sandbox via write_file, create_directory, move_file, and edit save-to.

🔍 Related Issues

✨ Changes Made

  • normalize_path now attempts to canonicalize the parent directory and rejoin the file name when the full path doesn't exist. Falls back to raw path only as last resort.
  • validate_path returns the normalized path instead of the raw absolute_path. Added defense-in-depth rejection of any path still containing Component::ParentDir after normalization.
  • save_to now passes through validate_path with the allowed directories set (previously skipped validation entirely).
  • Added 10 regression tests covering .. escape, symlink escape (unix), write/create/move/edit end-to-end escapes, multi-level .., resolved-in-root paths, non-existent-with-out-of-bounds-parent, and defense-in-depth.

🛠️ Testing Steps

cargo make check

💡 Additional Notes

  • A GitHub Security Advisory (with CVE request) has been drafted and will be published simultaneously with the release containing this fix.
  • SECURITY.md added to document the vulnerability reporting process.
  • CVE ID to be added to CHANGELOG.md at release time.

@hashemix
hashemix merged commit 1356567 into main Jul 26, 2026
14 checks passed
@hashemix hashemix mentioned this pull request Jul 26, 2026
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