CVE-2025-61911

6.5 MEDIUM

📋 TL;DR

This vulnerability in python-ldap allows LDAP injection attacks when applications use the library's escape_filter_chars method with escape_mode=1 and pass untrusted list/dict objects as input. Attackers could potentially access or modify LDAP data they shouldn't have access to. Applications using python-ldap with custom escaping configurations are affected.

💻 Affected Systems

Products:
  • python-ldap
Versions: All versions prior to 3.4.5
Operating Systems: All platforms running Python
Default Config Vulnerable: ✅ No
Notes: Only vulnerable when using escape_mode=1 parameter and passing list/dict objects as assertion_value. Default escape_mode=0 is not vulnerable.

📦 What is this software?

⚠️ Risk & Real-World Impact

🔴

Worst Case

Full LDAP directory compromise allowing data exfiltration, modification of user permissions, or authentication bypass.

🟠

Likely Case

Limited LDAP data disclosure or unauthorized data modification depending on application context.

🟢

If Mitigated

No impact if proper input validation and type checking are implemented before calling the vulnerable function.

🌐 Internet-Facing: MEDIUM - Requires specific configuration (escape_mode=1) and passing untrusted list/dict objects to the vulnerable function.
🏢 Internal Only: MEDIUM - Same technical risk but limited to internal attackers with network access.

🎯 Exploit Status

Public PoC: ✅ No
Weaponized: UNKNOWN
Unauthenticated Exploit: ✅ No
Complexity: MEDIUM

Requires specific application configuration and passing untrusted list/dict objects to the vulnerable function. Not trivially exploitable.

🛠️ Fix & Mitigation

✅ Official Fix

Patch Version: 3.4.5

Vendor Advisory: https://github.com/python-ldap/python-ldap/security/advisories/GHSA-r7r6-cc7p-4v5m

Restart Required: No

Instructions:

1. Update python-ldap package: pip install python-ldap==3.4.5
2. Verify no breaking changes in your application
3. Test LDAP functionality after update

🔧 Temporary Workarounds

Input validation wrapper

all

Add type checking before calling escape_filter_chars to ensure only string inputs are passed

def safe_escape_filter_chars(value, escape_mode=1):
    if not isinstance(value, str):
        raise TypeError('assertion_value must be string')
    return ldap.filter.escape_filter_chars(value, escape_mode)

🧯 If You Can't Patch

  • Implement strict input validation to ensure only string types are passed to escape_filter_chars
  • Avoid using escape_mode=1 configuration and use default escape_mode=0 instead

🔍 How to Verify

Check if Vulnerable:

Check python-ldap version: pip show python-ldap | grep Version

Check Version:

python -c "import ldap; print(ldap.__version__)"

Verify Fix Applied:

Verify version is 3.4.5 or higher and test with list/dict inputs to ensure exceptions are raised

📡 Detection & Monitoring

Log Indicators:

  • TypeError exceptions from ldap.filter.escape_filter_chars
  • Unexpected LDAP query patterns

Network Indicators:

  • Unusual LDAP query structures containing unescaped special characters

SIEM Query:

source="application.logs" AND ("TypeError" AND "escape_filter_chars" OR "ldap injection")

🔗 References

📤 Share & Export