Why this matters for PCI DSS
PCI DSS 4.0 Requirement 4.2.1 requires strong cryptography on any open network. A first-request HTTP response leaks the session cookie (if cookies aren't Secure) and lets a network attacker downgrade.
Open redirects don't directly steal cardholder data, but they're the standard primitive used in phishing campaigns to make a malicious URL look legitimate (it starts with your domain, then bounces to the attacker's). Phishing leading to credential theft hits Requirement 8.
How to fix it
HTTP → HTTPS redirect (nginx):
server {
listen 80;
server_name example.com www.example.com;
return 301 https://$host$request_uri;
}
Apache:
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule ^(.*)$ https://%{HTTP_HOST}%{REQUEST_URI} [R=301,L]
IIS — install URL Rewrite, then in web.config:
<rewrite><rules>
<rule name="HTTPS Redirect" stopProcessing="true">
<match url=".*" />
<conditions><add input="{HTTPS}" pattern="off" ignoreCase="true" /></conditions>
<action type="Redirect" url="https://{HTTP_HOST}/{R:0}" redirectType="Permanent" />
</rule>
</rules></rewrite>
Pair the redirect with HSTS (Check 3) so subsequent visits skip the HTTP request entirely.
Mixed content — fix by changing http:// to https:// (or to protocol-relative //). For third-party assets you don't control, find an HTTPS-capable replacement or self-host.
A one-line CSP can act as a safety net by upgrading insecure requests on the fly:
Content-Security-Policy: upgrade-insecure-requests
Open redirect — never trust the value. Either:
- Validate that the destination starts with your own origin (
https://example.com).
- Use a numeric ID that maps to a server-side allow-list of redirect targets.
- Show an interstitial page warning the user they're leaving your site.