# CVE-2026-40606: mitmproxy LDAP injection in LDAP proxy authentication

Source: https://junglewise.ai/threats/cve-2026-40606-mitmproxy-ldap-injection-in-ldap-proxy-authentication  
Publisher: Junglewise Threat Intelligence, https://junglewise.ai/threats  
Published: 2026-04-21. Updated: 2026-06-06  
License: CC BY 4.0 with a link back

CVE-2026-40606 · Severity: medium · CVSS 4.8 · Published 2026-04-21

mitmproxy is an open-source tool used for intercepting and analyzing web traffic. A security flaw in its LDAP authentication module allows unauthorized users to bypass login requirements by providing specially crafted usernames. This could allow an attacker to use the proxy without permission, potentially masking their identity or accessing restricted network resources.

Technologies: [mitmproxy (PyPI)](https://junglewise.ai/threats/technologies/mitmproxy). Vendors: [PyPI](https://junglewise.ai/threats/vendors/pypi).

## Quick answers

**Is CVE-2026-40606 exploited in the wild?** No. Junglewise Threat Intelligence has no report of CVE-2026-40606 being exploited in the wild.

**How severe is CVE-2026-40606?** Medium severity, with a CVSS score of 4.8, published 21 April 2026.

**Which products and versions are affected?** mitmproxy (PyPI) <= 12.2.1, ECOSYSTEM:introduced=0,fixed=12.2.2.

**Is there a fix for CVE-2026-40606?** Yes. mitmproxy (PyPI): upgrade to 12.2.2 or later. Junglewise finds every place you run it, drafts the upgrade and applies it once you approve.

**How is CVE-2026-40606 attacked?** It is attacked over the network, in a software library.

**Am I affected by CVE-2026-40606?** Check whether you run Mitmproxy or mitmproxy (PyPI) at an affected version. Junglewise does that check for you around the clock: connect your code, cloud and domains, and it matches new vulnerabilities like this one against what you actually run and tells you when one reaches you.

## How to fix

- mitmproxy (PyPI): upgrade to 12.2.2 or later

  ```sh
  pip install "mitmproxy>=12.2.2"
  ```


## Technical details

An LDAP injection vulnerability (CWE-90) exists in mitmproxy versions 12.2.1 and below. The root cause is the improper neutralization of special characters in the username field when constructing LDAP queries for proxy authentication. A remote attacker can exploit this by providing a malicious username that alters the logic of the LDAP query, leading to an authentication bypass. This vulnerability only affects instances where the 'proxyauth' option is explicitly configured to use LDAP. The issue is resolved in version 12.2.2.

## Affected products

- mitmproxy mitmproxy <= 12.2.1

## Identifiers

- CVE-2026-40606
- GHSA-527g-3w9m-29hv
- PYSEC-2026-92

## Timeline

- 2025-12-08: disclosed: Initial report received from researcher
- 2026-04-12: patched: Patch and advisory published
- 2026-04-14: advisory: GitHub Advisory published

## References

- [https://api.github.com/users/yueyueL](https://api.github.com/users/yueyueL)
- [https://github.com/yueyueL](https://github.com/yueyueL)
- [https://api.github.com/users/yueyueL/gists%7B/gist_id%7D](https://api.github.com/users/yueyueL/gists%7B/gist_id%7D)
- [https://api.github.com/users/yueyueL/repos](https://api.github.com/users/yueyueL/repos)
- [https://avatars.githubusercontent.com/u/64764840?v=4](https://avatars.githubusercontent.com/u/64764840?v=4)
- [https://api.github.com/users/yueyueL/events%7B/privacy%7D](https://api.github.com/users/yueyueL/events%7B/privacy%7D)

## Related threats

- [PYSEC-2026-1630 - Mitmweb API Authentication Bypass Using Proxy Server](https://junglewise.ai/threats/cve-2025-23217-mitmweb-api-authentication-bypass-using-proxy-server)
- [mitmproxy binaries embed a vulnerable python-hyper/h2 dependency](https://junglewise.ai/threats/mitmproxy-binaries-embed-a-vulnerable-python-hyper-h2-dependency-e14cde4e)
- [Insufficient Protection against HTTP Request Smuggling in mitmproxy](https://junglewise.ai/threats/cve-2022-24766-insufficient-protection-against-http-request-smuggling-in)
- [mitmproxy HTTP request smuggling](https://junglewise.ai/threats/cve-2021-39214-mitmproxy-http-request-smuggling)
- [PYSEC-2018-56 - mitmweb in mitmproxy v4.0.3 allows DNS Rebinding attacks, related to tools/web/app.py.](https://junglewise.ai/threats/cve-2018-14505-mitmweb-in-mitmproxy-allows-dns-rebinding-attacks)
