Tainted flow: 'safe_output' from os.getenv (line 208, credential/environment) → shutil.copy (file write)
Medium
- Category
- Data Flow
- Content
import shutil safe_output = os.path.join(workspace_path, "outputs", os.path.basename(args.output)) os.makedirs(os.path.dirname(safe_output), exist_ok=True) shutil.copy(args.output, safe_output) args.output = safe_output print(f"Copied to allowed directory: {safe_output}")- Confidence
- 71% confidence
- Finding
- The destination path for shutil.copy is derived from OPENCLAW_WORKSPACE without validation, so a malicious or untrusted environment value can redirect file writes outside the intended workspace. In agent or multi-tenant execution contexts, trusting environment-controlled filesystem roots can enable unauthorized file creation or overwrite in attacker-chosen locations.
