yireo / magento2-disable-csp
Disable CSP
Package info
github.com/yireo/Yireo_DisableCsp
Type:magento2-module
pkg:composer/yireo/magento2-disable-csp
Requires
- php: >=8.2 <8.6
- magento/framework: ^100.0|^101.0|^102.0|^103.0
- magento/module-csp: ^100.4.5
- magento/module-deploy: ^100.4
- magento/module-require-js: ^100.4
Requires (Dev)
None
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
For shops that don't need CSP to be enabled, this module offers a quick solution. Just install and enable the module and you're done.
Technically, it replaces the default implementation of Magento\Csp\Api\CspRendererInterface with a dummy. Next, it disables the Subresource Integrity (SRI) features of the Magento_Csp module: The DI plugins that generate, store and apply integrity hashes (including the Magento 2.4.9 plugins that add integrity attributes to merged scripts and position the SRI hashes in the head), the integrity post-processor of bin/magento setup:static-content:deploy, plus the sri.js script and the window.sriHashes block on the checkout, the multishipping checkout and the admin order creation page.
Security considerations
Before using this module, be aware of what you are giving up:
- No
Content-Security-Policy(orContent-Security-Policy-Report-Only) header is sent anymore, in all areas, including the Magento Admin Panel. Violations are no longer reported either. - No
integrityattributes are added to scripts on payment pages anymore. - PCI DSS 4.0 requirements 6.4.3 and 11.6.1 require you to manage and monitor scripts on payment pages. With this module enabled, you need an alternative way to meet these requirements.
If you only want to get rid of blocked resources without losing insight, consider using the report-only mode of Magento instead:
bin/magento config:set csp/mode/storefront/report_only 1 bin/magento config:set csp/mode/admin/report_only 1
Any previously generated pub/static/*/sri-hashes.json files are no longer used by Magento with this module enabled and can be safely removed.
Usage
composer require yireo/magento2-disable-csp bin/magento module:enable Yireo_DisableCsp
Remark
The magento/module-csp package is still necessary and should not be removed via composer replace.
Alternatives
- Wouyang_DisableCsp
- Disables the
csp_renderobserver
- Disables the
- baldwin-agency/magento2-module-csp-shim
- Overrides the Magento CSP module itself and its namespaces (ugly)