subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
for output_dir in [output_dir_en, output_dir_cn]: for f in sorted(os.listdir(output_dir)): if f.endswith('.pdf'): subprocess.run(['open', os.path.join(output_dir, f)], check=False) print("完成!")- Confidence
- 88% confidence
- Finding
- The script launches every discovered PDF using the local OS 'open' handler via subprocess. Although it avoids shell injection by passing an argument list, it still executes an external program on files found in a directory, which can trigger unsafe file handling, unexpected application launches, or exploitation of vulnerable PDF viewers if an attacker can place a crafted file in that output directory.
