Home
/
Use cases
/
Magecart protection

Magecart protection that sees the skimmer in the session

A Magecart skimmer reads the card in your customer's browser and sends it straight to the attacker. Nothing reaches your server, so nothing in your server-side stack can see it. Detection has to happen where the code runs.
TL;DR
Magecart protection
THE ATTACK
Attacker JavaScript on your checkout reads the card fields and posts the contents to a server they control, directly from the visitor's browser.
WHY IT HIDES
The exfiltration never touches your infrastructure. Your WAF sees nothing, your logs show a successful checkout, and the customer receives their order.
WHAT STOPS IT
An inventory of what is supposed to be there, integrity pinned to the payload rather than the URL, and behavioural alerting on scripts that start doing something new.
Short on time? Most skimmers arrive through a compromised vendor you already approved, which is why an origin allowlist alone does not help. CSP vs script monitoring.
ON THIS PAGE

What is Magecart?

Magecart is the umbrella name for a set of cybercriminal groups that inject malicious JavaScript into ecommerce checkout pages to steal payment card data as customers type it, a technique also called web skimming, e-skimming or formjacking. The name comes from early campaigns targeting Magento stores, and it is now used loosely for the whole category rather than one group. The defining characteristic is where the theft happens: in the customer's browser, on a page that otherwise works perfectly. Because the stolen data is posted from the browser directly to the attacker, the transaction completes normally and neither your server logs nor your network controls record anything unusual.

How a Magecart attack actually works

The attacker does not need your server. They need one script on your checkout, and there are three common ways to get one:
01
Compromise a vendor
Breach a third party whose script you already load and change what it does. Your allowlist passes, your CSP passes, and the origin is one you approved. Polyfill.io in 2024 is the large-scale example: one script domain changed owners and served malicious code to more than 100,000 sites.
02
Compromise your tag manager
A tag container injects arbitrary JavaScript by design. An attacker with access needs no codebase access, no deploy and no code review.
03
Exploit your own site
A vulnerable plugin, an outdated platform or an exposed admin account, used to add a script to the page directly. The classic Magento route, and still current: in 2024 the CosmicSting flaw was used to plant skimmers on about 5% of all Adobe Commerce and Magento stores.
The alert queue: n0rthwind.com at 10.0 Critical with its payment skimmer and the flagged destination it sent data to, then Google Tag Manager at 8.0 High, each with the domain and Allow, Remediate… or Block
The exfiltration never touches your server, so a WAF never sees it. The request happens in the visitor's browser, which is the only place it can be observed.

Why it is invisible to the rest of your stack

The skimmer reads the card field in the browser and posts it from the browser to a server the attacker controls. That request never traverses your infrastructure. Your WAF has nothing to inspect. Your server logs record a normal, successful checkout, because the checkout genuinely succeeded: the customer paid, the order shipped, and the card was copied on the way through.
This is why the average dwell time for these attacks is measured in weeks or months rather than hours. Nothing breaks. There is no outage, no error rate, no failed payment. The first signal is usually a common point of purchase report from an acquirer, which arrives long after the damage.

Magecart mitigation that works in practice

Three controls, in the order they earn their place:
01
Know what is on the page
You cannot detect an unexpected script without a definition of expected. The inventory is the control that makes everything downstream possible, which is also why 6.4.3 exists.
02
Pin the payload, not the URL
A compromised vendor serves malicious code from an approved address. Integrity by payload hash catches this; an origin allowlist does not.
03
Watch behaviour, not just identity
A script that suddenly starts reading form fields or posting to a new destination is worth an alert even if it is a script you approved last quarter.
See every script on your checkout, including the ones your vendors loaded.
Start for free
See pricing

The part that defeats periodic scanning

Skimmers are written to be rare. Common triggers: only on the checkout URL, only when the page contains a card field, only for a card BIN range worth stealing, only outside the attacker's working hours, and never when the browser looks automated. A crawler arriving from a datacentre IP with no session and no cart is exactly the visitor the payload is written to ignore.
A targeted payload that fires for 1 in 1,000 sessions: sampled scanning misses it, monitoring every session catches it.
A targeted skimmer fires for a slice of traffic: one country, one card BIN, one hour. Sampling is the norm in this category, commonly 10% of sessions and sometimes as low as 1%. That is a coin flip against an attack designed to be rare.
Reporting from every real session inverts that. The one visitor who triggered the payload is the one whose session reports it, which is the only reliable way to catch something engineered to be uncommon.
Related
Web skimming and e-skimming
What is Magecart
Requirement 6.4.3
The DebugBear compromise

