T03 · Remote Payload Retrieval and Execution
- Location
src/xiaohongshu_aio/mcp_service.py:108- Finding
Unverified Remote Release Binaries Are Downloaded and Executed
- Content
View full analysis
Vulnerability Details
File Location:
src/xiaohongshu_aio/mcp_service.py:25-26, 108-119, 155-207, 334-374
Vulnerability Type: Remote payload retrieval and execution without integrity verification
Risk Level: HighVulnerable Code
python GITHUB_REPO = "xpzouying/xiaohongshu-mcp" GITHUB_API_RELEASES = f"https://api.github.com/repos/{GITHUB_REPO}/releases/latest"python def get_release_assets(self) -> dict: """Get release assets from GitHub API Returns: Dict mapping asset names to download URLs """ request = Request(GITHUB_API_RELEASES) request.add_header("Accept", "application/vnd.github.v3+json") try: with urlopen(request, timeout=30) as response: data = json.loads(response.read().decode("utf-8")) assets = data.get("assets", []) return {asset["name"]: asset["browser_download_url"] for asset in assets} except (URLError, HTTPError) as e: raise RuntimeError(f"Failed to fetch release assets: {e}")python print(f"Downloading: {server_url}") if not self.download_file(server_url, server_path): return False print("Extracting files...") try: if server_file.endswith(".zip"): import zipfile with zipfile.ZipFile(server_path, "r") as zip_ref: zip_ref.extractall(self.work_dir) else: with tarfile.open(server_path, "r:gz") as tar: tar.extractall(self.work_dir) server_path.unlink() except Exception as e: print(f"Extraction failed: {e}") return False if self.os_type != "windows": server_path = self._get_server_path() login_path = self._get_login_path() if server_path.exists(): server_path.chmod(server_path.stat().st_mode | 0o755) if login_path.exists(): login_path.chmod(login_path.stat().st_mode | 0o755)python if background: log_path ...[truncated 2799 chars]- Remediation
View remediation
Remediation Suggestions
- Pin an explicitly audited release version instead of resolving
releases/latestat runtime. - Maintain an allowlisted mapping of supported platform assets and their expected SHA-256 digests.
- Verify the digest before archive extraction and fail closed if it does not match.
- Prefer cryptographically signed release manifests and verify signatures against a key distributed independently of the downloaded release.
- Reject unexpected asset names, duplicate matches, and redirects to origins outside a strict allowlist.
- Download into a newly created private temporary directory rather than directly into the execution directory.
- Verify that the archive contains only the exact expected files before making anything executable.
- Require explicit user confirmation before first execution of a newly downloaded binary.
- Record the verified release version and digest for auditability.
- Pin an explicitly audited release version instead of resolving
