Skip to content

fix(fetchkit): harden local file saver symlink handling#134

Merged
chaliy merged 1 commit into
mainfrom
2026-05-19-fix-local-file-saver-symlinks
May 19, 2026
Merged

fix(fetchkit): harden local file saver symlink handling#134
chaliy merged 1 commit into
mainfrom
2026-05-19-fix-local-file-saver-symlinks

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented May 19, 2026

What

Harden LocalFileSaver so base_dir saves cannot escape through symlinked parent directories or final symlink targets. Update safety tests and specs/threat model for the mitigated behavior.

Why

LocalFileSaver previously depended on lexical path checks plus check-then-write behavior. In embeddings that expose save_to_file with a filesystem-backed base directory, symlinks could redirect writes outside the intended sandbox.

How

Use Unix directory file descriptors with no-follow opens for save-time traversal and final file creation. Keep the existing non-Unix fallback checks, add final-symlink regression coverage, and document the mitigation.

Risk

  • Low / Medium / High: Medium
  • What can break: Unix save_to_file now rejects symlinked paths that may previously have worked. Intended behavior for sandboxed LocalFileSaver usage.

Checklist

  • Tests added or updated
  • Backward compatibility considered
  • Specs are up to date and not in conflict
  • Documentation updated where behavior is specified

@chaliy chaliy merged commit f857737 into main May 19, 2026
11 checks passed
@chaliy chaliy deleted the 2026-05-19-fix-local-file-saver-symlinks branch May 19, 2026 03:54
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