Frequently asked questions

Read the FAQ
No, and this is the single most important thing to understand about this attack class. A web application firewall inspects traffic arriving at your application. A skimmer reads the card in the browser and posts it from the browser to the attacker's server, so that traffic never reaches your infrastructure and there is nothing for the WAF to examine.
Partly, and it is worth running one. A CSP restricts which origins may load scripts and where they may send data, so it raises the cost of the attack. It does not help when the malicious code arrives from an origin you already allowed, which is what happens when a vendor you trust is compromised. That is the most common Magecart route, so CSP alone leaves the main path open.
Typically far too long: weeks to months is common, because nothing visibly breaks. Payments succeed, orders ship, and error rates do not move. Many merchants first learn about it from an acquirer or card brand raising a common point of purchase, by which point the exposure window is already large.
Yes. A block matches a script URL, a host or a domain, and blocking a vendor stops every resource it serves. When you need a vendor's script to keep working, vendor guardrails, on Pro, let you allow its scripts but limit what they can do, such as touching the payment form.
That is the normal case, and it is the reason periodic scanning struggles. Payloads commonly check the URL, the presence of a card field, the card BIN range, the time of day, and whether the browser looks automated. Reporting from 100% of real sessions means the visitor who triggered it is the one who reports it.
Yes, still active. The tooling and the hosting have changed, and the underlying economics have not: checkout pages load third-party code, third parties get compromised, and card data is valuable. The two new PCI DSS requirements exist precisely because the card brands consider this an ongoing and growing problem rather than a solved one.
Reduce what can run on the checkout, then watch what does. Remove scripts you cannot justify, keep a strict Content Security Policy, use Subresource Integrity on static files, lock down who can publish to your tag manager, and monitor every script on the payment page so a new or changed one alerts someone the same day. Prevention reduces the odds; detection is what limits the damage.
A client-side security tool that works in the visitor's browser, because that is where the skimmer reads the card and sends it out, and a WAF never sees that traffic. Script Monitoring is built for this: one first-party tag, first in the head, records every script in 100% of real sessions, flags a script that reads payment fields or sends data to a new host, and blocks a script, host, domain or vendor on every page within a minute with no deploy. The tag makes a blocked script inert before the browser runs it. It has a free plan and published pricing. It is not a WAF and does not replace one, and it covers web pages, not a native app checkout.
Real user monitoring. A skimmer that fires only for some countries, some card ranges or a small share of visitors stays quiet for a synthetic scanner, which visits from a datacentre address with no real session. Script Monitoring is real user monitoring: the tag runs in 100% of real sessions, so the visitor the skimmer targets is the one whose browser records it. Our Agentic Web Scanner is synthetic and fills gaps where you cannot add a tag; it is not a substitute for the tag.
Remove every script from the checkout that does not need to be there, keep the rest updated, and use a tool that watches the checkout for you: lists every new script for review and emails you when one looks dangerous. Script Monitoring is built to run without a security team: one tag, no DNS or CDN change, alerts by email, AI analysis on Pro that explains what a new script does in plain words, and blocking with one click. It is free for 1,000 page views a month and $99/month on Pro.
Look for what should not be there. Open the checkout in a private window, go through to the payment step, and in your browser's developer tools list every script and every request: an unfamiliar domain receiving data, a script you do not recognise, or a known file that has changed are the signs. Compare with your theme and app list, and check recent changes to your tag manager. If you find something, save the file and logs before removing it, and tell your payment provider. A one-off check only sees what fired for you; Script Monitoring records every script and outbound host in 100% of real sessions, on the free plan too.
Record every real session rather than a sample or a scheduled scan. A skimmer that fires for one visitor in a hundred, or only for some countries, rarely fires for a scanner or a sample, but it does fire in the browser of the visitor it targets. Script Monitoring's tag runs in 100% of real sessions, so that browser records the script, the payment fields it reads and the host it sends data to, and Script Monitoring records a script that reads payment fields or sends data to a new host. An approved vendor that starts reading card fields, or that reads them and sends data to a new host, goes back to Needs review on the PCI DSS page, and a script the rules engine or AI analysis judges malicious raises an email alert, which is on by default for the client-side security use case. It does not stop a script you have not blocked: the review or the alert is what tells you to block it, and a block usually reaches new page loads within a minute or two. The real user monitoring question above explains why scanners miss these skimmers. Start for free.

