T03 · Remote Payload Retrieval and Execution
Error
- Location
- docx_engine.py:209
- Finding
- Automatic Retrieval and Execution of an Unpinned Remote .NET Installer<![CDATA[ ## Vulnerability Details **File Location**: `docx_engine.py`, lines 209-265 **Vulnerability Type**: Unverified remote code retrieval and execution **Risk Level**: High ### Vulnerable Code ```python def provision_dotnet() -> Optional[Path]: """Download and install .NET SDK automatically. Returns: Path to the installed binary, or None on failure. """ os_type = platform.system() channel = required_dotnet_channel() print(" Acquiring .NET SDK...") try: if os_type == "Windows": installer_url = "https://dot.net/v1/dotnet-install.ps1" target_dir = Path.home() / ".dotnet" powershell_script = f""" $ErrorActionPreference = 'Stop' [Net.ServicePointManager]::SecurityProtocol = [Net.SecurityProtocolType]::Tls12 $installer = Invoke-WebRequest -Uri '{installer_url}' -UseBasicParsing $execution = [scriptblock]::Create($installer.Content) & $execution -Channel {channel} -InstallDir '{target_dir}' """ subprocess.run( ["powershell", "-Command", powershell_script], capture_output=True, text=True, timeout=300 ) binary = target_dir / "dotnet.exe" else: installer_url = "https://dot.net/v1/dotnet-install.sh" target_dir = Path.home() / ".dotnet" installer_path = Path(tempfile.gettempdir()) / "dotnet-bootstrap.sh" subprocess.run( ["curl", "-sSL", installer_url, "-o", str(installer_path)], check=True, timeout=60 ) installer_path.chmod(0o755) subprocess.run( [str(installer_path), "--channel", channel, "--install-dir", str(target_dir)], check=True, timeout=300 ) binary = target_dir / "dotnet" if binary.exists(): verify = subprocess.run([str(binary), "--version"] ...[truncated 3247 chars]
- Remediation
- <![CDATA[ ## Remediation Suggestions 1. Remove automatic download-and-execute behavior from normal document operations. 2. Treat a missing or incompatible runtime as a diagnostic error and provide manual installation instructions. 3. If automated provisioning is essential: - Download a versioned, immutable artifact rather than a mutable bootstrap URL. - Pin the exact .NET SDK version. - Verify a hardcoded SHA-256 or stronger digest before execution. - Validate an official digital signature where supported. - Abort on any integrity or signature mismatch. 4. Require explicit, informed user approval before making network requests or executing an installer. 5. Run provisioning in a sandbox with restricted filesystem access, no document access, and no inherited secrets. 6. On Unix-like systems, use a securely created private temporary directory and an unpredictable filename rather than a fixed path in the shared temporary directory. 7. Do not automatically delete an installation merely because the runtime probe reports corruption. Quarantine it or request user intervention. 8. Log the exact URL, resolved SDK version, expected digest, actual digest, and verification result for auditability. ]]>
