Skip to main content

Risks of Security Header Configuration

Updated today

πŸ” Common and rare risks when modifying headers in .htaccess


πŸ”΄ Common problems

  1. CSS and JS stop loading
    ​

    • If you misconfigure Content-Security-Policy, you could block your own style and script files.
      ​

    • Solution: Make sure to include 'self' and other allowed domains in script-src and style-src.
      ​

  2. Custom fonts don’t load
    ​

    • Blocking font-src in CSP can cause Google or other server fonts not to display.
      ​

    • Solution: Add 'self' and font domains to font-src.
      ​

  3. Broken images
    ​

    • Misconfigured CORS can block images from loading from external servers.
      ​

  4. Errors in APIs and connections to external services

    • If Permissions-Policy or CSP block connections to external APIs, integrations like Google Maps or Facebook Login may fail.


πŸ›‘ Rare but possible risks

  1. Website deindexing in Google
    ​

    • A misplaced X-Robots-Tag: noindex in .htaccess can cause Google to stop indexing your site.
      ​

  2. Problems with WebSockets and real-time applications
    ​

    • Services like live chats or push notifications may be blocked if headers restrict connect-src.
      ​

  3. Conflicts with cache plugins

    • Some Cache-Control configurations in .htaccess may conflict with plugins like WP Rocket or W3 Total Cache, affecting site speed.
      ​

  4. Errors in older browsers
    ​

    • Some modern headers, like Permissions-Policy, may not be recognized by older browsers and cause unexpected issues.


🚨 Why might payment gateways stop working?

Many payment gateways depend on external scripts and secure redirects. A bad header adjustment can block these functions, causing errors in the payment process.

πŸ”΄ Problematic headers for payment gateways:

  1. Misconfigured Content-Security-Policy (CSP)
    ​
    If it blocks scripts or iframes from external providers like Stripe, PayPal or Redsys, the gateway will not load.

    • Example: A too restrictive CSP allowing only 'self' would block scripts from stripe.com.
      ​

    • Solution: Include the necessary domains in script-src and frame-src.

    Header always set Content-Security-Policy "default-src 'self'; script-src 'self' https://js.stripe.com; frame-src 'self' https://js.stripe.com"

  2. Overly restrictive Referrer-Policy
    ​
    Some gateways need to know from which page the user is coming to validate the transaction.
    ​

    • If you use no-referrer, you could block this communication.

    • Solution: Use strict-origin-when-cross-origin.
      ​

    Header always set Referrer-Policy "strict-origin-when-cross-origin"

  3. X-Frame-Options with 'DENY'
    ​

    • If the payment gateway loads in an iframe, this header could block it.
      ​

    • Solution: Use SAMEORIGIN or allow the gateway domain.
      ​

    Header always set X-Frame-Options "SAMEORIGIN"

πŸ”§ How to avoid problems

βœ” Make a backup before modifying .htaccess.
βœ” Test in a staging environment before applying changes to production.
βœ” Use tools like Security Headers and CSP Evaluator to verify your configuration.
βœ” Check if your payment gateway has specific requirements about HTTP headers.

Did this answer your question?