Issues (1098)

Security Analysis    not enabled

This project does not seem to handle request data directly as such no vulnerable execution paths were found.

  Cross-Site Scripting
Cross-Site Scripting enables an attacker to inject code into the response of a web-request that is viewed by other users. It can for example be used to bypass access controls, or even to take over other users' accounts.
  File Exposure
File Exposure allows an attacker to gain access to local files that he should not be able to access. These files can for example include database credentials, or other configuration files.
  File Manipulation
File Manipulation enables an attacker to write custom data to files. This potentially leads to injection of arbitrary code on the server.
  Object Injection
Object Injection enables an attacker to inject an object into PHP code, and can lead to arbitrary code execution, file exposure, or file manipulation attacks.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Response Splitting
Response Splitting can be used to send arbitrary responses.
  File Inclusion
File Inclusion enables an attacker to inject custom files into PHP's file loading mechanism, either explicitly passed to include, or for example via PHP's auto-loading mechanism.
  Command Injection
Command Injection enables an attacker to inject a shell command that is execute with the privileges of the web-server. This can be used to expose sensitive data, or gain access of your server.
  SQL Injection
SQL Injection enables an attacker to execute arbitrary SQL code on your database server gaining access to user data, or manipulating user data.
  XPath Injection
XPath Injection enables an attacker to modify the parts of XML document that are read. If that XML document is for example used for authentication, this can lead to further vulnerabilities similar to SQL Injection.
  LDAP Injection
LDAP Injection enables an attacker to inject LDAP statements potentially granting permission to run unauthorized queries, or modify content inside the LDAP tree.
  Header Injection
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  XML Injection
XML Injection enables an attacker to read files on your local filesystem including configuration files, or can be abused to freeze your web-server process.
  Variable Injection
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
Unfortunately, the security analysis is currently not available for your project. If you are a non-commercial open-source project, please contact support to gain access.

src/projects/gmembers.php (3 issues)

Upgrade to new PHP Analysis Engine

These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more

1
<?php
2
3
//------------------------------------------------------------------------------
4
//
5
//  eTraxis - Records tracking web-based system
6
//  Copyright (C) 2005-2010  Artem Rodygin
7
//
8
//  This program is free software: you can redistribute it and/or modify
9
//  it under the terms of the GNU General Public License as published by
10
//  the Free Software Foundation, either version 3 of the License, or
11
//  (at your option) any later version.
12
//
13
//  This program is distributed in the hope that it will be useful,
14
//  but WITHOUT ANY WARRANTY; without even the implied warranty of
15
//  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
//  GNU General Public License for more details.
17
//
18
//  You should have received a copy of the GNU General Public License
19
//  along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
//
21
//------------------------------------------------------------------------------
22
23
/**
24
 * @package eTraxis
25
 * @ignore
26
 */
27
28
/**#@+
29
 * Dependency.
30
 */
