E-commerce websites are attacked more frequently than almost any other category of site. The combination of payment data, customer accounts, and high transaction volume makes them valuable targets for automated attacks. This guide covers the security fundamentals, PCI DSS requirements you actually need to understand, and the tools that keep online stores protected.
Anay Pandya
1,843 words
Anay Pandya
Founder of ZeriFlow · 10 years fullstack engineering · About the author
Key Takeaways
An e-commerce website is not just a website. It''s a system that handles payment card data, stores customer personal information, manages authenticated sessions with financial value, and processes transactions that criminals have direct financial motivation to interfere with.
The result: e-commerce sites face a disproportionately high volume of automated attacks. Credential stuffing attacks targeting customer accounts. Card testing attacks that use your checkout to validate stolen card numbers. Skimming scripts injected into checkout pages. XSS exploits that steal session tokens. Bot traffic probing for admin panel access.
Is your site actually secure?
Run a free check — 60 seconds
This guide covers the specific security concerns for e-commerce in 2026 — what you need to understand about PCI DSS, how to configure your checkout security correctly, and the tools that make ongoing protection manageable.
The math is simple. Stolen customer credentials can be sold or used for account takeover. Successful card testing generates immediate financial fraud. A compromised checkout page can silently exfiltrate payment card data for weeks before detection. Even a brief availability outage during peak shopping periods causes measurable revenue loss.
The 2025 Verizon DBIR reported that financial gain remains the dominant motive for web application attacks, with e-commerce representing the largest category of targeted sites. The attack methods are largely automated — adversaries run bots that probe thousands of sites simultaneously for known vulnerabilities.
What makes this manageable: the vast majority of attacks target known, preventable vulnerabilities. A correctly configured store with up-to-date software, proper security headers, and continuous monitoring is far less attractive than the next site that hasn''t done those things.
PCI DSS (Payment Card Industry Data Security Standard) is the compliance framework for payment card data. The version that applies to you depends heavily on how you handle payment data:
Scenario A: You use Stripe, PayPal, or Square with hosted payment pages
If your customer completes payment on Stripe''s hosted checkout page, PayPal''s checkout, or similar — and card data never touches your server — you qualify for SAQ A (Self-Assessment Questionnaire A). This is the simplest PCI DSS scope. The requirements are:
Most e-commerce stores using major payment processors qualify for SAQ A and can self-assess. You do not need a Qualified Security Assessor (QSA) engagement.
Scenario B: Payment forms are on your pages
If your checkout page hosts a payment form — even if it submits to a third-party processor — you qualify for a higher SAQ level (likely SAQ A-EP or SAQ D). Card data passing through your application''s browser context, even without server-side handling, expands your scope significantly.
The practical recommendation for most e-commerce stores: use Stripe Checkout, Stripe Payment Element, or PayPal''s hosted flows to stay within SAQ A scope. The UX tradeoff (slightly less control over the payment UI) is almost always worth the compliance simplification.
PCI DSS v4.0 introduced requirements that specifically affect e-commerce:
These requirements effectively mandate that you track what JavaScript runs on your checkout pages and detect if it changes. Tools that monitor Content Security Policy violations and script inventory are becoming compliance requirements, not just best practices.
max-age=31536000Tool for this: ZeriFlow monitors SSL certificate expiry and configuration continuously. SSL Labs for one-time deep TLS analysis.
src="http://..." in any template or product image URLMixed content is particularly critical on e-commerce sites. A browser that shows a security warning on a checkout page will lose you sales. A downgrade attack that intercepts an HTTP resource on a payment page is a real attack vector.
Tool for this: ZeriFlow''s Quick Scan includes mixed content detection across your pages.
CSP on payment pages requires careful calibration. Too restrictive and you break Stripe or PayPal''s JavaScript. Too permissive and you''ve defeated the purpose.
Stripe Payment Element CSP requirements:
Content-Security-Policy:
default-src ''self'';
script-src ''self'' https://js.stripe.com;
frame-src https://js.stripe.com https://hooks.stripe.com;
connect-src ''self'' https://api.stripe.com;
img-src ''self'' https://*.stripe.com data:;
style-src ''self'' ''unsafe-inline'';What NOT to do:
# Never use this — it defeats CSP entirely
Content-Security-Policy: default-src *; script-src * ''unsafe-inline'' ''unsafe-eval''The ''unsafe-inline'' and ''unsafe-eval'' directives should be avoided where possible. If you must use them (many e-commerce platforms require them for analytics or chat), use nonces for inline scripts rather than blanket unsafe-inline.
Shopping cart sessions and authenticated customer accounts are valuable targets. A stolen session cookie gives an attacker full access to a customer''s account, including saved payment methods, address book, and order history.
Required cookie attributes for session cookies:
Set-Cookie: session_id=abc123;
Secure;
HttpOnly;
SameSite=Strict;
Path=/;
Max-Age=86400SameSite=LaxWebhook signature verification:
// Always verify Stripe webhook signatures
import Stripe from ''stripe''
const stripe = new Stripe(process.env.STRIPE_SECRET_KEY)
export async function POST(req) {
const body = await req.text()
const signature = req.headers.get(''stripe-signature'')
let event
try {
event = stripe.webhooks.constructEvent(
body,
signature,
process.env.STRIPE_WEBHOOK_SECRET
)
} catch (err) {
return new Response(`Webhook Error: ${err.message}`, { status: 400 })
}
// Process event
switch (event.type) {
case ''payment_intent.succeeded'':
// Handle successful payment
break
}
return new Response(null, { status: 200 })
}Never process payment events without verifying the webhook signature. An attacker who knows your webhook endpoint can send fraudulent payment success events without signature verification.
Client-side key exposure:
- STRIPE_SECRET_KEY must only exist in server-side environment variables — never in the client bundle
- NEXT_PUBLIC_STRIPE_PUBLISHABLE_KEY is safe to expose client-side — it''s designed for that
- Audit your Next.js bundle to confirm STRIPE_SECRET_KEY is not present
Beyond the standard security headers, e-commerce sites have specific requirements:
Permissions-Policy — restrict access to browser features you don''t use:
Permissions-Policy: payment=(self "https://js.stripe.com"),
geolocation=(),
camera=(),
microphone=()The payment directive controls which origins can use the Payment Request API. Explicitly allowing only self and your payment processor prevents malicious scripts from intercepting payment flows.
Cross-Origin-Embedder-Policy and Cross-Origin-Opener-Policy — for pages embedding payment iframes:
Cross-Origin-Opener-Policy: same-origin
Cross-Origin-Resource-Policy: same-originNote: These headers can break third-party payment iframes. Test carefully — some payment processors require same-origin-allow-popups or cross-origin settings for their checkout flows.
/checkout — rate limit by IP and session
/api/payment — rate limit aggressively
/login — rate limit login attempts (5 per minute by IP)
/forgot-password — rate limit to prevent email bombing
/api/cart — rate limit to prevent inventory manipulationZeriFlow is the most relevant tool for ongoing e-commerce site security because it monitors your live site against the exact categories that affect PCI DSS compliance: headers, SSL, cookies, mixed content, and information disclosure.
The monitoring feature is particularly valuable for e-commerce: every deployment creates risk. A new checkout plugin, a theme update, or a CDN configuration change can silently remove a security header. ZeriFlow sends an alert when your security score drops, catching regressions before they become compliance issues.
The white-label PDF report is useful for documenting your security posture for payment processor reviews or enterprise partner security questionnaires.
Use ZeriFlow for: Continuous monitoring, pre-launch checks, compliance documentation, deployment regression detection.
E-commerce platforms often run dozens of plugins and packages. A vulnerable version of a checkout plugin, a payment gateway library, or a UI component can expose your entire store. Snyk monitors your dependency tree and opens pull requests for security updates.
Cloudflare''s Web Application Firewall (WAF) blocks common attack patterns — SQL injection, XSS, credential stuffing — before they reach your application. The free tier includes basic protection; the Pro tier ($20/mo) adds OWASP rulesets and bot management.
For e-commerce sites, Cloudflare Bot Management can significantly reduce card testing attacks and credential stuffing, which are disproportionately common against checkout and login endpoints.
Run SSL Labs on your domain quarterly to verify TLS configuration. It''s free and provides the most detailed TLS analysis available. Target an A+ grade.
Security is not a one-time checkbox. E-commerce site security degrades over time through deployments, plugin updates, configuration changes, and evolving attack patterns.
Weekly: - Review ZeriFlow monitoring alerts - Check Snyk/Dependabot for new vulnerability advisories
Monthly: - Run a full ZeriFlow scan and compare score to previous month - Review error logs for unusual patterns (excessive 401s, scanning behavior) - Verify SSL certificate expiry timeline
Quarterly: - Run SSL Labs TLS analysis - Review third-party scripts running on payment pages - Rotate credentials and API keys that are overdue for rotation - Review admin account access (remove former employees)
Annually: - Full security review against PCI DSS SAQ applicable to your implementation - Dependency audit for outdated packages beyond CVEs (older versions may lack security features even without known CVEs)
Start with a ZeriFlow free scan at zeriflow.com/free-scan to see where your store stands on the fundamentals. The results will show you which items on this checklist need immediate attention.
Related resources
Website Vulnerability Scanner
Run a broader website security audit across headers, TLS, DNS, cookies, SEO, and disclosure checks.
Security Headers Checker
Check CSP, HSTS, X-Frame-Options, and other response headers.
SSL Checker
Review TLS certificate, HTTPS, and transport security signals.
DMARC Checker
Validate email authentication records for domain spoofing protection.
CSP Checker
Review Content-Security-Policy coverage and common gaps.
Monitor your security score
Schedule recurring scans and catch regressions after deployments.