forked from Sylius/Sylius
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
bug Sylius#13765 [Security] Fixes for SVG XSS, wrong cache for logged…
… in users and clickjacking (ernestWarwas, lchrusciel, GSadee, Zales0123, Rafikooo) This PR was merged into the 1.9 branch. Discussion ---------- | Q | A | --------------- | ----- | Branch? | 1.9 | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Related tickets | | License | MIT This PR aims to solve 3 issues: 1. Possibility to inject SVGs with scripts (https://rietta.com/blog/svg-xss-injection-attacks/) 2. Possibility to check admin pages with back button after logging out due to wrong cache'ing configuration 3. Clickjacking while rendering Sylius in iframe (https://portswigger.net/web-security/clickjacking) <!-- - Bug fixes must be submitted against the 1.10 or 1.11 branch(the lowest possible) - Features and deprecations must be submitted against the master branch - Make sure that the correct base branch is set To be sure you are not breaking any Backward Compatibilities, check the documentation: https://docs.sylius.com/en/latest/book/organization/backward-compatibility-promise.html --> Commits ------- 0886078 listener added to finish response with X-Frame-Options sameorigin header c236431 suggested review changes 67de9e8 bug #14 [Security] Clickjacking vulnerability fixed (ernestWarwas) 4b6a77a [UI] Force no-store cache directives for admin and customer account section 691b700 [Maintenace] Test existence of new cache headers 08d0f5a Remove type declarations for properties due to supporting PHP 7.3 94366fd Minor fixes for specs and unit tests of cache control subscribers 5dee3dc [Behat] Add scenarios for securing access to account and dashboard after logging out d4bf36c [Behat] Extract browser element and context afa04e3 Replace str_contains with strpos method to support PHP 7 b00eb51 [PHPUnit] Move subscribers tests to main directory 253f66b bug #11 [Security] Set cache control directives to fix security leak after logging out and using back button (lchrusciel, GSadee) 46ed54b [Security] XSS - SVG file upload vulnerability fixed 6ccc2d6 bug #12 [Security] XSS - SVG file upload vulnerability fixed (Rafikooo)
- Loading branch information
Showing
34 changed files
with
764 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...omer_account/securing_access_to_account_after_using_back_button_after_logging_out.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@customer_account | ||
Feature: Securing access to the account after using the back button after logging out | ||
In order to have my personal information secured | ||
As a Customer | ||
I want to be unable to access to the account by using the back button after logging out | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And I am a logged in customer | ||
And I am browsing my orders | ||
|
||
@ui @javascript @no-api | ||
Scenario: Securing access to the account after using the back button after logging out | ||
When I log out | ||
And I go back one page in the browser | ||
Then I should not see my orders | ||
And I should be on the login page |
17 changes: 17 additions & 0 deletions
17
features/admin/securing_access_to_account_after_using_back_button_after_logging_out.feature
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
@admin_dashboard | ||
Feature: Securing access to the administration panel after using the back button after logging out | ||
In order to have administration panel secured | ||
As an Administrator | ||
I want to be unable to access to the administration panel by using the back button after logging out | ||
|
||
Background: | ||
Given the store operates on a single channel in "United States" | ||
And I am logged in as an administrator | ||
And I am on the administration dashboard | ||
|
||
@ui @javascript @no-api | ||
Scenario: Securing access to administration dashboard after using the back button after logging out | ||
When I log out | ||
And I go back one page in the browser | ||
Then I should not see the administration dashboard | ||
And I should be on the login page |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Behat\Context\Ui; | ||
|
||
use Behat\Behat\Context\Context; | ||
use Sylius\Behat\Element\BrowserElementInterface; | ||
|
||
final class BrowserContext implements Context | ||
{ | ||
/** @var BrowserElementInterface */ | ||
private $browserElement; | ||
|
||
public function __construct(BrowserElementInterface $browserElement) | ||
{ | ||
$this->browserElement = $browserElement; | ||
} | ||
|
||
/** | ||
* @When I go back one page in the browser | ||
*/ | ||
public function iGoBackOnePageInTheBrowser(): void | ||
{ | ||
$this->browserElement->goBack(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Behat\Element; | ||
|
||
use FriendsOfBehat\PageObjectExtension\Element\Element; | ||
|
||
final class BrowserElement extends Element implements BrowserElementInterface | ||
{ | ||
public function goBack(): void | ||
{ | ||
$this->getDriver()->back(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Behat\Element; | ||
|
||
interface BrowserElementInterface | ||
{ | ||
public function goBack(): void; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
src/Sylius/Bundle/AdminBundle/EventListener/AdminSectionCacheControlSubscriber.php
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?php | ||
|
||
/* | ||
* This file is part of the Sylius package. | ||
* | ||
* (c) Paweł Jędrzejewski | ||
* | ||
* For the full copyright and license information, please view the LICENSE | ||
* file that was distributed with this source code. | ||
*/ | ||
|
||
declare(strict_types=1); | ||
|
||
namespace Sylius\Bundle\AdminBundle\EventListener; | ||
|
||
use Sylius\Bundle\AdminBundle\SectionResolver\AdminSection; | ||
use Sylius\Bundle\CoreBundle\SectionResolver\SectionProviderInterface; | ||
use Symfony\Component\EventDispatcher\EventSubscriberInterface; | ||
use Symfony\Component\HttpKernel\Event\ResponseEvent; | ||
use Symfony\Component\HttpKernel\KernelEvents; | ||
|
||
final class AdminSectionCacheControlSubscriber implements EventSubscriberInterface | ||
{ | ||
/** @var SectionProviderInterface */ | ||
private $sectionProvider; | ||
|
||
public function __construct(SectionProviderInterface $sectionProvider) | ||
{ | ||
$this->sectionProvider = $sectionProvider; | ||
} | ||
|
||
public static function getSubscribedEvents(): array | ||
{ | ||
return [ | ||
KernelEvents::RESPONSE => 'setCacheControlDirectives', | ||
]; | ||
} | ||
|
||
public function setCacheControlDirectives(ResponseEvent $event): void | ||
{ | ||
if (!$this->sectionProvider->getSection() instanceof AdminSection) { | ||
return; | ||
} | ||
|
||
$response = $event->getResponse(); | ||
|
||
$response->headers->addCacheControlDirective('no-cache', true); | ||
$response->headers->addCacheControlDirective('max-age', '0'); | ||
$response->headers->addCacheControlDirective('must-revalidate', true); | ||
$response->headers->addCacheControlDirective('no-store', true); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.