Skip to main content

Python CVE-2026-40594

MEDIUM
Origin Validation Error (CWE-346)
2026-04-16 https://github.com/pyload/pyload GHSA-mp82-fmj6-f22v
4.8
CVSS 3.1 · Vendor: https://github.com/pyload/pyload
View

Attack ChainAIDerived

Hypothetical attack flow derived from CVE metadata – not a confirmed exploit chain

  1. Access
    Send concurrent requests with spoofed X-Forwarded-Proto
  2. Delivery
    Trigger race condition in before_request handler
  3. Exploit
    Mutate global SESSION_COOKIE_SECURE flag
  4. Execution
    Inject malicious cookie flags into legitimate user response
  5. Persist
    Browser receives insecure session cookie
  6. Impact
    Attacker captures plaintext cookie or session silently breaks

Vulnerability Assessment

Weakness
CWE
OWASP Top 10:2025
A07:2025 - Authentication Failures
ASVS 5.0
V6 - Authentication Origin validation
Exploitation Conditions

The vulnerability requires no special conditions to trigger in the default configuration. Exploitation paths differ by deployment: (1) For session downgrade (Attack Path 1): Deployment must use a TLS-terminating proxy in front of the pyLoad backend (use_ssl=False in config), AND the attacker must have network access to the backend listener (direct access or same cluster). The X-Forwarded-Proto header must be read by the before_request handler before the legitimate user's after_request handler runs (race window). (2) For session DoS (Attack Path 2): Deployment must use plain HTTP (default, use_ssl=False), AND the attacker must have network access to the pyLoad listener. No special configuration is required. Both attacks are fully unauthenticated-the before_request handler executes before authentication checks. Limiting factors: (a) Attack Path 1 requires attacker network position (container cluster or proxy bypass); (b) both attacks depend on multi-threaded request concurrency (Cheroot's default 512 queue size enables this, but single-threaded deployments would not be vulnerable to the race condition, though the header spoofing itself would still be possible); (c) browsers' cookie security model limits impact-Secure cookies are not sent over HTTP, and HttpOnly+SameSite may limit some attack variants.

Impact

The CVSS score of 4.8 with AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:L reflects network accessibility and no authentication requirement, but the AC:H (high complexity) understates real-world exploitability. The high complexity rating likely accounts for race condition timing requirements; however, the PoC demonstrates that sustained flooding (200 concurrent requests) reliably triggers the race window, making exploitation practical rather than theoretical. The vulnerability carries two distinct impacts: (1) confidentiality loss via session cookie downgrade when behind a TLS proxy (requires network position or direct backend access), and (2) availability loss via forced Secure flag on plain HTTP deployments (requires no special position-any attacker can reach the default HTTP listener). The AC:H rating is conservative; Attack Path 2 (session DoS on plain HTTP) is AC:L in practice because the attacker only needs to send repeated requests to an unauthenticated endpoint. The vulnerability is not listed in CISA KEV, but the GitHub security advisory confirms it is vendor-disclosed and reproducible. Attack automation is high (simple HTTP header manipulation), and technical impact is medium (session confidentiality or availability, not code execution). Under SSVC, this rates as moderate severity: exploitation is straightforward (no POC code required-curl alone suffices), automatable, but impact is bounded to session compromise rather than system-wide. Real-world priority depends on deployment model: containerized/Kubernetes setups with direct backend exposure face higher risk; single-node plain HTTP deployments face guaranteed session DoS if any attacker with network access sends crafted requests.

Exploit ScenarioDerived

An attacker in a Kubernetes cluster (or with direct network access to the pyLoad backend service) sends 200 concurrent HTTP requests with the X-Forwarded-Proto header set to 'http' while legitimate users simultaneously navigate the pyLoad web UI behind a TLS-terminating proxy. Due to the race condition, some legitimate users' responses include Set-Cookie headers without the Secure flag. If a victim's browser subsequently makes an HTTP request (via mixed-content or downgrade attack), the session cookie is sent in plaintext, allowing the attacker to capture and reuse it. Alternatively, on a plain HTTP deployment, the attacker sends concurrent requests with X-Forwarded-Proto: https, causing SESSION_COOKIE_SECURE to be set True; legitimate users' browsers then refuse to send cookies back to the server over HTTP, silently logging them out with no error message.

This Month Plan within 30 days. Why: MEDIUM severity (CVSS 4.0-6.9).
Patch available 0.0% exploitation probability (EPSS)

Get an e-mail when this CVE is exploited, patched or re-scored. Free account.

Alert me

AnalysisAIv1 – Apr 16, 2026

