Skip to content

fix(file-saver): block symlink escapes on save#103

Merged
chaliy merged 1 commit intomainfrom
fix/issue-97-file-saver-symlink-safety
Apr 15, 2026
Merged

fix(file-saver): block symlink escapes on save#103
chaliy merged 1 commit intomainfrom
fix/issue-97-file-saver-symlink-safety

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented Apr 15, 2026

What

Harden LocalFileSaver against symlink-based escapes under base_dir.

Closes #97.

Why

Lexical normalization blocked .. traversal, but a pre-existing symlink inside the save root could still redirect writes outside the allowed directory. execute_with_saver() also split validation and write into separate steps, which left a race window.

How

  • walk each parent directory at save time under the canonical base directory
  • reject symlinked parent components and symlink final targets before writing
  • keep the canonicalized path pinned under the canonical base directory
  • remove the separate validate_path() preflight from execute_with_saver() so checks happen at write time
  • add regression coverage for direct saver writes and execute_with_saver() symlink escapes
  • update the threat model to mark this path as mitigated

Risk

  • Low
  • Touches only file-save path handling and adds regression tests around the changed behavior

Checklist

  • Unit tests are passed
  • Smoke tests are passed
  • Documentation is updated
  • Specs are up to date and not in conflict
  • cargo fmt --all is passed
  • cargo clippy --workspace --all-targets -- -D warnings is passed
  • RUSTDOCFLAGS="-D warnings" cargo doc --workspace --no-deps is passed
  • cargo build --workspace --exclude fetchkit-python --release is passed

@chaliy chaliy merged commit afbc233 into main Apr 15, 2026
11 checks passed
@chaliy chaliy deleted the fix/issue-97-file-saver-symlink-safety branch April 15, 2026 14:31
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.

LocalFileSaver base-dir enforcement can be escaped via symlinks

1 participant