Issues (212)

Security Analysis    12 potential vulnerabilities

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

  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.
  Regex Injection
Regex Injection enables an attacker to execute arbitrary code in your PHP process.
  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.
  Response Splitting (2)
Response Splitting can be used to send arbitrary responses.
  File Manipulation (5)
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.
  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.
  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.
  Code Injection
Code Injection enables an attacker to execute arbitrary code on the server.
  Variable Injection (1)
Variable Injection enables an attacker to overwrite program variables with custom data, and can lead to further vulnerabilities.
  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.
  Other Vulnerability
This category comprises other attack vectors such as manipulating the PHP runtime, loading custom extensions, freezing the runtime, or similar.
  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.
  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.
  Cross-Site Scripting (2)
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.
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.

web/admin/edit_hotspot.php (2 issues)

1
<?php
2
/*
3
 * *****************************************************************************
4
 * Contributions to this work were made on behalf of the GÉANT project, a 
5
 * project that has received funding from the European Union’s Framework 
6
 * Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus),
7
 * Horizon 2020 research and innovation programme under Grant Agreements No. 
8
 * 691567 (GN4-1) and No. 731122 (GN4-2).
9
 * On behalf of the aforementioned projects, GEANT Association is the sole owner
10
 * of the copyright in all material which was developed by a member of the GÉANT
11
 * project. GÉANT Vereniging (Association) is registered with the Chamber of 
12
 * Commerce in Amsterdam with registration number 40535155 and operates in the 
13
 * UK as a branch of GÉANT Vereniging.
14
 * 
15
 * Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. 
16
 * UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK
17
 *
18
 * License: see the web/copyright.inc.php file in the file structure or
19
 *          <base_url>/copyright.php after deploying the software
20
 */
21
22
/**
23
 * This page is used to edit a RADIUS profile by its administrator.
24
 * 
25
 * @author Stefan Winter <[email protected]>
26
 * @author Maja Gorecka-Wolniewicz <[email protected]>
27
 */
28
?>
29
<?php
30
require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php";
31
32
33
$deco = new \web\lib\admin\PageDecoration();
34
$validator = new \web\lib\common\InputValidation();
35
$uiElements = new web\lib\admin\UIElements();
36
37
$optionlist = \core\Options::instance();
38
$availableFedOptions  = $optionlist->availableOptions('managedsp');
39
$wizard = new \web\lib\admin\Wizard(false);
40
$wizard->setOptionsHelp($availableFedOptions);
41
$wizard->setMessages();
42
// initialize inputs
43
[$my_inst, $editMode]  = $validator->existingIdPInt($_GET['inst_id'], $_SESSION['user']);
44
if ($editMode !== 'fullaccess') {
45
    echo "<h1>";
46
    echo _("Not sufficient access rights for this page");
47
    exit;
48
}
49
$myfed = new \core\Federation($my_inst->federation);
50
if (!isset($_GET['deployment_id'])) {
51
    /*if (isset($_POST['consortium']) && ( $_POST['consortium'] == "eduroam" ||
52
            ( $_POST['consortium'] == "OpenRoaming" && count($myfed->getAttributes("fed:openroaming")) > 0 )
53
            )
54
    ) {*/
55
    if (isset($_POST['consortium']) &&  $_POST['consortium'] == "eduroam")
56
    {
57
        $deployment = $my_inst->newDeployment(\core\AbstractDeployment::DEPLOYMENTTYPE_MANAGED, $_POST['consortium']);
58
        header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '#profilebox_' . $deployment->identifier);
59
        exit(0);
60
    } else {
61
        throw new Exception("Desired consortium for Managed SP needs to be specified, and allowed!");
62
    }
