T03 · Remote Payload Retrieval and Execution
Error
- Location
- scripts/install.py:129
- Finding
- Mutable Remote Executable Downloaded and Executed Without Integrity Verification<![CDATA[ ## Vulnerability Details **File Location**: `scripts/install.py:129-167` **Vulnerability Type**: Unverified remote executable retrieval and execution **Risk Level**: Critical ### Vulnerable Code ```python # Try fetching from GitHub API assets, tag = get_latest_release_assets() download_url = None if assets: for asset in assets: name = asset.get('name', '').lower() # Match keywords (e.g. 'win' or 'windows' for Windows, 'macos' for Mac, 'linux' for Linux) if asset_keyword in name: download_url = asset.get('browser_download_url') print(f"Found matching asset for version {tag}: {asset.get('name')}") break # Fallback to hardcoded URL patterns if API fails or asset not found if not download_url: print("Using hardcoded fallback download URL...") if system == "windows": download_url = "https://github.com/RollingGo-AI/oauth-hotel-cli/releases/latest/download/rgh-win.exe" elif system == "darwin": download_url = "https://github.com/RollingGo-AI/oauth-hotel-cli/releases/latest/download/rgh-macos" else: download_url = "https://github.com/RollingGo-AI/oauth-hotel-cli/releases/latest/download/rgh-linux" success = download_binary(download_url, dest_path) if not success and assets and system == "windows": # Extra fallback for windows naming differences (win vs windows) print("Retrying with alternative Windows asset name...") download_url = "https://github.com/RollingGo-AI/oauth-hotel-cli/releases/latest/download/rgh-windows.exe" success = download_binary(download_url, dest_path) if success: # Chmod on Linux/macOS if system != "windows": try: os.chmod(dest_path, 0o755) print("Permissions set to executable.") ``` The download function writes the HTTP response directly to the destination: ```python def download_binary(url, dest_path): """Download a file from url to dest_path with progress indication. ...[truncated 3378 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Pin the installer to an exact, reviewed release version instead of using `latest`. 2. Maintain an in-repository allowlist containing the exact expected filename, platform, architecture, version, and SHA-256 digest for every supported binary. 3. Verify the digest before granting executable permission or replacing an existing installation. 4. Prefer a signed release mechanism, such as Sigstore provenance or a detached signature verified against a pinned public key. 5. Match assets by exact filename and architecture; do not use substring matching. 6. Download to a newly created temporary file, validate it, set restrictive permissions, and atomically rename it into `bin` only after all checks succeed. 7. Apply explicit download-size and timeout limits. 8. Validate redirects and reject final download URLs outside an explicit trusted-host allowlist. 9. Preserve a previously verified binary if an update fails validation. 10. Remove the instruction requiring immediate automatic upgrades. Updates should require an independently verified release and explicit operator approval. ]]>
