This site is the archived OWASP Foundation Wiki and is no longer accepting Account Requests.
To view the new OWASP Foundation website, please visit

Difference between revisions of "Testing for LDAP Injection (OTG-INPVAL-006)"

Jump to: navigation, search
(Reverting to last version not containing links to
Line 1: Line 1:
[ asian american artists ] [ person search in south africa] [ african canadian helping youths ] [ australia institute of mathematics ] [ auto mart usa ] [ url] [ yahoo asia education] [ avg antivirus full ] [ top] [ australia education guide ] [ african american literary agents ] [ norton free antivirus scan ] [ drifters africa ] [ australian meals made through the gold rush ] [ asian online games] [ mcafee antivirus programs ] [ australias river map ] [ australia england cricket trophy the ] [ avgfreeantivirus ] [ antivirus2003] [ sitemap] [ australia bus conversion home in motor] [ asian tiffin lunchbox] [ mini minor for sale australia ] [ asian bare feet ] [ ch futterautomat pferd] [ african braid picture ] [ south african animal ] [ 5th test south africa ] [ asia and south pacific map ] [ dariusz wolski autograph] [ australian open tv schedule in us ] [ lily asian beaver ] [ camper van rent australia ] [ ] [ african american skincare ] [ african american care skin tip ] [ african championship handball nation ] [ africa store ] [ asian figure skaters ] [ assurance automobile du quebec societe ] [ usa embasy south africa ] [ waltons stationery south africa ] [ ez antivirus 2005 reviews ] [ pacific asia travel associations ] [ history of indigenous australians ] [ asian clothes wholesalers ] 
[ african american institute leadership
] [ search engine marketing south africa
] [ automatic login linux
] [ african licked
] [ 900 auto part saab
] [ genetics society of australasia] [ john thornton africa
] [ asian loni pics
] [ antivirus software information
] [ webmap] [ australia pajero
] [ african american incarcerated
] [ auto patcher xp 2005
] [ autoplex 2000 lake charles
] [ african dream phone card
] [ avisoft antivirus
] [ why did people migrate to australia
] [ australia post shop catalogue
] [ site] [ tales of phantasia walkthrough
] [ site] [ kensington ipod fm transmitter and auto charger 33159
] [ auto check
] [ mens clothing wholesalers gold coast australia
] [ pc cillin 2000 antivirus
] [ africans teens
] [ adelong australia
] [ celebrating indigenous south african
] [ malinish auto
] [ africanists
] [ antivirus and security software
] [ the autopsy report
] [ 2006 winantivirus
] [ lashins auto salvage
] [ man made attractions in australia
] [ sitemap] [ domain] [ url] [ seasonal weather in australia] [ webmap] [ unique automotive shelby
] [ winantivirus pro 2005 deluxe
] [ auto foam upholstery
] [ human hair wigs african american
] [ dod cert antivirus] [ submissive asians] [ antivirus trialware download  
{{Template:OWASP Testing Guide v3}}
{{Template:OWASP Testing Guide v3}}

Revision as of 16:00, 27 May 2009 OWASP Testing Guide v3 Table of Contents

This article is part of the OWASP Testing Guide v3. The entire OWASP Testing Guide v3 can be downloaded here.

OWASP at the moment is working at the OWASP Testing Guide v4: you can browse the Guide here

Brief Summary

LDAP is an acronym for Lightweight Directory Access Protocol. LDAP is a protocol to store information about users, hosts, and many other objects. LDAP injection is a server side attack, which could allow sensitive information about users and hosts represented in an LDAP structure to be disclosed, modified, or inserted.
This is done by manipulating input parameters afterwards passed to internal search, add, and modify functions.

Description of the Issue

A web application could use LDAP in order to let users authenticate or search other users' information inside a corporate structure.

The goal of LDAP injection attacks is to inject LDAP search filters metacharacters in a query which will be executed by the application.

[Rfc2254] defines a grammar on how to build a search filter on LDAPv3 and extends [Rfc1960] (LDAPv2).

An LDAP search filter is constructed in Polish notation, also known as [prefix notation].

This means that a pseudo code condition on a search filter like this:

find("cn=John & userPassword=mypass")

will be represented as:


Boolean conditions and group aggregations on an LDAP search filter could be applied by using the following metacharacters:

Metachar Meaning
& Boolean AND
| Boolean OR
 ! Boolean NOT
= Equals
~= Approx
>= Greater than
<= Less than
* Any character
() Grouping parenthesis

More complete examples on how to build a search filter can be found in the related RFC.

A successful exploitation of an LDAP injection vulnerability could allow the tester to:

  • Access unauthorized content
  • Evade application restrictions
  • Gather unauthorized informations
  • Add or modify Objects inside LDAP tree structure.

Black Box testing and example

Example 1. Search Filters

Let's suppose we have a web application using a search filter like the following one:


which is instantiated by an HTTP request like this:

If the value 'John' is replaced with a '*', by sending the request:*

the filter will look like:


which matches every object with a 'cn' attribute equals to anything.

If the application is vulnerable to LDAP injection, it will display some or all of the users' attributes, depending on the application's execution flow and the permissions of the LDAP connected user.

A tester could use a trial-and-error approach, by inserting in the parameter '(', '|', '&', '*' and the other characters, in order to check the application for errors.

Example 2. Login

If a web application uses LDAP to check user credentials during the login process and it is vulnerable to LDAP injection, it is possible to bypass the authentication check by injecting an always true LDAP query (in a similar way to SQL and XPATH injection ).

Let's suppose a web application uses a filter to match LDAP user/password pair.

searchlogin= "(&(uid="+user+")(userPassword={MD5}"+base64(pack("H*",md5(pass)))+"))";

By using the following values:


the search filter will results in:


which is correct and always true. This way, the tester will gain logged-in status as the first user in LDAP tree.


Sacha Faust: "LDAP Injection" -
Bruce Greenblatt: "LDAP Overview" -
IBM paper: "Understanding LDAP" -

Softerra LDAP Browser -