Race condition in pyLoad's Flask session cookie handler allows unauthenticated attackers to manipulate the SESSION_COOKIE_SECURE flag globally across all concurrent requests by spoofing the X-Forwarded-Proto header. On deployments behind a TLS-terminating proxy, this enables session cookie downgrade attacks resulting in plaintext cookie transmission; on default plain HTTP deployments, it causes session denial of service by forcing the Secure flag and breaking all concurrent user sessions. The vulnerability requires no authentication and exploits a multi-threaded race window in the Cheroot WSGI server (request_queue_size=512) combined with missing proxy origin validation (acknowledged TODO in code).

RemediationAI

The vendor-recommended fix is to replace global config mutation with per-response cookie handling combined with proxy validation. Immediate action: apply the vendor's patch (available in the GitHub advisory at https://github.com/pyload/pyload/security/advisories/GHSA-mp82-fmj6-f22v) which removes the race-prone before_request handler and uses either Werkzeug ProxyFix with explicit trusted proxy configuration or per-response Set-Cookie manipulation in an after_request handler. If patching is delayed, the most effective workaround is to disable the vulnerable before_request handler entirely by removing or commenting out the set_session_cookie_secure() function in src/pyload/webui/app/__init__.py and setting SESSION_COOKIE_SECURE once at application startup (the existing _configure_session() method already does this); this eliminates the race condition and header spoofing at the cost of losing dynamic SSL detection per-request (acceptable for most deployments where SSL mode does not change at runtime). For Kubernetes/container deployments, restrict network access to the pyLoad backend listener to only the TLS-terminating proxy; deny direct attacker access to port 8000. For plain HTTP deployments (no proxy), understand that SESSION_COOKIE_SECURE cannot be set True without breaking legitimate user sessions, so the security posture depends entirely on network isolation and HTTPS enforcement at the reverse proxy layer. Trade-off: the workaround prevents dynamic per-request SSL mode switching, so environments where users access both HTTP and HTTPS endpoints on the same deployment must be reconfigured to use a single protocol or accept cookies as session-only (HttpOnly flag sufficient without Secure on trusted networks).

Affected Packages

pypi pyload-ng fix: 0.5.0b3.dev69, 0.5.0b3.dev98

Source: OSV (Open Source Vulnerabilities)

Affects your stack

Affects 1 package in pypi

Checking this CVE against your own stacks and servers is part of the Basic plan and up.

Technical ContextAI · show details

pyLoad is a Python-based download manager that uses Flask for its web UI and Cheroot as its multi-threaded WSGI server. The vulnerability exists in the set_session_cookie_secure() before_request handler in src/pyload/webui/app/__init__.py, which reads the X-Forwarded-Proto header without validation and writes directly to Flask's global application configuration object (flask.current_app.config['SESSION_COOKIE_SECURE']). Because Cheroot processes requests concurrently (request_queue_size=512 threads), and Flask's session-save logic runs in the after_request phase on the same thread that processed the before_request phase, a crafted request from Thread A can modify global state before Thread B's after_request handler executes, causing Thread B's response to reflect Thread A's malicious configuration. The root cause is classified as CWE-346 (Origin Validation Error) combined with unsafe multi-threaded access to shared mutable state. No ProxyFix middleware or trusted proxy allowlist exists in the codebase to validate header origin.

Know when Python gets its next vulnerability

  • Watch products and get an email when something new is published
  • Check this CVE against your own stack and servers
  • Exploit and PoC references, threat intelligence from 22 sources

No credit card · 7-day full trial

Severity by source