31
require_once('../engine/engine.php');
32
require_once('../dbo/accounts.php');
33
require_once('../dbo/groups.php');
34
require_once('../dbo/projects.php');
35
/**#@-*/
36
37
init_page(LOAD_TAB);
38
39
if (get_user_level() != USER_LEVEL_ADMIN)
40
{
41
    debug_write_log(DEBUG_NOTICE, 'User must have admin rights to be allowed.');
42
    exit;
43
}
44
45
// check that requested project exists
46
47
$pid     = ustr2int(try_request('pid'));
48
$project = project_find($pid);
49
50
if (!$project)
51
{
52
    debug_write_log(DEBUG_NOTICE, 'Project cannot be found.');
53
    exit;
54
}
55
56
// check that requested group exists
57
58
$id    = ustr2int(try_request('id'));
59
$group = group_find($id);
60
61
if (!$group)
62
{
63
    debug_write_log(DEBUG_NOTICE, 'Group cannot be found.');
64
    exit;
65
}
66
67
// add/remove selected accounts
68
69 View Code Duplication
if (try_request('submitted') == 'othersform')
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
70
{
71
    debug_write_log(DEBUG_NOTICE, 'Data are submitted (adding new members).');
72
73
    if (LDAP_ENABLED && !LDAP_ENUMERATION)
74
    {
75
        $accounts = ustrcut($_REQUEST['accounts'], 1000);
76
        $accounts = ustr_replace("\n", ',', $accounts);
77
78
        mb_regex_encoding('UTF-8');
79
        $names = mb_split(',', $accounts);
80
81
        $accounts = NULL;
82
    }
83
    else
84
    {
85
        $names = try_request('accounts', array());
86
    }
87
88
    foreach ($names as $username)
89
    {
90
        $username = trim($username);
91
92
        if (ustrlen($username) != 0)
93
        {
94
            if (LDAP_ENABLED && !LDAP_ENUMERATION)
95
            {
96
                if (usubstr($username, ustrlen($username) - 1, 1) == '@')
97
                {
98
                    debug_write_log(DEBUG_NOTICE, 'Found @ at the end of login.');
99
                    $username = usubstr($username, 0, ustrlen($username) - 1);
100
                    $account = FALSE;
101
                }
102
                else
103
                {
104
                    $account = account_find_username($username . ACCOUNT_SUFFIX);
105
                }
106
            }
107
            else
108
            {
109
                $account = account_find_username($username);
110
            }
111
112
            if ($account)
113
            {
114
                group_membership_add($id, $account['account_id']);
115
            }
116
            else
117
            {
118
                $account_id = (LDAP_ENABLED ? account_register_ldapuser($username) : NULL);
119
120
                if (is_null($account_id))
121
                {
122
                    debug_write_log(DEBUG_NOTICE, 'Cannot find Active Directory account.');
123
124
                    if (LDAP_ENABLED && !LDAP_ENUMERATION)
125
                    {
126
                        $accounts .= $username . "\n";
127
                    }
128
                }
129
                else
130
                {
131
                    group_membership_add($id, $account_id);
132
                }
133
            }
134
        }
135
    }
136
137
    if (LDAP_ENABLED && !LDAP_ENUMERATION)
138
    {
139
        $_SESSION[VAR_LDAP_ENUMERATION] = $accounts;
140
    }
141
142
    exit;
143
}
144
elseif (try_request('submitted') == 'membersform')
145
{
146
    debug_write_log(DEBUG_NOTICE, 'Data are submitted (removing selected members).');
147
148
    if (isset($_REQUEST['accounts']))
149
    {
150
        foreach ($_REQUEST['accounts'] as $account)
151
        {
152
            group_membership_remove($id, $account);
153
        }
154
    }
155
    else
156
    {
157
        debug_write_log(DEBUG_NOTICE, 'No accounts are selected.');
158
    }
159
160
    exit;
161
}
162
else
163
{
164
    debug_write_log(DEBUG_NOTICE, 'Data are being requested.');
165
}
166
167
// generate left side
168
169
$xml = '<dual>'
170
     . '<dualleft>'
171
     . '<form name="othersform" action="gmembers.php?pid=' . $pid . '&amp;id=' . $id . '" success="reloadTab">'
172
     . '<group title="' . get_html_resource(RES_OTHERS_ID) . '">';
173
174 View Code Duplication
if (LDAP_ENABLED && !LDAP_ENUMERATION)
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
175
{
176
    $xml .= '<control name="accounts">'
177
          . '<textbox rows="10" maxlen="1000">'
178
          . $_SESSION[VAR_LDAP_ENUMERATION]
179
          . '</textbox>'
180
          . '</control>';
181
}
182
else
183
{
184
    $xml .= '<control name="accounts[]">'
185
          . '<listbox size="10">';
186
187
    $list = group_not_amongs($id);
188
189
    foreach ($list as $item)
190
    {
191
        $xml .= '<listitem value="' . $item['username'] . '">'
192
              . ustr2html(sprintf('%s (%s)', $item['fullname'], account_get_username($item['username'])))
193
              . '</listitem>';
194
    }
195
196
    $xml .= '</listbox>'
197
          . '</control>';
198
}
199
200
$xml .= '</group>'
201
      . '</form>'
202
      . '</dualleft>';
203
204
// generate right side
205
206
$xml .= '<dualright>'
207
      . '<form name="membersform" action="gmembers.php?pid=' . $pid . '&amp;id=' . $id . '" success="reloadTab">'
208
      . '<group title="' . get_html_resource(RES_MEMBERS_ID) . '">'
209
      . '<control name="accounts[]">'
210
      . '<listbox size="10">';
211
212
$rs = group_amongs($id);
213
214 View Code Duplication
while (($row = $rs->fetch()))
0 ignored issues
show
This code seems to be duplicated across your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
215
{
216
    $xml .= '<listitem value="' . $row['account_id'] . '">'
217
          . ustr2html(sprintf('%s (%s)', $row['fullname'], account_get_username($row['username'])))
218
          . '</listitem>';
219
}
220
221
$xml .= '</listbox>'
222
      . '</control>'
223
      . '</group>'
224
      . '</form>'
225
      . '</dualright>';
226
227
// generate buttons
228
229
$xml .= '<button action="$(\'#othersform\').submit()">%gt;%gt;</button>'
230
      . '<button action="$(\'#membersform\').submit()">%lt;%lt;</button>'
231
      . '</dual>';
232
233
echo(xml2html($xml));
234
235
?>
236