You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Path-confinement bypass in file_read/file_write (startswith sibling-dir escape) #1021
str.startswith on the resolved path string is a sibling-directory escape. With base_dir=/home/user/ws, an LLM-supplied path resolving to /home/user/ws-secret/creds (or /home/user/workspace-backup/...) passes the guard because the string "/home/user/ws-secret/creds" starts with "/home/user/ws". FileWriteTool._write_blocking additionally does mkdir(parents=True), so this is arbitrary file creation/overwrite outside the sandbox, not just read.
.resolve() already neutralises plain ../, so the practical exploit is the shared-prefix sibling class.
src/synapsekit/agents/tools/file_read.py:57
src/synapsekit/agents/tools/file_write.py:72
The path argument is LLM/agent-controlled tool input, so this is reachable by prompt injection or an adversarial task whenever an agent is given these tools with a base_dir.
Severity
HIGH — confinement bypass, LLM-reachable, read and write.
Fix
Use Path.is_relative_to (the pattern already used correctly at mesh/loaders.py:150 and sandbox/apply.py:35) instead of str.startswith. The docstrings claim to "mirror the mesh loader precedent" — this restores that. Non-breaking: legitimate in-tree paths still pass.
Also (defense-in-depth, this scope): file_list.py and pdf_reader.py have no confinement at all — add an optional base_dir using the same is_relative_to guard.
Acceptance
Regression test: sibling-prefix path ({base}-secret) is rejected for both read and write; in-tree paths still allowed; .. traversal rejected.
Activity
style: apply ruff format to security-hardening changes
Merge pull request #1027 from SynapseKit/security/hardening-1021-1026
fix(agents): close path-confinement bypass in file tools