Skip to content

Commit e45797f

Browse files
authored
improv. fix xss on admin panel (#290)
1 parent b9dbaa6 commit e45797f

2 files changed

Lines changed: 16 additions & 2 deletions

File tree

app/Controller/AppController.php

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
class AppController extends Controller
3737
{
3838

39-
public $components = ['Util', 'Module', 'Session', 'Cookie', 'Security', 'EyPlugin', 'Lang', 'Theme', 'History', 'Statistics', 'Permissions', 'Update', 'Server'];
39+
public $components = ['Util', 'Module', 'Session', 'Cookie', 'Security', 'EyPlugin', 'Lang', 'Theme', 'History', 'Statistics', 'Permissions', 'Update', 'Server', 'EySecurity'];
4040
public $helpers = ['Session'];
4141

4242
public $view = 'Theme';
@@ -46,7 +46,10 @@ class AppController extends Controller
4646

4747
public function beforeFilter()
4848
{
49-
49+
// find any xss vulnability on request data
50+
$datas = $this->request->data;
51+
$this->request->data = $this->xssProtection($datas);
52+
$this->request->data["xss"] = $datas;
5053
// lowercase to avoid errors when the controller is called with uppercase
5154
$this->params['controller'] = strtolower($this->params['controller']);
5255
$this->params['action'] = strtolower($this->params['action']);
@@ -110,6 +113,15 @@ public function beforeFilter()
110113

111114
}
112115

116+
public function xssProtection($array)
117+
{
118+
foreach ($array as $key => $value) {
119+
$array[$key] = is_array($value) ? $this->xssProtection($value) : $this->EySecurity->xssProtection($value);
120+
}
121+
return $array;
122+
123+
}
124+
113125
public function __initConfiguration()
114126
{
115127
// configuration générale

app/Controller/ConfigurationController.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ public function admin_index()
6969
['password_hash' => null]
7070
);
7171

72+
$data['end_layout_code'] = $data['xss']['end_layout_code'];
73+
7274
$this->Configuration->read(null, 1);
7375
$this->Configuration->set($data);
7476
$this->Configuration->save();

0 commit comments

Comments
 (0)