63
}
64
$my_inst->type =  'SP';
65
66
// if we have come this far, we are editing an existing deployment
67
68
$deployment = $validator->existingDeploymentManaged($_GET['deployment_id'], $my_inst);
69
if (isset($_POST['submitbutton'])) {
70
    switch ($_POST['submitbutton']) {
71
        case web\lib\common\FormElements::BUTTON_TERMSOFUSE_NEEDACCEPTANCE:
72
            if (count($deployment->getAttributes("hiddenmanagedsp:tou_accepted")) == 0) {
73
                //terms of use popup, going interactive
74
                echo $deco->defaultPagePrelude(sprintf(_("%s: %s Terms of Use"), \config\Master::APPEARANCE['productname'], $uiElements->nomenclatureHotspot));
75
                ?>
76
                </head>
77
                <body>
78
                    <?php
79
                    echo $deco->productheader("ADMIN-SP");
80
                    ?>
81
                    <h1>
82
                        <?php
83
                        echo _("Terms of Use Acceptance");
84
                        ?>
85
                    </h1>
86
                    <div id="sb-popup-message" >
87
                        <div id="overlay"></div>
88
                        <div id="msgbox">
89
                            <div style="top: 100px;">
90
                                <div class="graybox">
91
                                    <h1><?php echo sprintf(_("%s - Terms of Use"), core\DeploymentManaged::PRODUCTNAME); ?></h1>
92
                                    <div class="containerbox" style="position: relative;">
93
                                        <hr>
94
                                        <?php echo $deployment->termsAndConditions; ?>
95
                                        <hr>
96
                                        <form enctype='multipart/form-data' action='edit_hotspot.php?inst_id=<?php echo $my_inst->identifier; ?>&amp;deployment_id=<?php echo $deployment->identifier; ?>' method='post' accept-charset='UTF-8'>
97
                                            <div style="position: relative; padding-bottom: 5px;">
98
                                                <input type="checkbox" name="agreement" value="true"> <label><?php echo _("I have read and agree to the terms."); ?></label>
99
                                            </div>
100
                                            <button type="submit" name="submitbutton" value="<?php echo \web\lib\common\FormElements::BUTTON_TERMSOFUSE_ACCEPTED ?>"><?php echo _("Continue"); ?></button>
101
                                            <button class="delete" type="submit" name="command" value="<?php echo \web\lib\common\FormElements::BUTTON_CLOSE ?>"><?php echo _("Abort"); ?></button>
102
                                        </form>
103
                                    </div>
104
                                </div>
105
                            </div>
106
                        </div>
107
                    </div>
108
                    <?php
109
                    echo $deco->footer();
110
                }
111
                exit(0);
112
        case web\lib\common\FormElements::BUTTON_TERMSOFUSE_ACCEPTED:
113
            if (isset($_POST['agreement']) && $_POST['agreement'] == "true") {
114
                $deployment->addAttribute("hiddenmanagedsp:tou_accepted", NULL, 1);
115
            }
116
            header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '#profilebox_' . $deployment->identifier);
117
            exit(0);
118
        case web\lib\common\FormElements::BUTTON_DELETE:
119
            $response = $deployment->setRADIUSconfig();
120
            if (in_array('OK', $response)) {
121
                $deployment->deactivate();
122
            }
123
            header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '&' . urldecode(http_build_query($response)) . '#profilebox_' . 
124
                   $deployment->identifier);
125
            exit(0);
126
        case web\lib\common\FormElements::BUTTON_REMOVESP:
127
            $deployment->remove();
128
            header("Location: overview_org.php?inst_id=" . $my_inst->identifier);
129
            exit(0);
130
        case web\lib\common\FormElements::BUTTON_RENEWTLS:
131
            $data = openssl_x509_parse($deployment->radsec_cert);
132
            $certdata = array(
133
                    $data['serialNumberHex'],
134
                    date_create_from_format('ymdGis', substr($data['validTo'], 0, -1))->format('YmdHis')
135
            );
136
            $torevoke = implode('#', $certdata);
137
            $response = $deployment->setRADIUSconfig(0, 0, $torevoke);
138
            $deployment->renewtls();
139
            header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '#profilebox_' . $deployment->identifier);
140
            exit(0);
141
        case web\lib\common\FormElements::BUTTON_USECSR:
142
            if (isset($_FILES['upload']) && $_FILES['upload']['size'] > 0) {
143
                $csrpem = file_get_contents($_FILES['upload']['tmp_name']);
144
                if ($csrpem === FALSE) {
145
                    // seems we can't work with this file for some reason. Ignore.
146
                    header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '&errormsg=NOCSR_' . $deployment->identifier . '#profilebox_' . $deployment->identifier);
147
                    exit(0);
148
                }
