Content Security Policy (CSP)

How can CSP help meet PCI DSS 4.0 Compliance Requirements?

In the PCI DSS 4.0 specification, published in March 2022, section 6.4.3 sets out requirements for scripts loaded on payment pages.

Section 6.4.3 of PCI DSS 4.0 defines requirements for scripts (typically JavaScript or you could extrapolate that to also mean CSS files, or any other assets loaded that can cause dynamic code execution on the client, check with your PCI QSA) loaded on payment pages. Summarizing the following points:

Script Authorization

CSP or Content-Security-Policy was essentially designed for the purpose of authorizing scripts to run on a page. That makes CSP a great way to help meet parts of PCI Requirement 6.4.3

At a very minimum you can use the script-src or even the default-src directive to control what scripts can load.

A very basic Content-Security-Policy header might look like this:

Content-Security-Policy: script-src; default-src 'self';

In this very basic example we are allowing images, css, fonts, etc to be loaded from 'self' (the same domain as the requested document).

Many CSP implementations will simply use the domain name, but we can actually be more specific and allow only a specific JS file to load:

Content-Security-Policy: script-src;default-src 'self';

You can space seperate as many scripts as you need. Keep in mind that some servers might limit the size of your http response header.

Script Integrity

A great way to ensure integrity of scripts loaded is the Subresource Integrity or SRI feature. Here's an example of loading jQuery with a integrity attribute:


The value of the integrity attribute what we expect the SHA-256 hash of the src attribute ( to be. Browsers that support SRI will perform this verification before executing the script.

This provides a great protection, because if someone were to compromise and alter that script, it would fail to execute as long as that integrity script is present and the browser supports it.

By default when you enable CSP, it will block the execution of inline JavaScript. CSP can be used to provide a hash validation of inline scripts on your page by adding a hash to the script-src directive.

For example, if you have this inline script:


The value of doSomething(); has a SHA-256 hash of RFWPLDbv2BY+rCkDzsE+0fr8ylGr2R2faWMhq4lfEQc= and you can then allow the execution of it like this:

script-src 'sha256-RFWPLDbv2BY+rCkDzsE+0fr8ylGr2R2faWMhq4lfEQc=';

Script Inventory

CSP could be used to keep a list of scripts that are allowed to run, but you'll need to document why each one is required seperatly.


This page was not written by a PCI QSA, use at your own risk. Please consult with your PCI QSA for implementation and compliance advice.

CSP Developer Field Guide

CSP Developer Field Guide

Want to learn the ins and outs CSP? Grab a copy of the CSP Developer Field Guide. It's a short and sweet guide to help developers get up to speed quickly.

Grab a Copy

Struggling to stay on top of security advisories?

Advisory Week is a weekly roundup of all the security advisories published by the major software vendors.