Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 619ce0f

Browse files
committed
xss: Dashboard period
This mitigates a vulnerability reported by @indevi0us where XSS is possible via the `period` parameter. This sanitizes the parameter values before using them anywhere.
1 parent 9fb01bc commit 619ce0f

2 files changed

Lines changed: 12 additions & 18 deletions

File tree

include/class.report.php

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,14 +23,21 @@ static function getPermissions() {
2323
class OverviewReport {
2424
var $start;
2525
var $end;
26+
static $end_choices = [
27+
'now' => 'Up to today',
28+
'+7 days' => 'One Week',
29+
'+14 days' => 'Two Weeks',
30+
'+1 month' => 'One Month',
31+
'+3 months' => 'One Quarter'
32+
];
2633

2734
var $format;
2835

2936
function __construct($start, $end='now', $format=null) {
3037
global $cfg;
3138

32-
$this->start = $start;
33-
$this->end = $end;
39+
$this->start = Format::sanitize($start);
40+
$this->end = array_key_exists($end, self::$end_choices) ? $end : 'now';
3441
$this->format = $format ?: $cfg->getDateFormat(true);
3542
}
3643

include/staff/dashboard.inc.php

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -25,23 +25,10 @@
2525
?>" />
2626
</label>
2727
<label>
28-
<?php echo __( 'period');?>:
28+
<?php echo __('period');?>:
2929
<select name="period">
30-
<option value="now" selected="selected">
31-
<?php echo __( 'Up to today');?>
32-
</option>
33-
<option value="+7 days">
34-
<?php echo __( 'One Week');?>
35-
</option>
36-
<option value="+14 days">
37-
<?php echo __( 'Two Weeks');?>
38-
</option>
39-
<option value="+1 month">
40-
<?php echo __( 'One Month');?>
41-
</option>
42-
<option value="+3 months">
43-
<?php echo __( 'One Quarter');?>
44-
</option>
30+
<?php foreach ($report::$end_choices as $val=>$desc)
31+
echo "<option value='$val'>" . __($desc) . "</option>"; ?>
4532
</select>
4633
</label>
4734
<button class="green button action-button muted" type="submit">

0 commit comments

Comments
 (0)