Skip to content

Commit

Permalink
Escape login identifier before searching the entry.
Browse files Browse the repository at this point in the history
This will avoid trivial DOS and ldap.FILTER_ERROR exceptions on
attempted logins by users sporting "funny" login names, like 'user*name'
or 'user(middle)name'.
  • Loading branch information
lmctv committed Jan 19, 2013
1 parent 29ee4b4 commit f305744
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions pyramid_ldap/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
try:
import ldap
import ldap.filter
except ImportError: # pragma: no cover
# this is for benefit of being able to build the docs on rtd.org
class ldap(object):
Expand Down Expand Up @@ -113,8 +114,10 @@ def authenticate(self, login, password):
if search is None:
raise ConfigurationError(
'ldap_set_login_query was not called during setup')

result = search.execute(conn, login=login, password=password)

escaped_login = ldap.filter.escape_filter_chars(login)

result = search.execute(conn, login=escaped_login, password=password)
if len(result) == 1:
login_dn = result[0][0]
else:
Expand Down

0 comments on commit f305744

Please sign in to comment.