Watch the short answers

How Do You Detect a Magecart Attack?

A Magecart skimmer reads the card in your customer's browser and posts it straight to the attacker, so nothing breaks and your server logs show a normal checkout. The code is written to be rare: only on checkout, only for some cards and hours, never for automated browsers. This video covers why these attacks hide for months, what British Airways (2018), Polyfill (2024) and CosmicSting (2024) had in common, and the five signals that detect a skimmer in real sessions.

Read the transcript

To detect a Magecart attack, watch the browser, in every session. Look for a script that isn't in your inventory, an approved script whose code changed, a script reading card fields, or data going somewhere new. Why the browser? A WAF inspects traffic arriving at your application. A skimmer reads the card in the browser and posts it from the browser to the attacker, so there's nothing for the WAF to inspect. Magecart is the umbrella name for groups that inject card-skimming JavaScript into checkout pages. Nothing breaks: the payment succeeds and the order ships. The first signal is usually an acquirer reporting a common point of purchase, weeks or months later. And the code is built to be rare. Only on checkout, only when a card field is present, only for some card ranges, at some hours, and never when the browser looks automated. A scanner from a data centre is exactly the visitor it ignores. In 2018, attackers changed a library British Airways already loaded. In 2024, Polyfill served altered code from the same address to over 100,000 sites, and CosmicSting used an unpatched Magento flaw to plant skimmers. Each time, the pages looked normal. So detection has to happen where the code runs. Watch for five signals: a script that isn't in your inventory, an approved script whose payload hash changed, a script reading payment fields, a new outbound destination, and a security header quietly loosened. And watch every session. Sampling is the norm in this category, commonly 10% of sessions. Against an attack designed to be rare, that's a coin flip. Script Monitoring reports from every real session. Prevention helps: remove scripts you can't justify, keep a strict CSP, use Subresource Integrity on static files, and lock down your tag manager. But a CSP can't stop code from an origin you already allowed. Script Monitoring watches every script in every session from one tag, and puts what needs you today on one screen. Script Monitoring is free for 1,000 page views a month. Pro, with AI script analysis, starts at $99 a month, with a 14-day trial. Start for free at scriptmonitoring.com.

Video page with transcriptWatch on YouTube

How Do You Check If Your Checkout Page Has Been Skimmed?

To check a checkout page for a skimmer, go through it the way a customer would: logged out, in a private window, choosing each payment option. List every script that loads, including scripts loaded by other scripts, and every domain the page sends data to. A script nobody can name, one of your own files that no longer matches the release you shipped, an unused tag manager container, or data going to a domain that is not one of your vendors is a lead.

Read the transcript

How do you check if your checkout page has been skimmed? Go through it like a customer, and list every script that runs and every place it sends data. Anything you can't name is a lead. But a check today only shows today. Script Monitoring is one tag that records every script on your payment pages, in every real session, so this check never stops running. Log out, open a private window, and go through checkout, choosing each payment option, card included. In developer tools, list every script that loads, including ones loaded by other scripts. And note every domain the page sends data to. Then look for leads. A script nobody can name. One of your own files that no longer matches the release you shipped. A tag manager container you don't use. Or data going to a domain that isn't one of your vendors. A clean result isn't proof. Skimmers often fire only on checkout, only when a card field is present, only for some visitors, and never for a browser that looks automated. Some hide from logged-in admins. And it says nothing about last week. Nothing breaks during a skim: payments succeed and orders ship. Often the first sign is an acquirer reporting a common point of purchase, weeks or months later. If you find an altered file, treat it as an incident. Save the file and logs first. Restore from a known-good release. Rotate admin and hosting passwords. Patch. And follow your incident response plan, including your acquirer. Then make the next one harder. Remove scripts nobody can justify. Limit connect-src, img-src and form-action in your CSP to destinations you expect. And lock down who can publish to your tag manager. Script Monitoring keeps the record every week, and a block rule stops a script on every page with the tag, usually within a minute, with no deploy. It isn't a WAF, and it covers web pages, not a native app checkout. Free for 1,000 page views a month, Pro from $99 a month. Start for free at scriptmonitoring.com.

Video page with transcriptWatch on YouTube

Start with the scripts already on your checkout.

Install the tag, mark your payment pages, and see the inventory fill in. Free forever on 1,000 page views a month, no credit card.

Free forever plan. No credit card.