Cluster 11 · PCI DSS 6.4.3 · Nginx · add_header always

Nginx Checkout CSP & Security Headers for PCI DSS v4.0.1 Req. 6.4.3 & 11.6.1

Deploy production Nginx Content-Security-Policy, add_header inheritance fixes, per-request $request_id nonce tricks (njs/OpenResty), and CSP report logging for payment pages.

Zero Telemetry · Strict CSP (connect-src 'none') · WebCrypto

Checkout HTML & CSP Header Linter

PCI DSS v4.0.1 Req. 6.4.3 & 11.6.1
Compliance Note: Automated engineering & preparation guidance for PCI DSS v4.0.1 Req. 6.4.3 & 11.6.1 — verify final SAQ/ROC scope with your QSA or acquiring bank.
PCI DSS 6.4.3 & 11.6.1 Readiness Score
100 / 100 (A)
PCI 6.4.3 / 11.6.1 READY
External Scripts
2
Missing SRI/Pin
0
Evergreen PSPs
1
CSP Header
STRICT
Extracted Payment Page Script Inventory
Script / Block Category Status Required Control (SRI vs CSP/Nonce)
https://js.stripe.com/v3/ Evergreen PSP (Stripe.js v3) PASS
Evergreen PSP properly omits static SRI; enforce via strict CSP + Req. 11.6.1 header monitoring.
https://cdn.example.com/[email protected] Static External Script PASS
Pinned static script with valid SRI hash and crossorigin="anonymous".
PCI-643-PSP-OK: 1 evergreen PSP loader(s) classified for CSP/nonce PASS
Detected Stripe.js v3 — correctly distinguished from static CDN SRI.
PCI-643-SRI-OK: All 1 static third-party script(s) carry valid SRI + crossorigin PASS
Cryptographic script integrity verification active.
PCI-1161-REPORT-OK: CSP violation reporting directive present PASS
Supports continuous script-injection anomaly telemetry.
PCI-CSP-ALLOW-OK: All extracted HTML <script> origins match strict CSP script-src PASS
Zero unauthorized or unallowlisted script hosts.
Generated Strict Checkout CSP Template
default-src 'self'; script-src 'self' 'nonce-REPLACE_PER_REQUEST' https://js.stripe.com https://cdn.example.com; style-src 'self'; img-src 'self' data: https:; connect-src 'self' https://api.stripe.com https://r.stripe.com; frame-src 'self' https://js.stripe.com https://hooks.stripe.com; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; form-action 'self'; report-uri https://pay.example.com/__csp-report
PCI DSS v4.0.1 Req. 6.4.3 Script Justification Matrix (CSV)
"Merchant Origin","Script Location / Tag","Category","Authorization Status","Required Control (SRI vs CSP/Nonce)","Current Integrity / Nonce","Business Justification (PCI DSS v4.0.1 Req 6.4.3)","Req 11.6.1 Monitoring Cadence"
"pay.example.com","https://js.stripe.com/v3/","Evergreen PSP (Stripe.js v3)","Authorized","Strict CSP script-src host + 'nonce-...' + Req. 6.4.3 justification (Do NOT add static SRI)","MISSING","Core card tokenization and 3DS2 iframe loader (Stripe.js v3). Evergreen endpoint; SRI unsupported by Stripe — authorize via strict CSP script-src + nonce and monitor via Req. 11.6.1.","Automated weekly or continuous HTTP header + script hash check via CheckoutShield PCI (https://pci.runglab.dev)"
"pay.example.com","https://cdn.example.com/[email protected]","Static External Script","Authorized","SRI (sha384) + crossorigin=""anonymous""","sha384-oqVuAfXRKap7fdgcCY5uykM6+R9GqQ8K/uxy9rx7HNQlGYl1kPzQho1wx4JwY8wC","Pinned external script verified via Subresource Integrity (Req. 6.4.3).","Automated weekly or continuous HTTP header + script hash check via CheckoutShield PCI (https://pci.runglab.dev)"
CheckoutShield PCI · Live Audit $49 PCI Compliance Pack

Monitor Live Checkout Scripts & Ship QSA-Ready Req. 6.4.3 + 11.6.1 Evidence