Vendor (https://github.com/pyload/pyload) PRIMARY 4.8 MEDIUM
AV:N/AC:H/PR:N/UI:N/S:U/C:L/I:N/A:L

Primary rating from Vendor (https://github.com/pyload/pyload) · only source for this CVE.

CVSS VectorVendor: https://github.com/pyload/pyload

Attack Vector
Network
Attack Complexity
High
Privileges Required
None
User Interaction
None
Scope
Unchanged
Confidentiality
Low
Integrity
None
Availability
Low

Lifecycle Timeline

2
Patch released
Apr 16, 2026 - 02:30 nvd
Patch available
CVE Published
Apr 16, 2026 - 01:20 nvd
MEDIUM 4.8

DescriptionCVE.org

Summary

The set_session_cookie_secure before_request handler in src/pyload/webui/app/__init__.py reads the X-Forwarded-Proto header from any HTTP request without validating that the request originates from a trusted proxy, then mutates the global Flask configuration SESSION_COOKIE_SECURE on every request. Because pyLoad uses the multi-threaded Cheroot WSGI server (request_queue_size=512), this creates a race condition where an attacker's request can influence the Secure flag on other users' session cookies - either downgrading cookie security behind a TLS proxy or causing a session denial-of-service on plain HTTP deployments.

Details

The vulnerable code is in src/pyload/webui/app/__init__.py:75-84:

python
# Dynamically set SESSION_COOKIE_SECURE according to the value of X-Forwarded-Proto
# TODO: Add trusted proxy check
@app.before_request
def set_session_cookie_secure():
    x_forwarded_proto = flask.request.headers.get("X-Forwarded-Proto", "")
    is_secure = (
        x_forwarded_proto.split(',')[0].strip() == "https" or
        app.config["PYLOAD_API"].get_config_value("webui", "use_ssl")
    )
    flask.current_app.config['SESSION_COOKIE_SECURE'] = is_secure

The root cause has two components:

  1. No origin validation (CWE-346): The X-Forwarded-Proto header is read from any client request. This header is only trustworthy when set by a known reverse proxy. Without ProxyFix middleware or a trusted proxy allowlist, any client can spoof it. The code itself acknowledges this with the TODO on line 76.
  2. Global state mutation in a multi-threaded server: flask.current_app.config['SESSION_COOKIE_SECURE'] is application-wide shared state. When Thread A (attacker) writes False to this config, Thread B (victim) may read False when Flask's save_session() runs in the after_request phase, producing a Set-Cookie response without the Secure flag.

The Cheroot WSGI server is configured with request_queue_size=512 in src/pyload/webui/webserver_thread.py:46, confirming concurrent multi-threaded request processing.

No ProxyFix or equivalent middleware is configured anywhere in the codebase (confirmed via codebase-wide search).

PoC

Attack Path 1 - Cookie Security Downgrade (behind TLS-terminating proxy, use_ssl=False):

An attacker with direct access to the backend (e.g., in a containerized/Kubernetes deployment) sends concurrent requests to keep SESSION_COOKIE_SECURE set to False:

bash
# Attacker floods backend directly, bypassing TLS proxy
for i in $(seq 1 200); do
  curl -s -H 'X-Forwarded-Proto: http' http://pyload-backend:8000/ &
done
# Meanwhile, a legitimate user behind the TLS proxy receives a session cookie
# During the race window, their Set-Cookie header lacks the Secure flag
# The cookie is then vulnerable to interception over plain HTTP

Attack Path 2 - Session Denial of Service (default plain HTTP deployment):

bash
# Attacker causes SESSION_COOKIE_SECURE=True on a plain HTTP server
for i in $(seq 1 200); do
  curl -s -H 'X-Forwarded-Proto: https' http://localhost:8000/ &
done
# Concurrent legitimate users receive Set-Cookie with Secure flag
# Browser refuses to send Secure cookies over HTTP
# Users' sessions silently break - they appear logged out

The second attack path works against the default configuration (use_ssl=False) and requires no special network position.

Impact

  • Session cookie exposure (Attack Path 1): When deployed behind a TLS-terminating proxy, an attacker can cause session cookies to be issued without the Secure flag. If the victim's browser subsequently makes an HTTP request (e.g., via a mixed-content link or downgrade attack), the session cookie is transmitted in cleartext, enabling session hijacking.
  • Session denial of service (Attack Path 2): On default plain HTTP deployments, an attacker can continuously set SESSION_COOKIE_SECURE=True, causing browsers to refuse sending session cookies back to the server. This silently breaks all concurrent users' sessions with no user-visible error message, only a redirect to login.
  • No authentication required: Both attack paths are fully unauthenticated - the before_request handler fires before any auth checks.

Recommended Fix

Replace the global config mutation with per-response cookie handling, and add proxy validation:

python
# Option A: Set Secure flag per-response instead of mutating global config
@app.after_request
def set_session_cookie_secure(response):
# Only trust X-Forwarded-Proto if ProxyFix is configured
    is_secure = app.config["PYLOAD_API"].get_config_value("webui", "use_ssl")
    if 'Set-Cookie' in response.headers:
# Modify cookie flags per-response, not global config
        cookies = response.headers.getlist('Set-Cookie')
        response.headers.remove('Set-Cookie')
        for cookie in cookies:
            if is_secure and 'Secure' not in cookie:
                cookie += '; Secure'
            response.headers.add('Set-Cookie', cookie)
    return response
# Option B (preferred): Use Werkzeug's ProxyFix with explicit trust
from werkzeug.middleware.proxy_fix import ProxyFix
# In App.__new__, before returning:
if trusted_proxy_count:
# from config
    app.wsgi_app = ProxyFix(app.wsgi_app, x_proto=trusted_proxy_count)
# Then set SESSION_COOKIE_SECURE once at startup based on use_ssl config,
# and let ProxyFix handle X-Forwarded-Proto transparently

At minimum, remove the before_request handler entirely and set SESSION_COOKIE_SECURE once at startup (line 130 already does this in _configure_session). The dynamic per-request adjustment is the root cause of both the spoofing and the race condition.

Threat Intelligence Overview

EPSS Score
0.0%
Top 100% exploitable
Threat Intel
1
1 source
Data Quality
5 sources
Confidence: Medium
NVD CVE.org EPSS Vulnrichment GHSA GitHub VulDB

How this decision was reached

The engine reads each signal below and applies a fixed list of rules from top to bottom. The first rule that matches sets the recommended action – like a statement, every line is shown.

SignalValue
Severity MEDIUM
CISA KEV No
Public POC No
EPSS 0.0%
Patch available Yes
Active threat No
Deciding rule
MEDIUM severity (CVSS 4.0-6.9)
What every action level means
Emergency Immediate action required. Criteria: CRITICAL + in CISA KEV (actively exploited) without patch, OR CRITICAL + EPSS > 30% without patch, OR CRITICAL + active threat signals without patch.
Act Now Prioritize within 24-48h. Criteria: in KEV with patch available, OR CRITICAL + public POC, OR HIGH + EPSS > 10%, OR CRITICAL + active threat, OR any CRITICAL severity.
This Week Schedule remediation this week. Criteria: HIGH severity (CVSS 7.0-8.9). Patch within normal change window.
This Month Plan within 30 days. Criteria: MEDIUM severity (CVSS 4.0-6.9), lower exploitation probability. Include in regular patch cycle.
Monitor Track and reassess. Criteria: LOW severity (CVSS 0.1-3.9), minimal exploitation risk. No immediate action needed.

SSVC AssessmentENISA

SSVC Decision· derived
Scheduled
Exploitation
Poc
System Exposure· derived
Open
Automatable
No
Human Impact· derived
Medium
Technical Impact
Partial

Priority Score

24
Low Medium High Critical
KEV: 0
EPSS: 0
CVSS: +24
PoC: 0
Weaponized: 0
Threat intel: 0
Gov advisory: 0

Attack Technique

Denial of Service attacks render applications or systems unavailable by overwhelming resources or triggering failure conditions.

Affected Products (CPE)CVE.org

pkg:pip/pyload-ng

More in Python

View all
CVE-2025-24016 CRITICAL POC
9.9 Feb 10

Wazuh SIEM platform versions 4.4.0 through 4.9.0 contain an unsafe deserialization vulnerability in the DistributedAPI t

CVE-2025-27520 CRITICAL POC
9.8 Apr 04

BentoML version 1.4.2 and earlier contains an unauthenticated remote code execution vulnerability through insecure deser

CVE-2025-2945 CRITICAL POC
9.9 Apr 03

pgAdmin 4 contains critical remote code execution vulnerabilities in the Query Tool download and Cloud Deployment endpoi

CVE-2013-5093 MEDIUM POC
6.8 Sep 27

The renderLocalView function in render/views.py in graphite-web in Graphite 0.9.5 through 0.9.10 uses the pickle Python

CVE-2025-32375 CRITICAL POC
9.8 Apr 09

BentoML is a Python library for building online serving systems optimized for AI apps and model inference. Rated critica

CVE-2014-0224 HIGH POC
7.4 Jun 05

OpenSSL before 0.9.8za, 1.0.0 before 1.0.0m, and 1.0.1 before 1.0.1h does not properly restrict processing of ChangeCiph

CVE-2024-21644 HIGH POC
7.5 Jan 08

pyLoad download manager version prior to 0.5.0b3.dev77 exposes the Flask SECRET_KEY through an unauthenticated endpoint.

CVE-2026-33017 CRITICAL POC
9.3 Mar 17

Langflow (a visual LLM pipeline builder) contains a critical unauthenticated code execution vulnerability (CVE-2026-3301

CVE-2017-9462 HIGH POC
8.8 Jun 06

In Mercurial before 4.1.3, "hg serve --stdio" allows remote authenticated users to launch the Python debugger, and conse

CVE-2026-49869 CRITICAL POC
10.0 Jun 26

Unauthenticated remote code execution affects Kestra OSS (the open-source event-driven orchestration platform) prior to

CVE-2026-39987 CRITICAL POC
9.3 Apr 08

Unauthenticated remote code execution in Marimo ≤0.20.4 allows attackers to execute arbitrary system commands via the `/

CVE-2024-21645 MEDIUM POC
5.3 Jan 08

pyLoad is the free and open-source Download Manager written in pure Python. Rated medium severity (CVSS 5.3), this vulne

This site uses cookies essential for authentication and security. No tracking or analytics cookies are used. Privacy Policy