Tainted flow: 'ENV_FILE' from os.environ.get (line 41, credential/environment) → open (file write)
Medium
- Category
- Data Flow
- Content
ensure_dirs() if os.path.exists(ENV_FILE): return with open(ENV_FILE, "w", encoding="utf-8") as f: f.write(ENV_TEMPLATE) print( f"📝 已创建配置文件:{ENV_FILE}\n"- Confidence
- 83% confidence
- Finding
- The path used for ENV_FILE is derived from PROJECT_ROOT, which can be controlled via an environment variable. If an attacker can influence PROJECT_ROOT, the code will create or overwrite a .env file at an attacker-chosen filesystem location, enabling arbitrary file write within the agent's permissions. In an agent context that commonly runs with access to project workspaces and secrets, this is a real path-traversal/arbitrary-write risk rather than a purely theoretical issue.
