Skip to content

fix(security): reject path-traversal in extra_info paths - #238

Merged
Perry2004 merged 3 commits into
mainfrom
fix/extra-info-path-traversal
Jul 10, 2026
Merged

fix(security): reject path-traversal in extra_info paths#238
Perry2004 merged 3 commits into
mainfrom
fix/extra-info-path-traversal

Conversation

@reacher-z

Copy link
Copy Markdown
Collaborator

Reject path-traversal in extra_info paths

A task's extra_info[].path is untrusted input, but copy_extra_info() joined it to the case dir with no containment check (src = task_dir / rel_path). An absolute path or one containing .. could copy arbitrary host files into the staged my-info/ dir — which is then shipped inside a shareable Harbor export (clawbench-harbor-adapt) or bind-mounted into the agent container. This is a real information-disclosure vector.

Fix

  • New validate_extra_info_path(task_dir, rel_path) in run_support/task.py: rejects absolute paths and any target whose resolved location (symlinks followed) escapes task_dir (src.resolve().relative_to(task_dir.resolve())). Returns the unresolved task_dir / rel_path, so valid relative paths copy exactly as before.
  • Applied in copy_extra_info() — benefits the native runner and the Harbor adapter, which both stage extra_info.

Tests (all pass; ruff + pyright clean)

  • valid relative path still resolves/copies;
  • absolute path rejected;
  • .. escape rejected;
  • copy_extra_info with {"path": "../secret.txt"} raises and copies nothing.

Small, self-contained, no behavior change for legitimate tasks. Found while building Harbor-runner tooling; extracted here as a standalone fix against main.

An untrusted task's extra_info[].path was joined to the case dir with no
containment check, so an absolute path or one containing '..' could copy
arbitrary host files into the staged my-info dir (which can be shipped in a
shareable Harbor export). Add validate_extra_info_path() — rejects absolute
paths and any target whose resolved location escapes the task dir — and apply
it in copy_extra_info. Valid relative paths are unchanged.

@Perry2004 Perry2004 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The new test case test_validate_extra_info_path_rejects_absolute is failing on Windows: https://github.com/TIGER-AI-Lab/ClawBench/actions/runs/28527654260/job/84568382985?pr=238

reacher-z added 2 commits July 8, 2026 06:00
On Windows, Path('/etc/passwd').is_absolute() is False (no drive), so the guard
rejects it via the containment check ('escapes') rather than the is_absolute
branch ('absolute'). The path is still rejected (security holds); relax the
message match to 'absolute|escapes' so pytest (windows-latest) passes.
@reacher-z

Copy link
Copy Markdown
Collaborator Author

@Perry2004 Fixed — thanks for catching this. Root cause: on Windows Path("/etc/passwd").is_absolute() is False (Windows needs a drive letter), so validate_extra_info_path rejected it via the containment check ("escapes") rather than the is_absolute branch ("absolute") — the path is still correctly rejected, but the test's match="absolute" didn't match the Windows rejection message.

Fixed in c5d8061 by relaxing the assertion to match="absolute|escapes" (both are valid rejections; the security property holds on all platforms). Also brought the branch up to date with main.

CI is now green on all OS including pytest (windows-latest): https://github.com/TIGER-AI-Lab/ClawBench/actions/runs/28944758766

Ready for re-review when you have a moment.

@Perry2004 Perry2004 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM🫡

@Perry2004
Perry2004 merged commit 662d03a into main Jul 10, 2026
5 checks passed
@Perry2004
Perry2004 deleted the fix/extra-info-path-traversal branch July 10, 2026 01:22
@github-project-automation github-project-automation Bot moved this from Todo to Done in ClawBench Jul 10, 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.

2 participants