Skip to main content
All Terms Glossary

Magecart Attacks

Definition

Magecart attacks involve injecting malicious JavaScript into eCommerce websites to steal payment card data. These attacks often target third-party scripts and supply chain vulnerabilities. Prevention requires vigilant monitoring of third-party resources, implementing CSP, regular security scanning, and maintaining secure coding practices.

How Magecart attacks work

Attackers rarely breach the store directly. Instead they compromise something the checkout page already trusts, a third-party script like an analytics tag, a chat widget, or a payment library hosted on a CDN, and add a few lines of skimming code to it. When the page loads that script, the skimmer runs in every shopper's browser, listens to the card and address fields, and quietly sends a copy of each entry to an attacker-controlled domain. Because the theft happens in the browser, server logs and traditional web application firewalls see nothing unusual.

Why Magecart is hard to stop

The malicious code lives on a legitimate, allow-listed domain, so a Content Security Policy that trusts that domain will happily execute it. Skimmers also cloak themselves: they check for developer tools, only fire on checkout URLs, and rotate exfiltration domains to evade blocklists. Many campaigns run for months before discovery, and each one puts the merchant on the hook for PCI DSS penalties, card-brand fines, and forced forensic audits.

How cside detects Magecart

cside fetches third-party scripts on our side with the Script Method and analyses the actual JavaScript payload before it executes in the shopper's browser, rather than trusting a script by its source domain. A skimmer injected into an allow-listed vendor script is caught by what the code does, reading card fields or contacting an unfamiliar domain, not by where it came from. When something malicious appears, cside can block it in real time and keeps a forensic record of the exact code that ran, which is what PCI DSS 6.4.3 and 11.6.1 require you to demonstrate.

Definition

How is Magecart different from a server-side data breach?

A server-side breach steals data at rest from a database or backend. Magecart steals it in motion, in the shopper's browser, at the moment of entry, before the data ever reaches your server. That is why server-side tools and WAFs often miss it entirely, and why detection has to happen on the client side.

Definition

Can a Content Security Policy alone stop Magecart?

Not reliably. A CSP restricts which domains can load scripts, but Magecart usually hides inside a script served from a domain you already trust and allow-list. Once that vendor is compromised, the CSP treats the skimmer as legitimate. You need payload-level inspection of what each script actually does, not just where it loads from.

Got more questions

Talk to a security expert

We answer client-side security questions every day. Bring yours.

Book a demo

Want to walk through this with an engineer?

Thirty minutes, on your own site. Not a slide deck.

We'll show you:

Which third-party scripts are running on your site right now
Where you stand on PCI DSS 6.4.3 and 11.6.1
How much of your traffic is bots and AI agents

Rather just send a question?

Finding open slots…

Real humans only. We'd know.

Having trouble booking? Open scheduler in a new tab

What are you trying to solve?

Tell us in a line and we'll come back with something useful, not a generic pitch.

We usually help with:

Seeing which third-party scripts run on your site
PCI DSS 6.4.3 and 11.6.1 evidence
Bots, AI agents and account takeover

Prefer to just book a time? Pick a slot instead