-
Notifications
You must be signed in to change notification settings - Fork 253
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix escaping in LDAP search strings [CVE-2020-14013] #239
base: master
Are you sure you want to change the base?
Conversation
When username contains any special character (parentheses, asterisk, ...) user search will fail. When returned DN of user contains any escaped character (for example ",") group filter will fail. Example: (&(CN=group)(member=CN=dummy\, dummy2,OU=ou,DC=dc))" Which is wrong and doesn't work with Active directory. Correct is: (&(CN=group)(member=CN=dummy\5C, dummy2,OU=ou,DC=dc))" This patch fixies both of these bugs by using ldap_bv2escaped_filter_value from LDAP client to escape all of filter values. See: https://tools.ietf.org/search/rfc2254#page-5 Fix: kvspb#224 kvspb#180
} | ||
|
||
out.len = euserbv.bv_len; | ||
out.data = ngx_pcalloc(r->pool, out.len); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can ngx_pcalloc
not fail?
out.data = ngx_pcalloc(r->pool, out.len); | |
out.data = ngx_pcalloc(r->pool, out.len); | |
if (!out.data) { | |
return out; | |
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
returning out
is not correct, because out.len
will be set to new length but out.data
will be null.
return ngx_null_string
is probably better
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
but tbh: Whole upstream code is not checking return code of ngx_pcalloc, so meh.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah. I saw that I will probably not use this module at all and use https://github.com/sto/ngx_http_auth_pam_module which seems much simpler and cleaner code.
I encountered the error during make install with this module.
|
When username contains any special character (parentheses, asterisk, ...)
user search will fail.
When returned DN of user contains any escaped character (for example ",")
group filter will fail.
Example:
Which is wrong and doesn't work with Active directory.
Correct is:
This patch fixies both of these bugs by using ldap_bv2escaped_filter_value
from LDAP client to escape all of filter values.
See: https://tools.ietf.org/search/rfc2254#page-5
Fixes #224 fixes #180
CVE-2020-14013