Tainted flow: 'output_file' from input (line 228, user input) → open (file write)
Medium
- Category
- Data Flow
- Content
output_dir = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) output_file = os.path.join(output_dir, f"讲解词_{relic_name}.txt") with open(output_file, "w", encoding="utf-8") as f: f.write(narration) return output_file- Confidence
- 97% confidence
- Finding
- The output filename is derived directly from the user-controlled relic_name and passed to open() for writing without sanitization. An attacker can supply path traversal sequences or absolute/relative path components to overwrite arbitrary files accessible to the current user, making this more serious because the script writes to disk automatically in the project parent directory.
