subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
"""专门为老项目(使用 pkg_resources 的 setup.py)修复 setuptools 版本""" try: # 先强制修复损坏的 packaging 包(关键!解决无RECORD文件报错) subprocess.check_call([ sys.executable, "-m", "pip", "install", "--verbose", "--ignore-installed", "--no-deps", "packaging==26.1" ])- Confidence
- 90% confidence
- Finding
- This code automatically runs pip at import time to reinstall the packaging library, mutating the Python environment without user consent. Even though the command is statically defined, unsolicited dependency installation expands the attack surface and can destabilize or hijack the runtime if indexes, TLS trust, or package resolution are compromised.
