Skip to content

Commit

Permalink
improv. fix xss on admin panel (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
nivcoo committed Dec 1, 2021
1 parent b9dbaa6 commit e45797f
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
16 changes: 14 additions & 2 deletions app/Controller/AppController.php
Expand Up @@ -36,7 +36,7 @@
class AppController extends Controller
{

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

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

public function beforeFilter()
{

// find any xss vulnability on request data
$datas = $this->request->data;
$this->request->data = $this->xssProtection($datas);
$this->request->data["xss"] = $datas;
// lowercase to avoid errors when the controller is called with uppercase
$this->params['controller'] = strtolower($this->params['controller']);
$this->params['action'] = strtolower($this->params['action']);
Expand Down Expand Up @@ -110,6 +113,15 @@ public function beforeFilter()

}

public function xssProtection($array)
{
foreach ($array as $key => $value) {
$array[$key] = is_array($value) ? $this->xssProtection($value) : $this->EySecurity->xssProtection($value);
}
return $array;

}

public function __initConfiguration()
{
// configuration g茅n茅rale
Expand Down
2 changes: 2 additions & 0 deletions app/Controller/ConfigurationController.php
Expand Up @@ -69,6 +69,8 @@ public function admin_index()
['password_hash' => null]
);

$data['end_layout_code'] = $data['xss']['end_layout_code'];

$this->Configuration->read(null, 1);
$this->Configuration->set($data);
$this->Configuration->save();
Expand Down

0 comments on commit e45797f

Please sign in to comment.