Content-Security-Policy header missing
Content-Security-Policy tells the browser which scripts, styles and other resources a page may load and run. Without it, any script an attacker manages to inject through a cross-site scripting bug runs with full access to the page and the user's session. The fix is to send a policy from your server or host. A strict policy uses nonces, which in Next.js needs request-time rendering. A policy that limits sources to your own domain, with object-src 'none' and base-uri 'self', is a simpler start. Send it as Content-Security-Policy-Report-Only first so nothing breaks.
The fix
$ curl -sI https://yourapp.com | grep -i content-security-policy
$const csp = [
"default-src 'self'",
"script-src 'self' 'unsafe-inline'",
"style-src 'self' 'unsafe-inline'",
"img-src 'self' blob: data:",
"object-src 'none'",
"base-uri 'self'",
"frame-ancestors 'none'",
].join("; ");
module.exports = {
async headers() {
return [
{
source: "/(.*)",
// Rename to Content-Security-Policy once the reports are clean.
headers: [{ key: "Content-Security-Policy-Report-Only", value: csp }],
},
];
},
};How ShipReady finds it
shipready url requests your page once and reports when the response has no Content-Security-Policy header. Findings carry rule ID SR-WEB-001.
Run the check
npx @shipmate-agency/shipready url https://yourapp.comThe GitHub Action deeflect/shipready@v0.2.0 scans the repo only, so run this check against your deployed site.
Want a person to check every area and send the fixes as pull requests? Launch Lockdown, $950 once.