A handful of HTTP response headers reduce the attack surface for clickjacking, XSS, and information leakage at zero performance cost. cPanel does not deploy them by default. Adding them per-account in .htaccess is fast; deploying them globally via Apache include is durable. The careful operator does global with per-account exceptions.
What’s happening
Browsers honor security headers as the site’s instructions for how its content should be handled. X-Frame-Options: SAMEORIGIN prevents the site from being framed in another origin (clickjacking defense). Content-Security-Policy defines what resources may load (XSS defense). Referrer-Policy controls what the Referer header reveals on outbound clicks. X-Content-Type-Options: nosniff prevents MIME confusion attacks. Each is one line.
How to verify
curl -I https://example.com/ | grep -iE "X-Frame|Content-Security|Referrer|X-Content"
grep -ri "X-Frame-Options\|Content-Security-Policy" /etc/apache2/conf.d/
grep -ri "X-Frame-Options" /home/<user>/public_html/.htaccess
If the headers are not on the response, browsers default to the most permissive behavior.
The fix
- Global default in Apache — edit
/etc/apache2/conf.d/security_headers.conf(or create it) with:
These four are safe defaults that break almost nothing.<IfModule mod_headers.c> Header always set X-Frame-Options "SAMEORIGIN" Header always set X-Content-Type-Options "nosniff" Header always set Referrer-Policy "strict-origin-when-cross-origin" Header always set Permissions-Policy "interest-cohort=()" </IfModule> - CSP is harder. A strict CSP breaks most existing sites. Start permissive:
Content-Security-Policy-Report-Only: default-src 'self' https: data:and watch the violation reports. Tighten over weeks. - Per-customer override: a customer who embeds their site in an iframe (a SaaS dashboard, a marketing tool) needs
X-Frame-Options: ALLOW-FROMor a CSPframe-ancestors. Document the override in the per-account.htaccesswith a comment. - EasyApache rebuild: changes to global config files survive a rebuild only if added to the cPanel include system. Use
/etc/apache2/conf.d/userdata/includes or the Apache include editor in WHM. - Test in stage: pre-prod environments should have the headers on first so CSP can be tuned without burning down production.
- Communicate CSP changes: a customer with a JavaScript framework that uses inline scripts will break. Either grant
'unsafe-inline'(defeats the purpose) or work with them to move scripts to external files with nonces.
Stack Harbor deploys security headers as part of the takeover baseline under cPanel server management.