Language: PHP
Label: vulnerable
CWE: CWE-281 \u2014 Improper Preservation of Permissions
The product does not preserve permissions or incorrectly preserves permissions when copying, restoring, or sharing objects, which can cause them to have less restrictive permissions than intended.

Code:
    public function removeUserFromProject($project_id, $user_id, $admin_action = true)
    {
        $project = $this->getProject($project_id);

        if (! $this->dao->removeUserFromProject($project_id, $user_id)) {
            $GLOBALS['Response']->addFeedback(
                Feedback::ERROR,
                $GLOBALS['Language']->getText('project_admin_index', 'user_not_removed')
            );

            return false;
        }

        $this->event_manager->processEvent('project_admin_remove_user', [
            'group_id' => $project_id,
            'user_id'  => $user_id,
        ]);

        $this->removeUserFromTrackerV3($project_id, $user_id);

        if (! $this->removeUserFromProjectUgroups($project, $user_id)) {
            $GLOBALS['Response']->addFeedback('error', $GLOBALS['Language']->getText('project_admin_index', 'del_user_from_ug_fail'));
        }

        $user_name = $this->getUserName($user_id);

        $this->displayFeedback($project, $user_name, $admin_action);

        $this->project_history_dao->groupAddHistory(
            'removed_user',
            $user_name . " ($user_id)",
            $project_id
        );

        return true;
    }