Skip to content

Commit

Permalink
request #24168: Indirect LDAP injection via the ldap_id attribute of …
Browse files Browse the repository at this point in the history
…a user when checking if it exists

This is a follow up to git #tuleap/stable/bd47f29847fcd6a68d359bc8aefb8749bb8a1b7c the initial fix was incomplete.
Issue was identified thanks to Psalm taint analysis.

Change-Id: I695be7d006e0cabdb9d4804f62772b0d88f3ffc0
  • Loading branch information
LeSuisse committed Nov 23, 2021
1 parent 9fa45da commit 64e7756
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 1 deletion.
3 changes: 3 additions & 0 deletions plugins/ldap/include/LDAP_ProjectGroupDao.class.php
Expand Up @@ -148,6 +148,9 @@ public function doesProjectBindingKeepUsers($project_id)
return count($this->retrieve($sql)) > 0;
}

/**
* @psalm-taint-escape ldap DN is stored directly in plugin_ldap_project_group.ldap_group_dn, so we are forced to remove the taint
*/
public function getSynchronizedProjects()
{
$auto_synchronized_value = $this->da->quoteSmart(LDAP_GroupManager::AUTO_SYNCHRONIZATION);
Expand Down
2 changes: 1 addition & 1 deletion plugins/ldap/include/LDAP_UserManager.class.php
Expand Up @@ -505,7 +505,7 @@ public function checkThreshold($nbr_users_to_suspend, $nbr_all_users)
*/
public function isUserDeletedFromLdap($row)
{
$ldap_query = $this->ldap->getLDAPParam('eduid') . '=' . $row['ldap_id'];
$ldap_query = $this->ldap->getLDAPParam('eduid') . '=' . ldap_escape($row['ldap_id'], '', LDAP_ESCAPE_FILTER);
$attributes = $this->user_sync->getSyncAttributes($this->ldap);
$ldapSearch = false;

Expand Down
3 changes: 3 additions & 0 deletions src/common/DB/Compat/Legacy2018/CompatPDODataAccess.php
Expand Up @@ -49,6 +49,7 @@ public function __construct(DBConnection $db_connection)
*
* @psalm-taint-sink sql $sql
* @psalm-taint-sink sql $params
* @psalm-taint-source ldap
*/
public function query($sql, $params = [])
{
Expand Down Expand Up @@ -309,6 +310,7 @@ public function numRows($result)
* @deprecated
*
* @return array Returns an associative array of strings that corresponds to the fetched row, or FALSE if there are no more rows.
* @psalm-taint-source ldap
*/
public function fetch($result)
{
Expand All @@ -330,6 +332,7 @@ public function fetch($result)
* @param type $result
*
* @return type
* @psalm-taint-source ldap
*/
public function fetchArray($result)
{
Expand Down
2 changes: 2 additions & 0 deletions src/common/DB/Compat/Legacy2018/LegacyDataAccessInterface.php
Expand Up @@ -33,6 +33,7 @@ interface LegacyDataAccessInterface
*
* @psalm-taint-sink sql $sql
* @psalm-taint-sink sql $params
* @psalm-taint-source ldap
*/
public function query($sql, $params = []);

Expand Down Expand Up @@ -167,6 +168,7 @@ public function numRows($result);
* @deprecated
*
* @return array Returns an associative array of strings that corresponds to the fetched row, or FALSE if there are no more rows.
* @psalm-taint-source ldap
*/
public function fetch($result);

Expand Down

0 comments on commit 64e7756

Please sign in to comment.