149
                $csr = new \phpseclib3\File\X509();
150
                $csr->loadCSR($csrpem);
151
                if ($csr->validateSignature()) { 
152
                    // valid signature
153
                    $data = openssl_x509_parse($deployment->radsec_cert);
154
                    $certdata = array(
155
                              $data['serialNumberHex'],
156
                              date_create_from_format('ymdGis', substr($data['validTo'], 0, -1))->format('YmdHis')
157
                             );
158
                    $torevoke = implode('#', $certdata);
159
                    $response = $deployment->setRADIUSconfig(0, 0, $torevoke);
160
                    $deployment->tlsfromcsr($csr);
161
                    header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '#profilebox_' . $deployment->identifier);
162
                    exit(0);
163
                } else {
164
                    header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '&errormsg=WRONGCSR_' . $deployment->identifier . '#profilebox_' . $deployment->identifier);
165
                    exit(0);
166
                }
167
            }
168
        case web\lib\common\FormElements::BUTTON_ACTIVATE:
169
            if (count($deployment->getAttributes("hiddenmanagedsp:tou_accepted")) > 0) {
170
                $response = $deployment->setRADIUSconfig();
171
                if (in_array('OK', $response)) {
172
                    $deployment->activate();
173
                }
174
                header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '&' . urldecode(http_build_query($response)) . '#profilebox_' . $deployment->identifier);
175
                exit(0);
176
            } else {
177
                throw new Exception("Activate button pushed without acknowledged ToUs!");
178
            }
179
        case web\lib\common\FormElements::BUTTON_SAVE:
180
            $optionParser = new web\lib\admin\OptionParser();
181
            $postArray = $_POST;
182
            if (isset($postArray['vlan'])) {
183
                $postArray['option']['S1234567892'] = "managedsp:vlan#int##";
184
                $postArray['value']['S1234567892-integer'] = $postArray['vlan'];
185
            }
186
            if (isset($postArray['guest_vlan'])) {
187
                $postArray['option']['S1234567890'] = "managedsp:guest_vlan#int##";
188
                $postArray['value']['S1234567890-integer'] = $postArray['guest_vlan'];
189
            }
190
            if (isset($postArray['opname'])) {
191
                $postArray['option']['S1234567891'] = "managedsp:operatorname#string##";
192
                $postArray['value']['S1234567891-string'] = $postArray['opname'];
193
            }
194
            if (isset($postArray['hotspotname'])) {
195
                $postArray['option']['S1234567893'] = "managedsp:name#string##";
196
                $postArray['value']['S1234567893-string'] = $postArray['hotspotname'];
197
            }  
198
            $optionParser->processSubmittedFields($deployment, $postArray, $_FILES);
199
            // if ToU were already accepted, keep them (would otherwise be auto-deleted
200
            if (count($deployment->getAttributes("hiddenmanagedsp:tou_accepted")) > 0) {
201
                $deployment->addAttribute("hiddenmanagedsp:tou_accepted", NULL, 1);
202
            }
203
            // reinstantiate object with new values
204
            $deploymentReinstantiated = $validator->existingDeploymentManaged($deployment->identifier, $my_inst);
205
            if ($deploymentReinstantiated->status == core\DeploymentManaged::ACTIVE) {
206
                $deploymentReinstantiated->status = core\DeploymentManaged::INACTIVE;
207
                $response = $deploymentReinstantiated->setRADIUSconfig();
208
            } else {
209
                $response = ['NOOP', 'NOOP'];
210
            }
211
            header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '&' . urldecode(http_build_query($response)) . '#profilebox_' . $deployment->identifier);
212
            exit(0);
213
          default:
214
                throw new Exception("Unknown button action requested!");
215
    }
