UB-Mannheim /
PalMA
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | if (!isset($_SESSION)) { |
||
| 3 | session_start(); |
||
| 4 | } |
||
| 5 | |||
| 6 | if (!isset($_SESSION['username'])) { |
||
| 7 | if (isset($_SERVER['HTTP_REFERER'])) { |
||
| 8 | error_log("auth.php referred by " . $_SERVER['HTTP_REFERER']); |
||
| 9 | } |
||
| 10 | $header = 'Location: login.php'; |
||
| 11 | $separator = '?'; |
||
| 12 | View Code Duplication | if (isset($_REQUEST['lang'])) { |
|
|
0 ignored issues
–
show
|
|||
| 13 | $header = $header . $separator . 'lang=' . $_REQUEST['lang']; |
||
| 14 | $separator = '&'; |
||
| 15 | } |
||
| 16 | View Code Duplication | if (isset($_REQUEST['pin'])) { |
|
|
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...
|
|||
| 17 | $header = $header . $separator . 'pin=' . $_REQUEST['pin']; |
||
| 18 | $separator = '&'; |
||
| 19 | } |
||
| 20 | header($header); |
||
|
0 ignored issues
–
show
Security
Response Splitting
introduced
by
$header can contain request data and is used in response header context(s) leading to a potential security vulnerability.
Response Splitting AttacksAllowing an attacker to set a response header, opens your application to response splitting attacks; effectively allowing an attacker to send any response, he would like. 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;
Loading history...
|
|||
| 21 | |||
| 22 | exit; |
||
| 23 | } |
||
| 24 |
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.