This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include
, or for example
via PHP's auto-loading mechanism.
1 | <?php |
||
2 | |||
3 | /* |
||
4 | * ***************************************************************************** |
||
5 | * Contributions to this work were made on behalf of the GÉANT project, a |
||
6 | * project that has received funding from the European Union’s Framework |
||
7 | * Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus), |
||
8 | * Horizon 2020 research and innovation programme under Grant Agreements No. |
||
9 | * 691567 (GN4-1) and No. 731122 (GN4-2). |
||
10 | * On behalf of the aforementioned projects, GEANT Association is the sole owner |
||
11 | * of the copyright in all material which was developed by a member of the GÉANT |
||
12 | * project. GÉANT Vereniging (Association) is registered with the Chamber of |
||
13 | * Commerce in Amsterdam with registration number 40535155 and operates in the |
||
14 | * UK as a branch of GÉANT Vereniging. |
||
15 | * |
||
16 | * Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. |
||
17 | * UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK |
||
18 | * |
||
19 | * License: see the web/copyright.inc.php file in the file structure or |
||
20 | * <base_url>/copyright.php after deploying the software |
||
21 | */ |
||
22 | require_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php"; |
||
23 | $languageInstance = new \core\common\Language(); |
||
24 | $languageInstance->setTextDomain("diagnostics"); |
||
25 | $loggerInstance = new \core\common\Logging(); |
||
26 | // only enable this during development - it allows random junk to be logged |
||
27 | // without any control! |
||
28 | // $loggerInstance->debug(4, $_REQUEST); |
||
29 | $o = new stdClass(); |
||
30 | if (isset($_REQUEST['data'])) { |
||
31 | $o = json_decode($_REQUEST['data']); |
||
32 | } |
||
33 | $sp_problem = array( |
||
34 | 'technical' => _("I suspect a Technical Problem with the IdP"), |
||
35 | 'abuse-copyright' => _("A user from this IdP has allegedly infringed copyrights"), |
||
36 | 'abuse-network' => _("A user from this IdP has conducted malicious network operations (spam, DDoS, ...)") |
||
37 | ); |
||
38 | $idp_problem = array( |
||
39 | 'technical' => _("User claims connectivity problems but has been authenticated successfully"), |
||
40 | 'abuse-copyright' => _("User claims that mandatory open port is not open") |
||
41 | ); |
||
42 | $queryType = filter_input(INPUT_GET, 'type'); // no need to filter - exact values are tested later |
||
43 | $realmFromURL = htmlspecialchars(strip_tags(filter_input(INPUT_GET, 'realm'))); |
||
44 | if (!$realmFromURL) { |
||
45 | $realmFromURL = ''; |
||
46 | } |
||
47 | $res = ''; |
||
48 | $javascript = "<script> |
||
49 | var mac = $('#mac'); |
||
50 | mac.on('keyup', formatMAC); |
||
51 | var now = new Date(); |
||
52 | var datefrom = new Date(); |
||
53 | datefrom.setMonth(datefrom.getMonth() - 3); |
||
54 | $('#timestamp').datetimepicker({ |
||
55 | timeFormat: 'HH:mm z', |
||
56 | controlType: 'select', |
||
57 | minDateTime: datefrom, |
||
58 | maxDateTime: now |
||
59 | }); |
||
60 | </script> |
||
61 | "; |
||
62 | if ($queryType == 'sp') { |
||
63 | $select = "<div id='sp_abuse_problem'> |
||
64 | <select style='margin-left: 0px;' id='select_sp_problem'>"; |
||
65 | foreach ($sp_problem as $pname => $pdesc) { |
||
66 | $select = $select . "<option value='$pname'>$pdesc</option>\n"; |
||
67 | } |
||
68 | $select = $select . "</select></div>"; |
||
69 | $res = " |
||
70 | <input type='hidden' name='token' id='token' value=''> |
||
71 | <input type='hidden' name='tests_result' id='tests_result' value=''> |
||
72 | <table id='sp_questions'> |
||
73 | <tr id='sp_problem_selector'> |
||
74 | <td>" . _("Select your problem") . "</td> |
||
75 | <td>$select</td> |
||
76 | </tr> |
||
77 | <tr> |
||
78 | <td>" . _("What is the realm of the IdP in question?") . "</td> |
||
79 | <td> |
||
80 | <input type='text' name='admin_realm' id='admin_realm' value='$realmFromURL'> |
||
81 | <button class='diag_button' id='realm_in_db_admin' style='display: none;' accesskey='R' type='button'>" . |
||
82 | _("Check this realm") . |
||
83 | "</button> |
||
84 | <div id='tests_info_area'></div> |
||
85 | </td> |
||
86 | </tr> |
||
87 | <tr id='outer_user_row' class='hidden_row'> |
||
88 | <td>" . _("Do you prefer to use a specific outer identity for diagnostics test?") . "</td> |
||
89 | <td> <input type='text' name='outer_user' id='outer_user' value=''><span id='outer_user_realm'></span> |
||
90 | </tr> |
||
91 | <tr class='hidden_row'> |
||
92 | <td>" . _("What is the authentication timestamp of the user session in question?") . "</td> |
||
93 | <td><input type='text' id='timestamp' name='timestamp'> |
||
94 | <div id='datepicker'></div> |
||
95 | </td> |
||
96 | </tr> |
||
97 | <tr class='hidden_row'> |
||
98 | <td>" . _("What is the MAC address of the user session in question?") . "</td> |
||
99 | <td><input type='text' id='mac' name='mac'></td> |
||
100 | </tr> |
||
101 | <tr class='hidden_row'> |
||
102 | <td>" . _("Additional comments") . "</td> |
||
103 | <td><textarea id='freetext' name='freetext' cols='60' rows='5'></textarea></td> |
||
104 | </tr> |
||
105 | <tr class='hidden_row'> |
||
106 | <td>" . _("Please specify an email address on which the IdP can contact you") . "</td> |
||
107 | <td><input type='text' id='email' name='email'></td> |
||
108 | </tr> |
||
109 | <tr> |
||
110 | <td id='external_db_info'></td> |
||
111 | <td></td> |
||
112 | </tr> |
||
113 | <tr class='hidden_row' id='send_query_to_idp'> |
||
114 | <td>" . _("Now you can send your query") . "</td> |
||
115 | <td><button type='submit' class='diag_button' id='submit_idp_query' name='go'>" . _("Send") . "</button></td> |
||
116 | </tr> |
||
117 | </table>"; |
||
118 | $res = $res . $javascript; |
||
119 | } |
||
120 | if ($queryType == 'idp') { |
||
121 | $select = "<div id='idp_reported_problem' style='display:;'> |
||
122 | <select style='margin-left:0px;' id='select_idp_problem'>"; |
||
123 | foreach ($idp_problem as $pname => $pdesc) { |
||
124 | $select = $select . "<option value='$pname'>$pdesc</option>\n"; |
||
125 | } |
||
126 | $select = $select . "</select></div>"; |
||
127 | $res = " |
||
128 | <table id='idp_questions'> |
||
129 | <tr> |
||
130 | <td>" . _("Select your problem") . "</td> |
||
131 | <td>$select</td> |
||
132 | </tr> |
||
133 | <tr> |
||
134 | <td>" . _("Identify the SP by one of following means") . "</td> |
||
135 | <td></td> |
||
136 | </tr> |
||
137 | <tr id='by_opname'> |
||
138 | <td>" . _("SP Operator-Name attribute") . "</td> |
||
139 | <td><input type='text' id='opname' name='opname' value=''></td> |
||
140 | </tr> |
||
141 | <tr id='spmanually'> |
||
142 | <td>" . _("Select the SP manually:") . "</td> |
||
143 | <td> |
||
144 | <div id='select_asp_country'><a href='' id='asp_countries_list'> |
||
145 | <span id='opnameselect'>" . _("click to select country and organisation") . "</a></span> |
||
146 | </div> |
||
147 | <div id='select_asp_area'></div> |
||
148 | </td> |
||
149 | </tr> |
||
150 | <tr id='asp_desc' style='display: none;'> |
||
151 | <td>" . _("or") . ' ' . _("at least describe the SP location") . "</td> |
||
152 | <td><input type='text' id='asp_location' name='asp_location' value=''></td> |
||
153 | </tr> |
||
154 | <tr> |
||
155 | <td>" . _("What is the outer ID of the user session in question?") . "</td> |
||
156 | <td><input type='text' id='outer_id' name='outer_id' value=''></td> |
||
157 | </tr> |
||
158 | <tr> |
||
159 | <td>" . _("What is the authentication timestamp of the user session in question?") . "</td> |
||
160 | <td> |
||
161 | <input type='text' id='timestamp' name='timestamp'> |
||
162 | <div id='datepicker'></div> |
||
163 | </td> |
||
164 | </tr> |
||
165 | <tr> |
||
166 | <td>" . _("What is the MAC address of the user session in question?") . "</td> |
||
167 | <td><input type='text' id='mac' name='mac'></td> |
||
168 | </tr> |
||
169 | <tr> |
||
170 | <td>" . _("Additional comments about the problem") . "</td> |
||
171 | <td><textarea id='freetext' name='freetext' cols='60' rows='5'></textarea></td> |
||
172 | </tr> |
||
173 | <tr> |
||
174 | <td>" . _("Do you have any contact details by which the user wishes to be contacted by the SP?") . "</td> |
||
175 | <td><textarea id='c_details' name='c_details' cols='60' rows='5'></textarea></td> |
||
176 | </tr> |
||
177 | <tr> |
||
178 | <td>" . _("Please specify an email address on which the SP can contact you") . "</td> |
||
179 | <td><input type='text' id='email' name='email'></td> |
||
180 | </tr> |
||
181 | <tr class='hidden_row' id='send_query_to_sp'> |
||
182 | <td>" . _("Now you can send your query") . "</td> |
||
183 | <td><button type='submit' class='diag_button' id='submit_sp_query' name='go'>" . _("Send") . "</button></td> |
||
184 | </tr> |
||
185 | </table>"; |
||
186 | $res = $res . $javascript; |
||
187 | } |
||
188 | if ($queryType == 'idp_send' || $queryType == 'sp_send') { |
||
189 | include_once dirname(dirname(dirname(__FILE__))) . "/config/_config.php"; |
||
190 | $cat = new \core\CAT(); |
||
191 | $returnArray = array(); |
||
192 | if (count((array) $o) > 0) { |
||
193 | foreach ($o as $key => $value) { |
||
194 | $value = trim($value); |
||
195 | switch ($key) { |
||
196 | case 'realm': |
||
197 | $pos = strpos($value, '@'); |
||
198 | if ($pos !== FALSE ) { |
||
0 ignored issues
–
show
Coding Style
Comprehensibility
introduced
by
![]() |
|||
199 | $value = substr($value, $pos+1); |
||
200 | } |
||
201 | case 'email': |
||
202 | $returnArray[$key] = filter_var($value, FILTER_VALIDATE_EMAIL); |
||
203 | break; |
||
204 | case 'mac': |
||
205 | case 'freetext': |
||
206 | case 'timestamp': |
||
207 | case 'opname': |
||
208 | case 'outerid': |
||
209 | case 'cdetails': |
||
210 | case 'token': |
||
211 | // all of the above have to be printable strings, so sanitise them all in one go |
||
212 | $returnArray[$key] = htmlspecialchars(strip_tags($value)); |
||
213 | break; |
||
214 | case 'tests_result': |
||
215 | $returnArray[$key] = filter_var($value, FILTER_VALIDATE_INT); |
||
216 | break; |
||
217 | case 'idpcontact': |
||
218 | if ($value == '') { |
||
219 | $returnArray[$key] = '[email protected]'; |
||
220 | } else { |
||
221 | $returnArray[$key] = filter_var(base64_decode($value), FILTER_VALIDATE_EMAIL); |
||
222 | } |
||
223 | break; |
||
224 | case 'reason': |
||
225 | if ($queryType == 'idp_send') { |
||
226 | $returnArray[$key] = $sp_problem[$value]; |
||
227 | } else { |
||
228 | $returnArray[$key] = $idp_problem[$value]; |
||
229 | } |
||
230 | break; |
||
231 | default: |
||
232 | break; |
||
233 | } |
||
234 | } |
||
235 | } |
||
236 | if ($queryType == 'idp_send') { |
||
237 | $mail = \core\common\OutsideComm::mailHandle(); |
||
238 | $emails = ['[email protected]']; |
||
239 | //$emails = explode(',', $returnArray['idpcontact']); |
||
240 | $mail->FromName = \config\Master::APPEARANCE['productname'] . " Notification System"; |
||
241 | foreach ($emails as $email) { |
||
242 | $mail->addAddress($email); |
||
243 | } |
||
244 | $link = ''; |
||
245 | if (isset($_SERVER['HTTPS'])) { |
||
246 | $link = 'https://'; |
||
247 | } else { |
||
248 | $link = 'http://'; |
||
249 | } |
||
250 | $link .= $_SERVER['SERVER_NAME'] . \core\CAT::getRootUrlPath() . '/diag/show_realmcheck.php?token=' . $returnArray['token']; |
||
251 | $returnArray['testurl'] = $link; |
||
252 | $mail->Subject = _('Suspected a technical problem with the IdP'); |
||
253 | $txt = _("We suspect a technical problem with the IdP handling the realm") . ' ' . |
||
254 | $returnArray['realm'] . ".\n"; |
||
255 | $txt .= _("The CAT diagnostic test was run for this realm during reporting.\n"); |
||
256 | $txt .= _("The overall result was "); |
||
257 | if ($returnArray['tests_result'] == 0) { |
||
258 | $txt .= _("success"); |
||
259 | } else { |
||
260 | $txt .= _("failure"); |
||
261 | } |
||
262 | $txt .= ".\n" . _("To see details go to "); |
||
263 | $txt .= "$link\n\n"; |
||
264 | $txt .= _("The reported problem details are as follows") . "\n"; |
||
265 | $txt .= _("timestamp") . ": " . $returnArray['timestamp'] . "\n"; |
||
266 | $txt .= _("client MAC address") . ": " . $returnArray['mac'] . "\n"; |
||
267 | if ($returnArray['freetext']) { |
||
268 | $txt .= _("additional comments") . ': ' . $returnArray['freetext'] . "\n"; |
||
269 | } |
||
270 | $txt .= "\n" . _("You can contact the incident reporter at") . ' ' . $returnArray['email']; |
||
271 | |||
272 | $mail->Body = $txt; |
||
0 ignored issues
–
show
$Body can contain request data and is used in file manipulation context(s) leading to a potential security vulnerability.
1 path for user data to reach this point
Used in path-write context
General Strategies to prevent injectionIn general, it is advisable to prevent any user-data to reach this point. This can be done by white-listing certain values:
if ( ! in_array($value, array('this-is-allowed', 'and-this-too'), true)) {
throw new \InvalidArgumentException('This input is not allowed.');
}
For numeric data, we recommend to explicitly cast the data: $sanitized = (integer) $tainted;
![]() $Body can contain request data and is used in file manipulation context(s) leading to a potential security vulnerability.
1 path for user data to reach this point
Used in path-write context
General Strategies to prevent injectionIn general, it is advisable to prevent any user-data to reach this point. This can be done by white-listing certain values:
if ( ! in_array($value, array('this-is-allowed', 'and-this-too'), true)) {
throw new \InvalidArgumentException('This input is not allowed.');
}
For numeric data, we recommend to explicitly cast the data: $sanitized = (integer) $tainted;
![]() $Body can contain request data and is used in file manipulation context(s) leading to a potential security vulnerability.
1 path for user data to reach this point
Used in path-write context
General Strategies to prevent injectionIn general, it is advisable to prevent any user-data to reach this point. This can be done by white-listing certain values:
if ( ! in_array($value, array('this-is-allowed', 'and-this-too'), true)) {
throw new \InvalidArgumentException('This input is not allowed.');
}
For numeric data, we recommend to explicitly cast the data: $sanitized = (integer) $tainted;
![]() $Body can contain request data and is used in request header context(s) leading to a potential security vulnerability.
1 path for user data to reach this point
Used in request-header context
General Strategies to prevent injectionIn general, it is advisable to prevent any user-data to reach this point. This can be done by white-listing certain values:
if ( ! in_array($value, array('this-is-allowed', 'and-this-too'), true)) {
throw new \InvalidArgumentException('This input is not allowed.');
}
For numeric data, we recommend to explicitly cast the data: $sanitized = (integer) $tainted;
![]() |
|||
273 | $sent = $mail->send(); |
||
274 | if ($sent === FALSE) { |
||
275 | $returnArray['emailsent'] = 0; |
||
276 | $loggerInstance->debug(1, 'Mailing failed'); |
||
277 | } else { |
||
278 | $returnArray['emailsent'] = 1; |
||
279 | } |
||
280 | } |
||
281 | $returnArray['status'] = 1; |
||
282 | $res = json_encode($returnArray); |
||
283 | } |
||
284 | echo $res; |
||
285 |