Tainted flow: 'output_file' from os.environ.get (line 134, credential/environment) → open (file write)
Medium
- Category
- Data Flow
- Content
# Default to ./investment_analysis/<fund_code>_analysis.md but allow override via env var base_path = os.environ.get('FUND_ANALYSIS_BASE_PATH', 'investment_analysis') output_file = Path('.') / base_path / f"{fund_code}_analysis.md" with open(output_file, 'w', encoding='utf-8') as f: f.write(report) print(f"报告已保存至: {output_file}")- Confidence
- 90% confidence
- Finding
- The script allows an environment variable to control the base output directory and then writes a file there without constraining or validating the path. In an agent or automation context, an attacker who can influence the environment can redirect output to unintended filesystem locations, causing arbitrary file overwrite within the executing user's permissions.
