subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
chrome = shutil.which('google-chrome-stable') or shutil.which('google-chrome') or shutil.which('chromium') or shutil.which('chromium-browser') if not chrome: return False, 'No Chrome/Chromium binary found' subprocess.run([chrome, '--headless', '--disable-gpu', '--no-sandbox', f'--print-to-pdf={pdf_path}', html_path.resolve().as_uri()], check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) return True, None- Confidence
- 87% confidence
- Finding
- The script launches a local Chrome/Chromium process to render a generated HTML file into PDF, and the HTML content is built from untrusted JSON fields such as stock names, combo names, title, and note without any output escaping. Even though shell injection is avoided by using an argument list, malicious HTML can still be embedded into the report and then processed by a powerful browser in headless mode; combined with the explicit '--no-sandbox' flag, this increases the risk of browser-based code execution or local file/network access if hostile content is supplied.
