LDAP Injection
LDAP Injection is an attack used to exploit web based applications that construct LDAP statements based on user input. When an application fails to properly sanitize user input, it's possible to modify LDAP statements using a local proxy.
Summary
Methodology
LDAP Injection is a vulnerability that occurs when user-supplied input is used to construct LDAP queries without proper sanitization or escaping
Authentication Bypass
Attempt to manipulate the filter logic by injecting always-true conditions.
Example 1: This LDAP query exploits logical operators in the query structure to potentially bypass authentication
Example 2: This LDAP query exploits logical operators in the query structure to potentially bypass authentication
Blind Exploitation
This scenario demonstrates LDAP blind exploitation using a technique similar to binary search or character-based brute-forcing to discover sensitive information like passwords. It relies on the fact that LDAP filters respond differently to queries based on whether the conditions match or not, without directly revealing the actual password.
LDAP Filter Breakdown:
&: Logical AND operator, meaning all conditions inside must be true.(sn=administrator): Matches entries where the sn (surname) attribute is administrator.(password=X*): Matches entries where the password starts with X (case-sensitive). The asterisk (*) is a wildcard, representing any remaining characters.
Defaults Attributes
Can be used in an injection like *)(ATTRIBUTE_HERE=*
Exploiting userPassword Attribute
userPassword attribute is not a string like the cn attribute for example but it’s an OCTET STRING In LDAP, every object, type, operator etc. is referenced by an OID : octetStringOrderingMatch (OID 2.5.13.18).
octetStringOrderingMatch (OID 2.5.13.18): An ordering matching rule that will perform a bit-by-bit comparison (in big endian ordering) of two octet string values until a difference is found. The first case in which a zero bit is found in one value but a one bit is found in another will cause the value with the zero bit to be considered less than the value with the one bit.
Scripts
Discover Valid LDAP Fields
Special Blind LDAP Injection
Exploitation script by @noraj
Labs
References
Last updated