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
Two related path-boundary gaps in packages/policy:
rego.go:391 — the rootDirectory check uses a plain startswith string comparison between the candidate path and the configured root, with no boundary check after the prefix. A root of /home/user/project would incorrectly match a sibling path like /home/user/project-evil since the latter starts with the former as a raw string.
extract_paths.go:231 — absolute paths containing dot-segments (e.g. /a/b/../../etc/passwd) are not canonicalized (no filepath.Clean or equivalent) before being used in comparisons, so a path can appear to be within a root while its actual resolved target is outside it.
Impact
Both gaps let a path that should be rejected as outside the configured root directory pass the confinement check: via a sibling-directory name that merely shares the same string prefix, or via unresolved dot-segments that walk the real path outside the root after the string comparison already passed.
Repro
Configure rootDirectory to /home/user/project and evaluate a path /home/user/project-other/secret and observe the prefix check allows it.
Configure the same root and evaluate /home/user/project/../../etc/passwd and observe it is treated as inside the root by the raw string/prefix logic despite resolving outside it.
Suggested fix
Clean every path with filepath.Clean (and resolve .. segments) before any root-containment comparison, in both extract_paths.go and rego.go. Change the root check from a bare string-prefix test to a proper path-boundary comparison, e.g. verify the cleaned candidate equals the root or starts with root + string(os.PathSeparator), never a same-string-prefix-without-separator match.
Unanchored prefix matching on uncleaned paths is a classic directory traversal bypass — /home/user/../etc/passwd matches a /home/user prefix but escapes the directory. I'll add path cleaning and anchored matching with a trailing separator check.
Activity
sharmis-tp commentedon Nov 18, 2026
Unanchored prefix matching on uncleaned paths is a classic directory traversal bypass —
/home/user/../etc/passwdmatches a/home/userprefix but escapes the directory. I'll add path cleaning and anchored matching with a trailing separator check.