fix(platform): close CWE-59 symlink-traversal gap in resolveInsideRoot (#380) #409

Merged
core-be merged 1 commits from fix/380-cwe59-symlink-traversal into staging 2026-05-11 07:02:35 +00:00

1 Commits

Author SHA1 Message Date
72a48214ee fix(platform): close CWE-59 symlink-traversal gap in resolveInsideRoot (#380)
Some checks failed
sop-tier-check / tier-check (pull_request) Failing after 5s
Secret scan / Scan diff for credential-shaped strings (pull_request) Successful in 6s
audit-force-merge / audit (pull_request) Successful in 30s
Follow-up to #369. `resolveInsideRoot` used `filepath.Abs` which does NOT
resolve symlinks — so "workspaces/dev/leaked" where "leaked" is a symlink
to "/etc" would lexically pass the prefix check but resolve outside root.

Fix: call `filepath.EvalSymlinks` before the final prefix check. If the
resolved path points outside root the function returns "path escapes root".
Broken symlinks are also rejected (fail closed).

Also add TestResolveInsideRoot_RejectsSymlinkTraversal covering:
- Symlink pointing outside → rejected (CWE-59)
- Symlink staying inside root → allowed
- Broken symlink → rejected
2026-05-11 06:26:56 +00:00