mirror of
https://github.com/drakkan/sftpgo.git
synced 2025-12-07 06:40:54 +03:00
Fix potential ldap injection
Signed-off-by: Felix Eckhofer <felix@eckhofer.com>
This commit is contained in:
committed by
Nicola Murino
parent
e0cbb966f0
commit
71f691b208
@@ -97,7 +97,7 @@ func main() {
|
|||||||
|
|
||||||
// search the user trying to login and fetch some attributes, this search string is tested against 389ds using the default configuration
|
// search the user trying to login and fetch some attributes, this search string is tested against 389ds using the default configuration
|
||||||
log.Printf("username=%s\n", username)
|
log.Printf("username=%s\n", username)
|
||||||
searchFilter := fmt.Sprintf("(uid=%s)", username)
|
searchFilter := fmt.Sprintf("(uid=%s)", ldap.EscapeFilter(username))
|
||||||
searchRequest := ldap.NewSearchRequest(
|
searchRequest := ldap.NewSearchRequest(
|
||||||
"ou=people," + rootDN,
|
"ou=people," + rootDN,
|
||||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
|
|||||||
@@ -78,7 +78,7 @@ func checkSFTPGoUserAuth(w http.ResponseWriter, r *http.Request) {
|
|||||||
searchRequest := ldap.NewSearchRequest(
|
searchRequest := ldap.NewSearchRequest(
|
||||||
ldapConfig.BaseDN,
|
ldapConfig.BaseDN,
|
||||||
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
ldap.ScopeWholeSubtree, ldap.NeverDerefAliases, 0, 0, false,
|
||||||
strings.Replace(ldapConfig.SearchFilter, "%s", authReq.Username, 1),
|
strings.Replace(ldapConfig.SearchFilter, "%s", ldap.EscapeFilter(authReq.Username), 1),
|
||||||
ldapConfig.SearchBaseAttrs,
|
ldapConfig.SearchBaseAttrs,
|
||||||
nil,
|
nil,
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user