PT-2026-59240 · Pypi · Lemur
Published
2026-07-13
·
Updated
2026-07-13
CVSS v3.1
8.1
High
| Vector | AV:N/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N |
Description
Overview
Lemur's LDAP authentication module (
lemur/auth/ldap.py) constructs LDAP search filters using unsanitized user input via Python string interpolation. An authenticated LDAP user can inject LDAP filter metacharacters through the username field to manipulate group membership queries and escalate their privileges to administrator.Vulnerable Code
Location:
lemur/auth/ldap.py, bind() methodFilter 1 — User lookup (line ~161):
python
ldap filter = "userPrincipalName=%s" % self.ldap principalself.ldap principal is derived directly from args["username"] submitted at POST /auth/login with no sanitization. The ldap.filter.escape filter chars() function is never called.Filter 2 — Active Directory group lookup (line ~189):
python
groupfilter = "(&(objectclass=group)(member:1.2.840.113556.1.4.1941:={}))".format(userdn)The
userdn value is derived from the LDAP response to the first unsanitized query, making it potentially tainted as well.Impact
An authenticated LDAP user can:
- Inject LDAP filter syntax into the username field during login
- Manipulate the group membership query to return arbitrary groups
- Be assigned the
adminrole or any other privileged role in Lemur - Gain unauthorized access to all certificates, private keys (via
/certificates/<id>/key), and CA configurations - Issue certificates under any authority
Exploitation Constraint
The
simple bind s() call must succeed before the injectable filter is reached, so the attacker requires valid LDAP credentials. This is a post-authentication privilege escalation.Steps to Reproduce
- Deploy Lemur with LDAP authentication enabled:
python
LDAP AUTH = True
LDAP IS ACTIVE DIRECTORY = True
LDAP BIND URI = "ldaps://dc.corp.example.com"
LDAP BASE DN = "DC=corp,DC=example,DC=com"
LDAP EMAIL DOMAIN = "corp.example.com"- Create a valid LDAP user account
- Send login request with crafted username containing LDAP metacharacters:
POST /auth/login
Content-Type: application/json
{
"username": "validuser)(memberOf=CN=LemurAdmins,DC=corp,DC=example,DC=com",
"password": "validpassword"
}- The LDAP filter becomes:
userPrincipalName=validuser)(memberOf=CN=LemurAdmins,DC=corp,DC=example,DC=com@corp.example.com- Depending on the LDAP server's parsing, this can alter query semantics
- The user is assigned roles they should not have access to
Remediation
Apply
ldap.filter.escape filter chars() to all user-controlled values before interpolation:python
from ldap.filter import escape filter chars
# Fix 1: User lookup filter
ldap filter = "userPrincipalName=%s" % escape filter chars(self.ldap principal)
# Fix 2: Active Directory group filter
groupfilter = "(&(objectclass=group)(member:1.2.840.113556.1.4.1941:={}))".format(
escape filter chars(userdn)
)Resources
- CWE-90: https://cwe.mitre.org/data/definitions/90.html
- OWASP LDAP Injection: https://owasp.org/www-community/attacks/LDAP Injection
- Python ldap.filter.escape filter chars: https://www.python-ldap.org/en/python-ldap-3.4.0/reference/ldap-filter.html
Fix
Found an issue in the description? Have something to add? Feel free to write us 👾
Related Identifiers
Affected Products
Lemur