CVE-2025-61911: Python ldap Python-ldap Has Sanitization Bypass Vulnerability
MODERATECVE-2025-61911 is a MODERATE python-ldap has sanitization bypass vulnerability (CWE-843: Access of Resource Using Incompatible Type ('Type Confusion')) affecting Python ldap libraries in the PyPI ecosystem. The issue involves python-ldap has sanitization bypass in ldap.filter.escape_filter_chars. Remediation is available by upgrading affected packages to version 3.4.5.
CVE-2025-61911 at a Glance
How to Fix CVE-2025-61911
To remediate this vulnerability, upgrade all affected Python ldap dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.
pip install python-ldap>=3.4.5
Run the following command in your project directory to verify that all resolved dependencies use the patched release:
pip show python-ldap
How to Check if You Are Affected
To determine whether your Python environment is affected by CVE-2025-61911, inspect your installed packages using pip:
pip show python-ldap
Analyze the terminal output to locate any version of Python ldap in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.4.5), your application is affected.
Note: The pip show python-ldap command checks currently installed packages in your active Python environment.
Technical Details
Vulnerability Mechanism & Technical Analysis
This vulnerability is classified under CWE-843: Access of Resource Using Incompatible Type ('Type Confusion'), where the product allocates or initializes a resource such as a pointer, object, or variable using one type, but it later accesses that resource using a type that is incompatible with the original type. In Python ldap, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.
Source Advisory Statement
CVE-2025-61911 Affected Python ldap Versions
1 component(s)| Product / Package | Ecosystem | Affected Versions | Fixed Version |
|---|---|---|---|
|
python-ldap
|
PyPI |
< 3.4.5
|
3.4.5
|
References
Frequently Asked Questions
What is CVE-2025-61911?
Which Python ldap versions are affected?
What version fixes CVE-2025-61911?
Is python-ldap affected?
What CWE is associated with CVE-2025-61911?
How can I check PyPI dependencies for CVE-2025-61911?
Machine-readable OSV JSON
OSV v1.5 Schema
{
"schema_version" : "1.4.0",
"id" : "GHSA-r7r6-cc7p-4v5m",
"modified" : "2025-10-13T15:47:36Z",
"published" : "2025-10-10T22:51:28Z",
"aliases" : [ "CVE-2025-61911" ],
"summary" : "python-ldap has sanitization bypass in ldap.filter.escape_filter_chars",
"details" : "### Summary\nThe sanitization method `ldap.filter.escape_filter_chars` can be tricked to skip escaping of special characters when a crafted `list` or `dict` is supplied as the `assertion_value` parameter, and the non-default `escape_mode=1` is configured.\n\n### Details\nThe method `ldap.filter.escape_filter_chars` supports 3 different escaping modes. `escape_mode=0` (default) and `escape_mode=2` happen to raise exceptions when a `list` or `dict` object is supplied as the `assertion_value` parameter. However, `escape_mode=1` happily computes without performing adequate logic to ensure a fully escaped return value.\n\n### PoC\n```\n>>> import ldap.filter\n```\n**Exploitable**\n```\n>>> ldap.filter.escape_filter_chars([\"abc@*()/xyz\"], escape_mode=1)\n'abc@*()/xyz'\n>>> ldap.filter.escape_filter_chars({\"abc@*()/xyz\": 1}, escape_mode=1)\n'abc@*()/xyz'\n```\n**Not exploitable**\n```\n>>> ldap.filter.escape_filter_chars(\"abc@*()/xyz\", escape_mode=1)\n'abc@\\\\2a\\\\28\\\\29\\\\2fxyz'\n>>> ldap.filter.escape_filter_chars([\"abc@*()/xyz\"], escape_mode=0)\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n File \"/usr/local/lib64/python3.12/site-packages/ldap/filter.py\", line 41, in escape_filter_chars\n s = assertion_value.replace('\\\\', r'\\5c')\n ^^^^^^^^^^^^^^^^^^^^^^^\nAttributeError: 'list' object has no attribute 'replace'\n>>> ldap.filter.escape_filter_chars([\"abc@*()/xyz\"], escape_mode=2)\nTraceback (most recent call last):\n File \"<stdin>\", line 1, in <module>\n File \"/usr/local/lib64/python3.12/site-packages/ldap/filter.py\", line 36, in escape_filter_chars\n r.append(\"\\\\%02x\" % ord(c))\n ^^^^^^\nTypeError: ord() expected a character, but string of length 11 found\n```\n### Impact\nIf 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.\n\nWith 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.\n\nThe vulnerable `escape_mode=1` configuration does not appear to be widely used.\n\n### Suggested Fix\nAdd a type check at the start of the `ldap.filter.escape_filter_chars` method to raise an exception when the supplied `assertion_value` parameter is not of type `str`.",
"severity" : [ {
"type" : "CVSS_V4",
"score" : "CVSS:4.0/AV:N/AC:L/AT:N/PR:N/UI:N/VC:L/VI:L/VA:N/SC:N/SI:N/SA:N/E:P"
} ],
"affected" : [ {
"package" : {
"ecosystem" : "PyPI",
"name" : "python-ldap"
},
"ranges" : [ {
"type" : "ECOSYSTEM",
"events" : [ {
"introduced" : "0"
}, {
"fixed" : "3.4.5"
} ]
} ]
} ],
"references" : [ {
"type" : "WEB",
"url" : "https://github.com/python-ldap/python-ldap/security/advisories/GHSA-r7r6-cc7p-4v5m"
}, {
"type" : "ADVISORY",
"url" : "https://nvd.nist.gov/vuln/detail/CVE-2025-61911"
}, {
"type" : "WEB",
"url" : "https://github.com/python-ldap/python-ldap/commit/3957526fb1852e84b90f423d9fef34c7af25b85a"
}, {
"type" : "PACKAGE",
"url" : "https://github.com/python-ldap/python-ldap"
}, {
"type" : "WEB",
"url" : "https://github.com/python-ldap/python-ldap/releases/tag/python-ldap-3.4.5"
} ],
"database_specific" : {
"cwe_ids" : [ "CWE-75", "CWE-843" ],
"severity" : "MODERATE",
"github_reviewed" : true,
"github_reviewed_at" : "2025-10-10T22:51:28Z",
"nvd_published_at" : "2025-10-10T22:15:37Z"
}
}