Need automated HTTP header + script tampering alerts (PCI DSS v4.0.1 Req. 11.6.1) or a tailored CSP, nonce middleware & script justification bundle? Run a free live scan on CheckoutShield PCI (https://pci.runglab.dev), order the $49 CheckoutShield PCI Pack via Creem, or request a PayPal invoice via [email protected].

Platform PCI DSS v4.0.1 Specifications & Controls

Control / Origin Hardened Pattern Req. 6.4.3 & 11.6.1 Rationale
Nginx add_header Inheritance Repeat security headers inside location = /checkout Any child location block with add_header wipes out server-level add_header directives!
always Modifier add_header Content-Security-Policy "..." always; Ensures CSP applies on 4xx/5xx error responses too
CSP Report Logging location = /__csp-report Captures application/csp-report JSON payloads for Req. 11.6.1 alerting
Dynamic Nonce Option ngx_http_sub_module + $request_id (or njs) Replaces CSP_NONCE placeholder cleanly if origin HTML cannot mint nonces

Nginx Production Checkout Location Block (CSP + Header Inheritance Safe)

nginx-pci-checkout.conf
location ^~ /checkout {
  # Repeat ALL security headers whenever a location block defines add_header
  add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always;
  add_header X-Content-Type-Options "nosniff" always;
  add_header X-Frame-Options "DENY" always;
  add_header Referrer-Policy "strict-origin-when-cross-origin" always;
  add_header Content-Security-Policy "default-src 'self'; script-src 'self' https://js.stripe.com https://cdn.example.com; style-src 'self'; img-src 'self' data: https:; connect-src 'self' https://api.stripe.com https://r.stripe.com; frame-src 'self' https://js.stripe.com https://hooks.stripe.com; object-src 'none'; base-uri 'self'; frame-ancestors 'none'; form-action 'self'; report-uri https://pay.example.com/__csp-report" always;

  proxy_pass http://app_backend;
}

location = /__csp-report {
  access_log /var/log/nginx/csp_violations.log;
  return 204;
}

Verify Live Nginx Checkout Headers with cURL

verify-nginx-pci.sh
curl -sI https://pay.example.com/checkout | grep -iE "content-security-policy|strict-transport-security|x-frame-options|x-content-type-options"
# Verify zero 'unsafe-inline' or 'unsafe-eval' and confirm report-uri / frame-ancestors are active.

Step-by-Step Hardening & Key Insights

  1. Audit every Nginx server{} and location{} block so child add_header rules never drop parent CSP or HSTS headers.
  2. Append the always parameter on every security header in Nginx.
  3. Move any inline checkout scripts into external JS files covered by 'self' + SRI, or inject dynamic nonces via your app / njs.
  4. Monitor /var/log/nginx/csp_violations.log and run CheckoutShield PCI weekly under Req. 11.6.1.
  • The #1 Nginx header bug in PCI audits is adding Cache-Control inside a location block — which silently drops server-level Content-Security-Policy and HSTS unless repeated.
  • Always include the always flag in add_header so 400/404/500 responses on payment routes keep CSP protections.
  • Using Nginx's built-in report-uri sink or forwarding logs to your SIEM closes the loop on Req. 11.6.1 tampering alerts.

Common Checkout Audit Pitfalls to Avoid

  • Putting add_header Cache-Control 'no-store'; in location /checkout without repeating Content-Security-Policy.
  • Omitting always on add_header, leaving error responses unprotected.
  • Using $request_id as a nonce while proxy_cache is enabled (causes stale nonce collisions).

More PCI DSS v4.0.1 & SRI Checkout Guides

← Back to PCI & SRI Checker Hub · Cluster 4: Security Headers & CSP → · Cluster 7B: Stripe/Creem Webhook HMAC → · CheckoutShield PCI Live Scan → · $49 PCI Compliance Pack →

Frequently Asked Questions

Why did my server-level CSP header disappear on /checkout in Nginx?

In Nginx, defining ANY add_header directive inside a location block discards ALL add_header directives inherited from the outer server or http block. Always repeat or include a shared headers snippet.

Can Nginx serve CSP-Report-Only alongside enforcing CSP?

Yes — during rollout, emit Content-Security-Policy-Report-Only first, validate zero legitimate breaks in csp_violations.log, then promote to Content-Security-Policy.

Where can I generate full Nginx security headers beyond CSP?

Use Cluster 4 (/security-headers/nginx/) for complete Nginx HSTS, Permissions-Policy, COOP, and CSP configuration.