Skip to content

Commit

Permalink
[BUGFIX] Anonymize encoded tokens
Browse files Browse the repository at this point in the history
Tokens in an encoded URL (where '=' is '%3D') now get anonymized.

Resolves: #96858
Releases: main, 11.5
Change-Id: If07d122b2a5b89cb66fef3fff0790004c5d07eb1
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/73456
Tested-by: core-ci <typo3@b13.com>
Tested-by: Stefan Bürk <stefan@buerk.tech>
Tested-by: Simon Schaufelberger <simonschaufi+typo3@gmail.com>
Tested-by: Christian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk <stefan@buerk.tech>
Reviewed-by: Simon Schaufelberger <simonschaufi+typo3@gmail.com>
Reviewed-by: Christian Kuhn <lolli@schwarzbu.ch>
  • Loading branch information
okmiim authored and lolli42 committed Feb 14, 2022
1 parent 85d0b4a commit 3704e20
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ protected function getBackendUser(): ?BackendUserAuthentication
*/
protected function anonymizeToken(string $requestedUrl): string
{
$pattern = '/(?<=[tT]oken=)[0-9a-fA-F]{40}/';
$pattern = '/(?:(?<=[tT]oken=)|(?<=[tT]oken%3D))[0-9a-fA-F]{40}/';
return preg_replace($pattern, '--AnonymizedToken--', $requestedUrl);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,10 @@ public function exampleUrlsForTokenAnonymization(): array
'http://localhost/typo3/index.php?M=foo&moduleToken=5f1f7d447f22886e8ea206693b0d530ccd6b2b36',
'http://localhost/typo3/index.php?M=foo&moduleToken=--AnonymizedToken--',
],
'url with valid token and encoded token' => [
'http://localhost/typo3/index.php?M=foo&moduleToken=5f1f7d447f22886e8ea206693b0d530ccd6b2b36&returnUrl=%2Ftypo3%2Findex%2Ephp%3FM%3Dfoo%26moduleToken%3D5f1f7d447f22886e8ea206693b0d530ccd6b2b36',
'http://localhost/typo3/index.php?M=foo&moduleToken=--AnonymizedToken--&returnUrl=%2Ftypo3%2Findex%2Ephp%3FM%3Dfoo%26moduleToken%3D--AnonymizedToken--',
],
'url with valid token in the middle' => [
'http://localhost/typo3/index.php?M=foo&moduleToken=5f1f7d447f22886e8ea206693b0d530ccd6b2b36&param=asdf',
'http://localhost/typo3/index.php?M=foo&moduleToken=--AnonymizedToken--&param=asdf',
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,10 @@ public function exampleUrlsForTokenAnonymization(): array
'http://localhost/typo3/index.php?M=foo&moduleToken=5f1f7d447f22886e8ea206693b0d530ccd6b2b36',
'http://localhost/typo3/index.php?M=foo&moduleToken=--AnonymizedToken--',
],
'url with valid token and encoded token' => [
'http://localhost/typo3/index.php?M=foo&moduleToken=5f1f7d447f22886e8ea206693b0d530ccd6b2b36&returnUrl=%2Ftypo3%2Findex%2Ephp%3FM%3Dfoo%26moduleToken%3D5f1f7d447f22886e8ea206693b0d530ccd6b2b36',
'http://localhost/typo3/index.php?M=foo&moduleToken=--AnonymizedToken--&returnUrl=%2Ftypo3%2Findex%2Ephp%3FM%3Dfoo%26moduleToken%3D--AnonymizedToken--',
],
'url with valid token in the middle' => [
'http://localhost/typo3/index.php?M=foo&moduleToken=5f1f7d447f22886e8ea206693b0d530ccd6b2b36&param=asdf',
'http://localhost/typo3/index.php?M=foo&moduleToken=--AnonymizedToken--&param=asdf',
Expand Down

0 comments on commit 3704e20

Please sign in to comment.