nelmio / security-bundle
Extra security-related features for Symfony: signed/encrypted cookies, HTTPS/SSL/HSTS handling, cookie session storage, ...
Installs: 9 167 092
Dependents: 21
Suggesters: 0
Security: 0
Stars: 656
Watchers: 26
Forks: 88
Open Issues: 34
Type:symfony-bundle
Requires
- php: ^7.4 || ^8.0
- symfony/deprecation-contracts: ^2.5 || ^3
- symfony/framework-bundle: ^5.4 || ^6.3 || ^7.0
- symfony/http-kernel: ^5.4 || ^6.3 || ^7.0
- symfony/security-core: ^5.4 || ^6.3 || ^7.0
- symfony/security-csrf: ^5.4 || ^6.3 || ^7.0
- symfony/security-http: ^5.4 || ^6.3 || ^7.0
- symfony/yaml: ^5.4 || ^6.3 || ^7.0
- ua-parser/uap-php: ^3.4.4
Requires (Dev)
- phpstan/phpstan: ^1.4
- phpstan/phpstan-deprecation-rules: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-strict-rules: ^1.1
- phpstan/phpstan-symfony: ^1.1
- phpunit/phpunit: ^9.5
- psr/cache: ^1.0 || ^2.0 || ^3.0
- symfony/browser-kit: ^5.4 || ^6.3 || ^7.0
- symfony/cache: ^5.4 || ^6.3 || ^7.0
- symfony/phpunit-bridge: ^6.3 || ^7.0
- symfony/twig-bundle: ^5.4 || ^6.3 || ^7.0
- twig/twig: ^2.10 || ^3.0
- dev-master / 3.x-dev
- v3.4.2
- v3.4.1
- v3.4.0
- v3.3.0
- v3.2.0
- v3.1.1
- v3.1.0
- v3.0.0
- v3.0.0-alpha.1
- v2.12.0
- v2.11.0
- v2.10.3
- v2.10.2
- v2.10.1
- v2.10.0
- v2.9.1
- v2.9.0
- v2.8.0
- 2.7.0
- 2.6.0
- 2.5.1
- 2.5.0
- 2.4.0
- 2.3.1
- 2.3.0
- 2.2.4
- 2.2.3
- 2.2.2
- 2.2.1
- 2.2.0
- 2.1.0
- 2.0.4
- 2.0.3
- 2.0.2
- 2.0.1
- 2.0.0
- 1.10.0
- 1.9.1
- 1.9.0
- 1.8.0
- 1.7.0
- 1.6.0
- 1.5.0
- 1.4.0
- 1.3.0
- 1.2.0
- 1.1.0
- 1.0.0
This package is auto-updated.
Last update: 2024-12-16 16:37:54 UTC
README
About
The NelmioSecurityBundle provides additional security features for your Symfony application.
Installation
Require the nelmio/security-bundle
package in your composer.json and update your dependencies:
composer require nelmio/security-bundle
The bundle should be automatically enabled by Symfony Flex. If you don't use Flex, you'll need to enable it manually as explained in the docs.
Features
Read the docs for the details and configuration needed for each feature:
-
Content Security Policy: Cross site scripting attacks (XSS) can be mitigated in modern browsers using a policy which instructs the browser never to execute inline scripts, or never to load content from another domain than the page's domain.
-
Signed Cookies: Specify certain cookies to be signed, so that the user cannot modify them. Note that they will not be encrypted, but signed only. The contents will still be visible to the user.
-
Clickjacking Protection: X-Frame-Options header is added to all responses to prevent your site from being put in a frame/iframe. This can have serious security implications as it has been demonstrated time and time again with Facebook and others. You can allow framing of your site from itself or from anywhere on a per-URL basis.
-
External Redirects Detection: Redirecting from your site to arbitrary URLs based on user input can be exploited to confuse users into clicking links that seemingly point to valid sites while they in fact lead to malicious content. It also may be possible to gain PageRank that way.
-
Forced HTTPS/SSL Handling: This forces all requests to go through SSL. It will also send HSTS headers so that modern browsers supporting it can make users use HTTPS even if they enter URLs without https, avoiding attacks on public Wi-Fi.
-
Flexible HTTPS/SSL Handling: If you don't want to force all users to use HTTPS, you should at least use secure session cookies and force SSL for logged-in users. But then logged-in users appear logged-out when they access a non-HTTPS resource. This is not really a good solution. This will make the application detect logged-in users and redirect them to a secure URL, without making the session cookie insecure.
-
Disable Content Type Sniffing: Require that scripts are loaded using the correct mime type. This disables the feature that some browsers have which uses content sniffing to determine if the response is a valid script file or not.
-
(DEPRECATED) XSS Protection: Enables/Disables Microsoft XSS Protection on compatible browsers (IE 8 and newer).
-
Referrer Policy:
Referrer-Policy
header is added to all responses to control theReferer
header that is added to requests made from your site, and for navigations away from your site by browsers.
Usage
See the documentation for usage instructions.
License
Released under the MIT License, see LICENSE.