Deploy a Content-Security-Policy
Start in report-only mode, observe violations for a week, then enforce. Even a loose policy kills the majority of injected-script attacks.
Content-Security-Policy: default-src 'self'; script-src 'self' www.googletagmanager.com; object-src 'none'; base-uri 'self'+ Platform examples (4)− Platform examples
const nextConfig = {
async headers() {
return [{
source: '/(.*)',
headers: [{
key: 'Content-Security-Policy',
value: "default-src 'self'; object-src 'none'; base-uri 'self'",
}],
}]
},
}import helmet from 'helmet'
app.use(helmet.contentSecurityPolicy({
directives: {
defaultSrc: ["'self'"],
objectSrc: ["'none'"],
baseUri: ["'self'"],
},
}))add_header Content-Security-Policy "default-src 'self'; object-src 'none'; base-uri 'self'" always;/*
Content-Security-Policy: default-src 'self'; object-src 'none'; base-uri 'self'