Composio powers 1000+ toolkits, tool search, context management, authentication, and a sandboxed workbench to help you build AI agents that turn intent into action.
Mirrored from https://github.com/Camo67/composio.git
Synced Nov 21, 22:15 UTC
refactor(security): run SEC-316 containment check before mkdir
Reorder `FileDownloadable.download()` so the `is_relative_to()` containment check fires before `outdir.mkdir(parents=True)`, so a rejected payload doesn't leave the cache directory tree created as a side effect. `Path.resolve(strict=False)` (Python's default) resolves non-existent paths logically, so the check is well-defined without the directory existing first. No behavior change for accepted payloads.
jkomyno committed
May 6, 2026 at 11:49 UTC
b6eeb8528748709013091c881c6212e961c8f197
1 file changed
+1
-1
python/composio/core/models/_files.py
+1
-1
@@ -554,12 +554,12 @@ class FileDownloadable(BaseModel):
554
# name like `output_evil/foo` (sibling-prefix attack) is also rejected.
555
safe_name = Path(self.name).name
556
outfile = outdir / safe_name
557
- outdir.mkdir(exist_ok=True, parents=True)
557
if not outfile.resolve().is_relative_to(outdir.resolve()):
558
raise ErrorDownloadingFile(
559
f"Path traversal detected: filename '{self.name}' resolves "
560
"outside the intended output directory."
561
)
562
+ outdir.mkdir(exist_ok=True, parents=True)
563
response = requests.get(url=self.s3url, stream=True)
564
if response.status_code != 200:
565
raise ErrorDownloadingFile(f"Error downloading file: {self.s3url}")