fix: allow symlinked local sandbox workspace paths#2997
Conversation
There was a problem hiding this comment.
Pull request overview
This PR updates local sandbox user-data path validation so symlinked repositories under the workspace are accepted without resolving them outside the allowlist.
Changes:
- Switches user-data validation from
Path.resolve()to lexicalabspath()normalization. - Documents why symlink traversal is intentionally not resolved.
- Adds a regression test for a symlinked workspace repository path.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
backend/packages/harness/deerflow/sandbox/tools.py |
Changes local sandbox user-data path normalization/validation behavior. |
backend/tests/test_sandbox_tools_security.py |
Adds symlinked workspace path regression coverage. |
| """ | ||
| resolved_str = replace_virtual_path(path, thread_data) | ||
| resolved = Path(resolved_str).resolve() | ||
| resolved = Path(os.path.abspath(resolved_str)) |
|
@yu-xin-c thanks for your contribution. Please check out the unit test error and review the comment of Copilot. |
024cde8 to
358a187
Compare
|
@yu-xin-c, here are some comments for the latest code
|
|
Updated in 76048ce:\n\n- Added a regression test for a workspace symlink followed by a |
Summary
..before checking allowed roots/mnt/user-data/workspaceContext
This addresses the path-validation asymmetry discussed in #2820: dedicated tools such as
read_file,ls,grep, andglobcan reject symlinked workspace repositories afterPath.resolve()follows the symlink outside the allowlist, while bash path replacement still works.Tests
uv run --project backend pytest backend/tests/test_sandbox_tools_security.py -quv run --project backend ruff check backend/packages/harness/deerflow/sandbox/tools.py backend/tests/test_sandbox_tools_security.pypython3 -m py_compile backend/packages/harness/deerflow/sandbox/tools.py backend/tests/test_sandbox_tools_security.py