LDAP Injection Detection and Testing
What you'll learn: How to identify LDAP injection vulnerabilities using error messages, timing analysis, and blind injection methods.
Now that you understand how LDAP injection works, you need to know how to test for it in real applications. Detection relies on observing how the application responds to malicious input—sometimes obviously, sometimes subtly.
Error-Based Detection
The easiest way to find LDAP injection is through error messages. Try injecting special LDAP characters like *, (, ), &, or | into input fields (username, search boxes, etc.). If the application returns LDAP syntax errors or behaves unexpectedly, you've likely found a vulnerability.
Example test input: admin* or *)(uid=*))(|(uid=*
If you see error messages mentioning LDAP filters, distinguished names, or attribute errors, the application is vulnerable and isn't properly sanitizing input.
Timing-Based Detection
Like SQL injection, time-based blind LDAP injection exploits timing differences. If the application doesn't show errors but processes LDAP queries differently based on your input, you can infer vulnerability by measuring response times.
Think of it like asking yes/no questions: "Does this user exist?" If the server takes longer to respond when your query is true versus false, you can extract information bit by bit.
Blind Injection Techniques
When the application shows no errors and timing is unreliable, use boolean-based blind injection. Craft queries that change the application's behavior (like successful login, different search results, or different page content) based on true/false conditions.
Test approach: Inject logic that always evaluates to true (|(uid=*)) versus always false (&(uid=admin)(uid=test)) and observe if the application behaves differently—different results, error states, or redirects indicate vulnerability.
Key Takeaway: LDAP injection detection combines error message analysis, timing measurement, and blind testing techniques to uncover vulnerabilities where user input flows unsanitized into LDAP queries.