CVE-2025-61911: python-ldap has sanitization bypass in ldap.filter.escape_filter_chars

Published Oct 10, 2025
·
Updated

Summary The sanitization method ldap.filter.escapefilterchars can be tricked to skip escaping of special characters when a crafted list or dict is supplied as the assertionvalue parameter, and the non-default escapemode=1 is configured.

Details The method ldap.filter.escapefilterchars supports 3 different escaping modes. escapemode=0 (default) and escapemode=2 happen to raise exceptions when a list or dict object is supplied as the assertionvalue parameter. However, escapemode=1 happily computes without performing adequate logic to ensure a fully escaped return value.

PoC >>> import ldap.filter Exploitable >>> ldap.filter.escapefilterchars(["abc@()/xyz"], escapemode=1) 'abc@()/xyz' >>> ldap.filter.escapefilterchars({"abc@()/xyz": 1}, escapemode=1) 'abc@()/xyz' Not exploitable >>> ldap.filter.escapefilterchars("abc@()/xyz", escapemode=1) 'abc@\\2a\\28\\29\\2fxyz' >>> ldap.filter.escapefilterchars(["abc@()/xyz"], escapemode=0) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib64/python3.12/site-packages/ldap/filter.py", line 41, in escapefilterchars s = assertionvalue.replace('\\', r'\5c') ^^^^^^^^^^^^^^^^^^^^^^^ AttributeError: 'list' object has no attribute 'replace' >>> ldap.filter.escapefilterchars(["abc@()/xyz"], escapemode=2) Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib64/python3.12/site-packages/ldap/filter.py", line 36, in escapefilterchars r.append("\\%02x" % ord(c)) ^^^^^^ TypeError: ord() expected a character, but string of length 11 found Impact If an application relies on the vulnerable method in the python-ldap library to escape untrusted user input, an attacker might be able to abuse the vulnerability to launch ldap injection attacks which could potentially disclose or manipulate ldap data meant to be inaccessible to them.

With Python being a dynamically typed language, and the commonly used JSON format supporting list and dict, it is to be expected that Python applications may commonly forward unchecked and potentially malicious list and dict objects to the vulnerable sanitization method.

The vulnerable escapemode=1 configuration does not appear to be widely used.

Suggested Fix Add a type check at the start of the ldap.filter.escapefilterchars method to raise an exception when the supplied assertionvalue parameter is not of type str.

Other sources

python-ldap is a lightweight directory access protocol (LDAP) client API for Python. In versions prior to 3.4.5, the sanitization method ldap.filter.escapefilterchars can be tricked to skip escaping of special characters when a crafted list or dict is supplied as the assertionvalue parameter, and the non-default escapemode=1 is configured. The method ldap.filter.escapefilterchars supports 3 different escaping modes. escapemode=0 (default) and escapemode=2 happen to raise exceptions when a list or dict object is supplied as the assertionvalue parameter. However, escapemode=1 computes without performing adequate logic to ensure a fully escaped return value. If an application relies on the vulnerable method in the python-ldap library to escape untrusted user input, an attacker might be able to abuse the vulnerability to launch ldap injection attacks which could potentially disclose or manipulate ldap data meant to be inaccessible to them. Version 3.4.5 fixes the issue by adding a type check at the start of the ldap.filter.escapefilterchars method to raise an exception when the supplied assertionvalue parameter is not of type str.

MITRE

Affected Software

3 affected componentsFixes available
python-ldap python-ldap<3.4.5
pip/python-ldap<3.4.5
3.4.5
python-ldap python-ldap<3.4.5

Event History

Oct 10, 2025
CVE Published
via MITRE·10:02 PM
Data Sourced
via MITRE·10:02 PM
DescriptionWeakness
Data Sourced
via NVD·10:15 PM
DescriptionSeverityWeakness
Data Sourced
via NVD·10:15 PM
RemedyAffected Software
Advisory Published
via GitHub·10:51 PM
Data Sourced
via GitHub·10:51 PM
DescriptionWeaknessAffected Software
Free Weekly Intel

Don't miss critical vulnerabilities

Join thousands of security professionals who receive our weekly digest of trending CVEs, zero-days, and exploited vulnerabilities.

No spam. Unsubscribe anytime.

Frequently Asked Questions

1

What is the severity of CVE-2025-61911?

The severity of CVE-2025-61911 is currently classified as moderate.

2

How do I fix CVE-2025-61911?

To fix CVE-2025-61911, upgrade to python-ldap version 3.4.5 or later.

3

What causes CVE-2025-61911?

CVE-2025-61911 is caused by a flaw in the `ldap.filter.escape_filter_chars` method that can be exploited with crafted input.

4

Which software is affected by CVE-2025-61911?

CVE-2025-61911 affects python-ldap versions prior to 3.4.5.

5

Is CVE-2025-61911 critical?

CVE-2025-61911 is not classified as critical but it poses a risk due to potential exploitation.

Contact

SecAlerts Pty Ltd.
132 Wickham Terrace
Fortitude Valley,
QLD 4006, Australia
info@secalerts.co
By using SecAlerts services, you agree to our services end-user license agreement. This website is safeguarded by reCAPTCHA and governed by the Google Privacy Policy and Terms of Service. All names, logos, and brands of products are owned by their respective owners, and any usage of these names, logos, and brands for identification purposes only does not imply endorsement. If you possess any content that requires removal, please get in touch with us.
© 2026 SecAlerts Pty Ltd.
ABN: 70 645 966 203, ACN: 645 966 203