Skip to content

Commit

Permalink
remove session id on payload #301
Browse files Browse the repository at this point in the history
  • Loading branch information
Mohamed Nizar committed Dec 2, 2020
1 parent 4a32b37 commit 59e3de5
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 15 deletions.
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>

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>

0 comments on commit 59e3de5

Please sign in to comment.