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

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

From OWASP
Jump to: navigation, search
(Reverting to last version not containing links to s1.shard.jp)
Line 1: Line 1:
[http://s1.shard.jp/galeach/new189.html asian babe cute ] [http://s1.shard.jp/olharder/automation-control.html quebec autoroutes ] [http://s1.shard.jp/olharder/autosurf-site.html autosurf site for sale] [http://s1.shard.jp/galeach/new73.html ancient greek clothing that aspasia wore ] [http://s1.shard.jp/losaul/australian-vets.html australian vets for pfizer] [http://s1.shard.jp/olharder/autopsy-picture.html addison automation force in sales ] [http://s1.shard.jp/bireba/disable-norton.html download norton antivirus updates ] [http://s1.shard.jp/losaul/midas-mufflers.html positive cash flow property australia ] [http://s1.shard.jp/galeach/new121.html canastasia studio pinpines ] [http://s1.shard.jp/olharder/opforce-it-automation.html unitrend auto insurance ] [http://s1.shard.jp/bireba/computer-antivirus.html lu1848 norton antivirus ] [http://s1.shard.jp/losaul/australia-cost.html 2004 cpi australia ] [http://s1.shard.jp/frhorton/98rznyn69.html european african middle eastern theater ribbon ] [http://s1.shard.jp/galeach/new8.html asia fhm girl ] [http://s1.shard.jp/olharder/autoroll-654.html index] [http://s1.shard.jp/olharder/wes-finch-auto-plaza.html automatic shut off valve ] [http://s1.shard.jp/olharder/autobiography.html auto quirk ] [http://s1.shard.jp/galeach/new67.html jewelry news asia ] [http://s1.shard.jp/frhorton/3o7l9jema.html african bubble butt ] [http://s1.shard.jp/frhorton/bc7zse5ug.html african scholarships ] [http://s1.shard.jp/bireba/symantec-antivirus.html panda titanium antivirus plus ] [http://s1.shard.jp/frhorton/ru5u87lsh.html african marriage ritual ] [http://s1.shard.jp/bireba/antivirus-check.html inoculateit antivirus avboot ] [http://s1.shard.jp/bireba/panda-software.html kasperskys antivirus firewall ] [http://s1.shard.jp/galeach/new109.html asian healing arts ] [http://s1.shard.jp/losaul/australia-funniest.html abu australian photo ] [http://s1.shard.jp/bireba/download-kaspersky.html pc magazine antivirus ] [http://s1.shard.jp/olharder/autoroll-654.html domain] [http://s1.shard.jp/olharder/automation-expense.html starting samba automatically ] [http://s1.shard.jp/olharder/keystone-automotive.html autocad blocks cars ] [http://s1.shard.jp/bireba/noton-antivirus.html norten antivirus download ] [http://s1.shard.jp/olharder/autoroll-654.html webmap] [http://s1.shard.jp/bireba/clamav-antivirus.html network antivirus scanner ] [http://s1.shard.jp/losaul/sai-global-australia.html australia driving map ] [http://s1.shard.jp/frhorton/j45p2foyu.html african penguin habitat ] [http://s1.shard.jp/olharder/autoroll-654.html link] [http://s1.shard.jp/bireba/download-free.html antivirus server 2003 free ] [http://s1.shard.jp/bireba/extendia-antivirus.html antivirus software for pc ] [http://s1.shard.jp/olharder/automotive-repair.html american automobile racing association inc ] [http://s1.shard.jp/olharder/auto-copart-sale.html auto copart sale] [http://s1.shard.jp/bireba/antivirus-software.html stinger antivirus download free ] [http://s1.shard.jp/frhorton/bnm8i4pvp.html africas best universities ] [http://s1.shard.jp/bireba/etrust-antivirus.html pc cillin antivirus ] [http://s1.shard.jp/olharder/auto-wrap-graphics.html auto in law lemon mold ] [http://s1.shard.jp/bireba/dod-cert-antivirus.html panda antivirus free download ] [http://s1.shard.jp/bireba/avg-antivirus.html panda antivirus free download ] [http://s1.shard.jp/bireba/avg-antivirus-73.html antivirus free trial download ] [http://s1.shard.jp/galeach/new119.html asian tsunami blogs ] [http://s1.shard.jp/losaul/australian-oil.html australian surf lifesaving titles 2004 photos ] [http://s1.shard.jp/galeach/new130.html lyrics to fantasia barrino ] 
 
 
{{Template:OWASP Testing Guide v3}}
 
{{Template:OWASP Testing Guide v3}}
  

Revision as of 12:50, 3 June 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:

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

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:

searchfilter="(cn="+user+")"

which is instantiated by an HTTP request like this:

http://www.example.com/ldapsearch?user=John

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

http://www.example.com/ldapsearch?user=*

the filter will look like:

searchfilter="(cn=*)"

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:

user=*)(uid=*))(|(uid=*
 pass=password

the search filter will results in:

searchlogin="(&(uid=*)(uid=*))(|(uid=*)(userPassword={MD5}X03MO1qnZdYdgyfeuILPmQ==))";

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

References

Whitepapers
Sacha Faust: "LDAP Injection" - http://www.spidynamics.com/whitepapers/LDAPinjection.pdf
Bruce Greenblatt: "LDAP Overview" - http://www.directory-applications.com/ldap3_files/frame.htm
IBM paper: "Understanding LDAP" - http://www.redbooks.ibm.com/redbooks/SG244986.html

Tools
Softerra LDAP Browser - http://www.ldapadministrator.com/download/index.php