Tainted flow: 'outpath' from os.environ.get (line 225, credential/environment) → open (file write)
Medium
- Category
- Data Flow
- Content
profile = await download_attachment(a["url"]) if profile: outpath = PROFILES_DIR / a["filename"] with open(outpath, "w") as f: json.dump(profile, f, indent=2) print(f" ✅ {a['filename']}: {summarize_profile(profile)}") print(f" → {outpath}")- Confidence
- 92% confidence
- Finding
- The output path is influenced by the environment-controlled PROFILES_DIR and an untrusted Discord attachment filename. Because the code joins them directly and writes with open(), a crafted filename containing path traversal sequences or absolute-path semantics can cause files to be written outside the intended directory, potentially overwriting arbitrary user-accessible files.
