subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
def _get_ws_url(self, tab_id: str, host: str = "127.0.0.1", port: int = 9222) -> Optional[str]: """通过 JSON API 获取 Tab 的 WebSocket URL""" try: result = subprocess.run( ['powershell', '-Command', f'(Invoke-RestMethod http://{host}:{port}/json).webSocketDebuggerUrl'], capture_output=True, text=True, timeout=5 )- Confidence
- 87% confidence
- Finding
- This subprocess call builds a PowerShell command string with interpolated host and port values. If those parameters are ever influenced by untrusted input, an attacker could inject additional PowerShell syntax and execute arbitrary local commands. In this skill, the defaults are localhost-oriented, but the helper is generic and exposes an unnecessary command-construction surface.
