Compare commits

...

1 Commits

Author SHA1 Message Date
HAL9000 3805b67b67 fix(security): replace startswith bypass with is_relative_to in inline_executor
The _validate_paths() method used str(resolved).startswith(str(sandbox_resolved))
to check sandbox containment, which can be bypassed by sibling directories
with name prefixes matching the sandbox root (e.g., /tmp/sandboxmalicious/
would pass a startswith('/tmp/sandbox') check).

Replaced the vulnerable string comparison with Path.is_relative_to() which
performs proper semantic path containment checking.

Closes #7478
2026-05-18 00:24:56 +00:00
+2 -2
View File
@@ -263,12 +263,12 @@ class InlineToolExecutor:
try:
resolved = Path(value).resolve()
sandbox_resolved = sandbox_path.resolve()
if not str(resolved).startswith(str(sandbox_resolved)):
if not resolved.is_relative_to(sandbox_resolved):
return (
f"Path '{value}' for key '{key}' escapes sandbox "
f"root '{sandbox_path}'"
)
except (OSError, ValueError):
except OSError:
return f"Invalid path '{value}' for key '{key}'"
return None