What Is a Magecart Attack on Checkout Pages - Source Defense
RESOURCES / BLOG

What Is a Magecart Attack on Checkout Pages

Magecart attacks use malicious JavaScript on ecommerce websites to steal shoppers’ payment data during checkout. The code can copy information from accessible form fields or present a fake payment form (sometimes called formjacking), then send captured data to an attacker.

Your checkout can continue processing orders while this happens. For your security team, a working payment flow provides little evidence about whether a script is also collecting customer information.

To understand what a Magecart attack does, you need to understand what happens inside the browser, including;

  • How code reaches checkout
  • Which data it accesses
  • What it changes 
  • Where that information goes

What does Magecart mean

Magecart is an umbrella term associated with multiple criminal groups and the payment-data theft techniques they use. The PCI Security Standards Council and Retail & Hospitality ISAC describe both uses of the term.

These malware attacks are a form of digital skimming, also called eSkimming. They can target card numbers, expiration dates, card security codes, and associated customer information.

The label does not establish who carried out an attack or identify a single malware strain. Your investigation needs to establish the actual compromise path and behavior.

How Magecart attacks reach your checkout

The entry point and the theft can happen in different places. An attacker may exploit a website vulnerability or compromise an account used to publish site changes, allowing them to add malicious JavaScript to checkout pages or alter scripts those pages already load.  The resulting JavaScript then runs in your customers’ browsers.

An attacker gains a delivery path

Common routes include vulnerable ecommerce software, compromised plugins, modified website files, and third-party services that deliver JavaScript. Tag manager access can also give an attacker a way to publish code into the checkout experience.

Microsoft’s web-skimming research documents exploitation of ecommerce platforms and third-party components, along with scripts disguised as familiar analytics tools.

First-party hosting can conceal the delivery path. In a September 2026 investigation, Source Defense found malicious JavaScript stored directly on affected merchandise storefronts.

The code activates during the payment journey

An eskimmer may wait for a checkout URL, a payment field, or a customer interaction before acting. A homepage scan can therefore miss behavior that appears later in the purchase journey.

The code may read accessible inputs as they change, collect values when the shopper clicks a button, or display fields controlled by the attacker. Some attacks can capture data even when the shopper abandons checkout or the legitimate transaction fails.

Captured data leaves the browser

Exfiltration means moving stolen information to a destination the attacker controls. The request may resemble ordinary website traffic or use a legitimate service in an unauthorized way.

Source Defense’s Firestore and Braintree investigation documented a skimmer that stored captured information in browser storage, then sent it through Braintree’s sandbox API using customer-profile fields.

The recognizable service name did not establish that the request served a legitimate payment purpose.

Browser behaviors your team should investigate

An e-commerce security investigation should connect a script to the data it accessed and the actions it performed. A domain name or file name provides only part of that context.

Use these behaviors to guide investigation:

Observed behaviorWhat your team should establish
An analytics or marketing script reads payment-field values or captures input eventsWhich fields can it access, and does its approved purpose require those values?
A script adds card fields, hides a payment element, or changes a checkout buttonWas the change approved, which script initiated it, and where do the new fields send data?
Form values appear in browser storageWhich component wrote them, what data was stored, and which script retrieves it?
Data is sent to an unfamiliar endpoint or an unexpected account at a familiar serviceWho controls the destination, and does the request contain information outside its approved purpose?
A script opens a WebSocket connection during checkoutWhich code initiated this persistent connection, and is it being used for code delivery or data transfer?

Source Defense documented several of these behaviors in a GTM-delivered attack combining fake checkout forms and silent eSkimming. The campaign could select a theft method based on the page structure and used separate WebSocket connections for delivery and stolen-data transfer.

Event listeners, browser storage, and WebSockets also have legitimate uses. Treat them as investigation signals. Establish whether the specific data access and transmission were authorized before classifying the activity.

How fake payment forms target hosted checkout

A properly isolated payment iframe limits direct access to its contents. Under the browser’s same-origin policy, JavaScript on the merchant’s parent page generally cannot read fields inside a payment-provider frame from a different origin.

An attacker who controls the parent page may instead hide the legitimate payment element or display a convincing replacement form. Customers enter their card details into the attacker-controlled fields. The attack can then return them to the real payment flow, sometimes with an apparent error or retry request.

This is payment-experience manipulation. It does not require breaking the payment provider’s iframe isolation.

For online payment security, examine the page surrounding the payment component and the steps that lead customers to it. Confirm which script created each payment field and whether the displayed experience matches your approved integration.

Reduce the opportunities for payment information theft

Start with one representative checkout journey and trace it from cart to payment. Use controlled testing and synthetic data to examine script activity during field entry, payment-method selection, validation errors, and submission.

Build your review around the following actions:

Establish script ownership and purpose. Inventory the scripts and dependencies that execute during checkout. Identify who can publish changes through your application, integrations, and tag manager.

Limit access to sensitive fields. Identify scripts whose business purpose does not require payment data. Evaluate controls that can restrict their access while preserving the checkout functions you need.

Verify what your controls enforce. Establish which behaviors produce alerts, which require manual blocking, and which can be restricted automatically. An alert reports activity; the response still needs to stop the unauthorized access or transfer.

Close the original compromise path. If you find malicious code, activate your incident-response process. Preserve relevant evidence while containing exposure, investigate affected journeys and sessions, and address the compromised account, vulnerable component, or publishing process.

Test the restrictions in the actual checkout environment. Confirm that essential payment functions still complete and that unauthorized data access is blocked where enforcement is configured. Repeat relevant checks after changes to scripts, payment integrations, or checkout behavior. 

Control JavaScript behavior during checkout

Magecart investigations require evidence about what code does after it reaches the shopper’s browser. Script approval and familiar infrastructure cannot establish whether each subsequent action is authorized.

Source Defense monitors JavaScript behavior, sensitive-data access, and outbound destinations. Available controls range from on-demand script blocking to granular runtime policies and optional automated enforcement, depending on the selected plan.

Request a demo to examine how your team can identify and restrict unauthorized script behavior in your checkout journey.

Related Reads

Source Defense
Privacy Overview

This website uses cookies so that we can provide you with the best user experience possible. Cookie information is stored in your browser and performs functions such as recognising you when you return to our website and helping our team to understand which sections of the website you find most interesting and useful.