LDAP Injection

LDAP Injection

By Rohit Gautam
LDAP Injection

Summary: LDAP (Lightweight Directory Access Protocol) Injection is a web security vulnerability that occurs when untrusted data is improperly handled or concatenated into LDAP statements, leading to unintended LDAP queries or unauthorized access to directory services. By exploiting this vulnerability, an attacker can manipulate LDAP queries to extract sensitive information, modify data, or execute arbitrary commands within the target LDAP server.

Severity: High

Attack Vector: Remote

Complexity: Medium

Impact: By successfully exploiting LDAP Injection, an attacker can gain unauthorized access to sensitive information, escalate privileges, perform unauthorized actions, or disrupt the functionality of the LDAP server and associated applications.

Affected IP Address: https://www.example.com/

Port: 443

Steps to Reproduce:

1. Identify the target application or component that interacts with an LDAP server.
2. Analyze how user input or untrusted data is used in LDAP queries or filter construction.
3. Craft malicious input that includes LDAP metacharacters or escape sequences to modify the query's intended behavior.
4. Inject the malicious input into the application and observe the LDAP query generated by the application.
5. Exploit vulnerabilities in the LDAP query construction to extract sensitive information or execute unauthorized operations within the LDAP server.


To mitigate LDAP Injection vulnerabilities, consider the following recommendations:
1. Implement input validation and sanitization to ensure that user-supplied data does not contain LDAP metacharacters or escape sequences.
2. Use parameterized queries or prepared statements provided by the LDAP client library or framework to prevent injection attacks.
3. Implement proper access controls and authentication mechanisms to limit the privileges of LDAP service accounts used by the application.
4. Regularly update and patch LDAP client libraries and server software to address any known security vulnerabilities.
5. Perform input validation and output encoding on data retrieved from the LDAP server to prevent Cross-Site Scripting (XSS) attacks.


1. OWASP - LDAP Injection: https://owasp.org/www-community/attacks/LDAP_Injection 
2. PortSwigger - LDAP Injection: LDAP injection - PortSwigger

Proof of Concept:

Please refer to the attached screenshot or video for a visual demonstration of an LDAP Injection vulnerability.