216
}
217
if (isset($_POST['command'])) {
218
    switch ($_POST['command']) {
219
        case web\lib\common\FormElements::BUTTON_CLOSE:
220
            header("Location: overview_org.php?inst_id=" . $my_inst->identifier) . '#profilebox_' . $deployment->identifier;
0 ignored issues
show
Are you sure header('Location: overvi.... $my_inst->identifier) of type void can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

220
            /** @scrutinizer ignore-type */ header("Location: overview_org.php?inst_id=" . $my_inst->identifier) . '#profilebox_' . $deployment->identifier;
Loading history...
Are you sure the usage of header('Location: overvi.... $my_inst->identifier) is correct as it seems to always return null.

This check looks for function or method calls that always return null and whose return value is used.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
if ($a->getObject()) {

The method getObject() can return nothing but null, so it makes no sense to use the return value.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
221
            exit(0);
222
        default:
223
            header("Location: overview_org.php?inst_id=" . $my_inst->identifier . '#profilebox_' . $deployment->identifier);
224
            exit(0);
225
        }
226
}
227
$vlan = $deployment->getAttributes("managedsp:vlan")[0]['value'] ?? NULL;
228
$guest_vlan = $deployment->getAttributes("managedsp:guest_vlan")[0]['value'] ?? NULL;
229
$opname = $deployment->getAttributes("managedsp:operatorname")[0]['value'] ?? "";
230
$name = $deployment->getAttributes("managedsp:name")[0]['value'] ?? "";
231
$hotspotname = $deployment->getAttributes("managedsp:name")[0]['value'] ?? "";
232
echo $deco->defaultPagePrelude(sprintf(_("%s: Enrollment Wizard (Step 3)"), \config\Master::APPEARANCE['productname']));
233
?>
234
<script src="js/XHR.js" type="text/javascript"></script>
235
<script src="js/option_expand.js" type="text/javascript"></script>
236
<script type="text/javascript" src="../external/jquery/jquery-ui.js"></script> 
237
<link rel="stylesheet" type="text/css" href="../external/jquery/jquery-ui.css" />
238
<script type="text/javascript" src="js/wizard.js"></script> 
239
<link rel='stylesheet' type='text/css' href='css/wizard.css.php' />
240
</head>
241
<body>
242
    <?php
243
    echo $deco->productheader("ADMIN-SP");
244
    ?>
245
    <div id="wizard_help_window"><img id="wizard_menu_close" src="../resources/images/icons/button_cancel.png" ALT="Close"/><div></div></div>
246
    <h1>
247
        <?php
248
        printf(_("Editing %s deployment"), $uiElements->nomenclatureHotspot);
249
        ?>
250
    </h1>
251
    <?php
252
    echo $uiElements->instLevelInfoBoxes($my_inst);
253
    $deploymentOptions = $deployment->getAttributes();
254
    echo "<form enctype='multipart/form-data' action='edit_hotspot.php?inst_id=$my_inst->identifier&amp;deployment_id=$deployment->identifier' method='post' accept-charset='UTF-8'>
255
                <input type='hidden' name='MAX_FILE_SIZE' value='" . \config\Master::MAX_UPLOAD_SIZE . "'>";
256
    $optionDisplay = new \web\lib\admin\OptionDisplay($deploymentOptions, \core\Options::LEVEL_PROFILE);
257
    ?>
258
    <fieldset class='option_container' id='managedsp_override'>
259
        <legend>
260
            <strong>
261
                <?php
262
                $tablecaption = _("Options for this deployment");
263
                echo $tablecaption;
264
                ?>
265
            </strong>
266
        </legend>
267
        <?php echo $wizard->displayHelp("managedsp"); ?>
268
269
        <table>
270
            <caption><?php echo $tablecaption; ?></caption>
271
            <tr>
272
                <th class="wai-invisible" scope="col"><?php echo _("Property Type"); ?></th>
273
                <th class="wai-invisible" scope="col"><?php echo _("Language if applicable"); ?></th>
274
                <th class="wai-invisible" scope="col"><?php echo _("Property Value"); ?></th>
275
            </tr>
276
            <tr>
277
                <!-- input for Hotspot name-->
278
                <td>
279
                    <span id1='hotspotname_label'>
280
                        <?php echo _("Custom  Hotspot Name:"); ?>
281
                    </span>
282
                </td>
283
                <td>
284
                    <input type='text' width="20" name="hotspotname" value="<?php echo $name; ?>"/>
285
                </td>
286
            </tr>
287
            <tr>
288
                <!-- input for Operator-Name override-->
289
                <td>
290
                    <span id1='opname_label'>
291
                        <?php echo _("Custom Operator-Name:"); ?>
292
                    </span>
293
                </td>
294
                <td>
295
                    <input type='text' width="20" name="opname" value="<?php echo $opname; ?>"/>
296
                </td>
297
            </tr>
298
            <tr>
299
                <!-- input for VLAN identifier for guests-->
300
                <td>
301
                    <span id='guest_vlan_label'>
302
                        <?php echo sprintf(_("VLAN tag for guests:"), ($guest_vlan === NULL ? "" : " " . _("(unset with '0')"))); ?>
303
                    </span>
304
                </td>
305
                <td>
306
                    <input type='number' width="4" name='guest_vlan' <?php
307
                    if ($guest_vlan !== NULL) {
308
                        echo "value='$guest_vlan'";
309
                    }
310
                    ?>
311
                    >
312
                </td>
313
            </tr>
314
            <tr>
315
                <!-- input for VLAN identifier for home users-->
316
                <td>
317
                    <span id='vlan_label'>
318
                        <?php echo sprintf(_("VLAN tag for own users%s:"), ($vlan === NULL ? "" : " " . _("(unset with '0')"))); ?>
319
                    </span>
320
                </td>
321
                <td>
322
                    <input type='number' width="4" name='vlan' <?php
323
                    if ($vlan !== NULL) {
324
                        echo "value='$vlan'";
325
                    }
326
                    ?>
327
                    >
328
                </td>
329
            </tr>
330
        </table>
331
        <?php
332
        echo $optionDisplay->prefilledOptionTable("managedsp", $my_inst->federation);
333
        ?>
334
        <?php if($editMode === 'fullaccess') { ?>
335
        <button type='button' class='newoption' onclick='getXML("managedsp", "<?php echo $my_inst->federation ?>")'><?php echo _("Add new option (a realm for own users)"); ?></button>
336
        <?php } ?>
337
    </fieldset><p>
338
339
    <?php
340
    if ($editMode === 'fullaccess') {
341
        echo "<button type='submit' name='submitbutton' class='deploymentopts' value='" . web\lib\common\FormElements::BUTTON_SAVE . "'>" . _("Save data") . "</button>";
342
        $discardLabel = _("Discard changes");
343
    } else {
344
        $discardLabel = _("Return");
345
    }
346
    echo "<button type='button' class='delete' name='abortbutton' value='abort' onclick='javascript:window.location = \"edit_hotspot.php?inst_id=$my_inst->identifier\"'>$discardLabel</button></p>";
347
    echo "</form>";
348
    echo $deco->footer();
349
    ?>
350
    <script>
351
        $(document).ready(function () {
352
            $('.deploymentopts').on('click', function () {
353
            var emptyvlan = "<?php echo _("VLAN tag for own users not set, realm setting will be not used."); ?>";
354
            var emptyrealm = "<?php echo _("A realm to be considered own users is not set, VLAN tag setting will be not used."); ?>";
355
            var query = "<?php echo _("Do you want to save this data after all?"); ?>";
356
            
357
            var vlan = $("[name='vlan']");
358
            var ids= [];
359
            var realms = [];
360
            $("#expandable_managedsp_options").find('tr').each(function(idx, el) {      
361
               var val = $("#" + el.id.substring(7) + "-input-string").val();
362
               if (val !== undefined && val != '') {
363
                    realms.push(val);
364
                }
365
            });
366
            ack = true;
367
            if (realms.length > 0 && vlan.val() == '' ) {
368
                ack = confirm (emptyvlan + ' ' + query);      
369
            }
370
            if (vlan.val() != '' && realms.length == 0) {
371
                ack = confirm (emptyrealm + ' ' + query);
372
            }
373
            if (!ack) {
374
                event.preventDefault();
375
            }
376
            return;
377
            });
378
        });
379
    </script>
380
381