fix(security): fix file_tools.py validate_path startswith bypass #7478 #11214

Merged
HAL9000 merged 1 commits from fix/m1-security-fix-startswith-bypass into master 2026-05-14 23:37:33 +00:00

1 Commits

Author SHA1 Message Date
HAL9000 55a6169dda fix(security): fix file_tools.py validate_path startswith bypass #7478
CI / push-validation (pull_request) Successful in 29s
CI / helm (pull_request) Successful in 39s
CI / build (pull_request) Successful in 1m8s
CI / lint (pull_request) Successful in 1m27s
CI / quality (pull_request) Successful in 1m31s
CI / security (pull_request) Successful in 1m47s
CI / typecheck (pull_request) Successful in 1m49s
CI / integration_tests (pull_request) Successful in 4m41s
CI / unit_tests (pull_request) Successful in 4m48s
CI / docker (pull_request) Successful in 1m30s
CI / coverage (pull_request) Successful in 15m7s
CI / status-check (pull_request) Successful in 14s
Replace string-based startswith() path traversal guards with robust
Path.relative_to() across three files to prevent prefix-collision
bypass attacks.  The old checks using str(target).startswith(str(root))
could be evaded by paths like /tmp/abc123-escape when root is /tmp/abc123.

Files patched:
  - src/cleveragents/skills/builtins/file_ops.py (validate_sandbox_path)
  - src/cleveragents/resource/handlers/_base.py (_safe_resolve)
  - src/cleveragents/application/services/llm_actors.py (_write_to_sandbox)

ISSUES CLOSED: #7478
2026-05-14 23:16:41 +00:00