T03 · Remote Payload Retrieval and Execution
- Location
scripts/ensure_env.py:278- Finding
Unverified Remote Python Bootstrap Is Downloaded and Executed
- Content
View full analysis
Vulnerability Details
File Location:
scripts/ensure_env.py:26, 278-294
Vulnerability Type: Unauthenticated remote code retrieval and execution
Risk Level: HighThe Skill documentation makes the environment check a prerequisite in
SKILL.md:71-78andSKILL.md:101-107. If both pip andensurepipare unavailable, that check downloads a Python program from the network and executes it.Relevant code:
python ssl._create_default_https_context = ssl._create_unverified_contextpython get_pip_path = os.path.join(tempfile.gettempdir(), "get-pip.py") urls = [ "https://mirrors.huaweicloud.com/repository/pypi/simple/get-pip.py", "https://bootstrap.pypa.io/get-pip.py", ] ctx = ssl._create_unverified_context() for url in urls: info(f"尝试下载 get-pip.py: {url}") try: urllib.request.urlretrieve(url, get_pip_path, context=ctx) except Exception as e: print(f" 下载失败: {e}") continue rc, out, err = run_cmd([sys.executable, get_pip_path], timeout=120) if rc == 0: ok("get-pip.py 安装 pip 成功") return TrueTechnical Analysis
The code explicitly creates an SSL context that does not verify certificates and also replaces Python's default HTTPS context with an unverified context. The downloaded file is not checked against a pinned hash or trusted signature before being passed to the Python interpreter.
This turns a network response into an executable code channel. HTTPS encryption alone does not provide server authenticity when certificate validation is disabled. A network-positioned attacker, malicious proxy, or DNS/network intermediary can therefore substitute arbitrary Python content.
The behavior is reachable through the documented setup flow when:
- The Skill's required environment check is invoked.
- The virtual environment does not have a working pip installation.
- `python -m ensurepip --upgrade ...[truncated 1281 chars]
- Remediation
View remediation
Remediation Suggestions
- Remove both uses of unverified SSL contexts:
python ssl._create_default_https_context = ssl._create_unverified_context ctx = ssl._create_unverified_context() - Use Python's verified default TLS context and system trust store.
- Prefer failing safely with manual installation instructions if
ensurepipis unavailable. - If remote bootstrap remains necessary, pin an expected SHA-256 digest or verify a trusted cryptographic signature before execution.
- Download to a securely created file with restrictive permissions and delete it after verification and use.
- Do not execute a fallback response merely because the download completed successfully.
- Remove both uses of unverified SSL contexts:
