Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pen test FIXES #305

Merged
merged 3 commits into from
Dec 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,7 @@
RewriteRule ^$ webroot/ [L]
RewriteRule (.*) webroot/$1 [L]
</IfModule>
<IfModule mod_php7.c>
php_flag session.use_trans_sid off
</IfModule>

8 changes: 7 additions & 1 deletion config/app.php
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,13 @@
* To use database sessions, load the SQL file located at config/Schema/sessions.sql
*/
'Session' => [
'defaults' => 'php',
'defaults' => 'cake',
'timeout' => 30,
'cookieTimeout' => 30,
'ini' => array(
'session.cookie_secure' => true,
'session.cookie_httponly' => true
)
// 'defaults' => 'cache',
],
'debug' => true
Expand Down
22 changes: 10 additions & 12 deletions config/routes.php
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,6 @@
*/
$routes->connect('/pages/*', ['controller' => 'Pages', 'action' => 'display']);



/**
* Connect catchall routes for all controllers.
*
Expand Down Expand Up @@ -203,16 +201,16 @@
});

// For restful session
Router::scope('/session', ['plugin' => 'Restful'], function ($routes) {
$routes->scope('/', ['controller' => 'Session'], function ($routes) {
$routes->extensions(['json']);

$routes->connect('/:key', ['action' => 'check', '_method' => 'CHECK'], ['pass' => ['key']]);
$routes->connect('/:key', ['action' => 'read', '_method' => 'GET'], ['pass' => ['key']]);
$routes->connect('/', ['action' => 'write', '_method' => 'POST']);
$routes->connect('/:key', ['action' => 'delete', '_method' => 'DELETE'], ['pass' => ['key']]);
});
});
// Router::scope('/session', ['plugin' => 'Restful'], function ($routes) {
// $routes->scope('/', ['controller' => 'Session'], function ($routes) {
// $routes->extensions(['json']);

// $routes->connect('/:key', ['action' => 'check', '_method' => 'CHECK'], ['pass' => ['key']]);
// $routes->connect('/:key', ['action' => 'read', '_method' => 'GET'], ['pass' => ['key']]);
// $routes->connect('/', ['action' => 'write', '_method' => 'POST']);
// $routes->connect('/:key', ['action' => 'delete', '_method' => 'DELETE'], ['pass' => ['key']]);
// });
// });

/**
* Load all plugin routes. See the Plugin documentation on
Expand Down
14 changes: 0 additions & 14 deletions plugins/ControllerAction/src/Model/Traits/SecurityTrait.php
Original file line number Diff line number Diff line change
Expand Up @@ -68,25 +68,11 @@ public function paramsDecode($params)
$signature = $this->urlsafeB64Decode($signature);

$payload = json_decode($payload, true);
$sessionId = Security::hash('session_id', 'sha256');
if (!isset($payload[$sessionId])) {
throw new SecurityException('No session id in payload');
} else {
$checkPayload = $payload;
$checkPayload[$sessionId] = session_id();
$checkSignature = Security::hash(json_encode($checkPayload), 'sha256', true);
if ($signature !== $checkSignature) {
throw new SecurityException('Query String has been tampered');
}
}
unset($payload[$sessionId]);
return $payload;
}

public function paramsEncode($params = [])
{
$sessionId = Security::hash('session_id', 'sha256');
$params[$sessionId] = session_id();
$jsonParam = json_encode($params);
$base64Param = $this->urlsafeB64Encode($jsonParam);
$signature = Security::hash($jsonParam, 'sha256', true);
Expand Down
4 changes: 3 additions & 1 deletion webroot/.htaccess
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,6 @@
RewriteCond %{REQUEST_URI} !=/server-status
RewriteRule ^ index.php [L]
</IfModule>

<IfModule mod_php7.c>
php_flag session.use_trans_sid off
</IfModule>