19.09.2017 Views

the-web-application-hackers-handbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

350 Chapter 9 n Attacking Data Stores<br />

Common examples of LDAP are <strong>the</strong> Active Directory used within Windows<br />

domains, and OpenLDAP, used in various situations. You are most likely to<br />

encounter LDAP being used in corporate intranet-based <strong>web</strong> <strong>application</strong>s, such<br />

as an HR <strong>application</strong> that allows users to view and modify information about<br />

employees.<br />

Each LDAP query uses one or more search filters, which determine <strong>the</strong> directory<br />

entries that are returned by <strong>the</strong> query. Search filters can use various logical<br />

operators to represent complex search conditions. The most common search<br />

filters you are likely to encounter are as follows:<br />

n Simple match conditions match on <strong>the</strong> value of a single attribute. For<br />

example, an <strong>application</strong> function that searches for a user via his username<br />

might use this filter:<br />

(username=daf)<br />

n Disjunctive queries specify multiple conditions, any one of which must<br />

be satisfied by entries that are returned. For example, a search function<br />

that looks up a user-supplied search term in several directory attributes<br />

might use this filter:<br />

(|(cn=searchterm)(sn=searchterm)(ou=searchterm))<br />

n Conjunctive queries specify multiple conditions, all of which must be<br />

satisfied by entries that are returned. For example, a login mechanism<br />

implemented in LDAP might use this filter:<br />

(&(username=daf)(password=secret)<br />

As with o<strong>the</strong>r forms of injection, if user-supplied input is inserted into an<br />

LDAP search filter without any validation, it may be possible for an attacker<br />

to supply crafted input that modifies <strong>the</strong> filter’s structure and <strong>the</strong>reby retrieve<br />

data or perform actions in an unauthorized way.<br />

In general, LDAP injection vulnerabilities are not as readily exploitable as<br />

SQL injection flaws, due to <strong>the</strong> following factors:<br />

n Where <strong>the</strong> search filter employs a logical operator to specify a conjunctive<br />

or disjunctive query, this usually appears before <strong>the</strong> point where usersupplied<br />

data is inserted and <strong>the</strong>refore cannot be modified. Hence, simple<br />

match conditions and conjunctive queries don’t have an equivalent to <strong>the</strong><br />

“or 1=1” type of attack that arises with SQL injection.<br />

n In <strong>the</strong> LDAP implementations that are in common use, <strong>the</strong> directory attributes<br />

to be returned are passed to <strong>the</strong> LDAP APIs as a separate parameter<br />

from <strong>the</strong> search filter and normally are hard-coded within <strong>the</strong> <strong>application</strong>.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!