Skip to content
MonSpark home

What is Magecart? How card skimmers get into checkout pages

Magecart is a common name for e-skimming. In this attack, malicious JavaScript on a checkout page copies the card number while the customer types it. The script sends the copy to a host that the attacker controls. The payment still succeeds, so the shopper and the merchant see nothing wrong. PCI DSS v4.0.1 requirement 6.4.3 controls which scripts run on the payment page. Requirement 11.6.1 detects changes to those scripts and to security headers.

What Magecart means

The PCI Security Standards Council (PCI SSC) uses the term e-skimming for data breaches during e-commerce transactions. Its information supplement on payment page security says that these attacks "are also called Magecart or Formjacking". The Council also says that scripts in the consumer's browser "are now a significant target for attackers seeking to steal payment card data".

The attack works because a browser trusts every script on the page in the same way. The supplement explains that a script can read, change or delete page content and react to user input. On a payment page, a script can detect when the consumer types into a card field. A form library uses this ability to validate input. A skimmer uses it to steal data.

How a skimmer steals a card number

Here is a typical silent attack. John Doe buys a jacket from Acme at shop.example. The total is $129.00.

  1. The browser loads the checkout page and every script on it. One of these scripts contains code from the attacker.
  2. The changed script attaches a listener to the card number, expiry date and security code fields.
  3. John types his card details. The script copies each value.
  4. The script sends the copy in a network request to a host that the attacker controls.
  5. The real form submits as usual. John pays $129.00 and gets a confirmation email.

The PCI SSC supplement calls this type silent skimming. It warns that silent attacks "may go undetected for long periods of time", because everything works as expected. In the second type, double-entry skimming, a false payment form shows an error and the consumer types the card again into the real form. The supplement says that this type is often discovered more quickly.

How the skimmer gets onto the checkout page

The supplement says that scripts load from first-party servers and from third-party servers. It names two attack types: supply-chain attacks and script injection attacks. The skimmer uses one of three entry points.

A compromised third-party script

Many checkout pages load scripts for chat, analytics, marketing or payment functions. The supplement warns that attackers who compromise a third-party script "can insert malicious code without the TPSP or merchant immediately noticing". The script tag and the URL on the merchant page stay the same. Only the content that the vendor serves is different. A third-party script can also load more scripts from fourth parties and beyond. Each link in that chain is a possible entry point.

A tag manager

The supplement lists tag management among the script types that attackers can manipulate to capture payment data. A tag manager loads other scripts from a configuration. A person with access to that configuration can add a script to the checkout without a code release. Thus a stolen tag manager login can put a skimmer on the page without access to the web server.

Changed first-party code

An attacker with access to the web server, the build system or the deploy account can edit the merchant's own JavaScript. The British Airways case below is an example of this entry point.

Two public cases

British Airways, 2018

The UK Information Commissioner's Office (ICO) describes this case in its penalty notice of 16 October 2020:

  • Between 22 June and 5 September 2018, an attacker got access to an internal BA application. The attacker used compromised credentials for a Citrix remote access gateway.
  • The attacker moved across the network and edited a JavaScript file on britishairways.com.
  • The edited code copied payment card data and sent it to BAways.com, a domain that the attacker controlled.
  • The code was active for 15 days, from 21 August to 5 September 2018. The booking and payment flow worked as usual during that time.
  • On 5 September 2018, a third party informed BA that data went to BAways.com.

The ICO found that BA "has not identified any technical or organisational measure it had in place to detect unauthorised changes to its website code". The notice quotes requirement 11.5 of PCI DSS v3.2.1, the change-detection requirement of that time. On BA's estimate, the attacker potentially accessed the personal data of about 429,612 people. The ICO fined BA £20m.

Ticketmaster UK, 2018

The BBC reported on 13 November 2020 that the ICO fined Ticketmaster UK £1.25m. The investigation found a vulnerability in a third-party chatbot from Inbenta Technologies. Ticketmaster had installed this chatbot on its online payments page. An attacker used the chatbot to access customer payment details.

The ICO said that the attacker potentially stole personal data and payment details of more than nine million customers in Europe. Several banks and card companies warned Ticketmaster of suspected fraud. According to the ICO, Ticketmaster took nine weeks to start to monitor activity on its payments page. Ticketmaster said that it would appeal. In June 2018, Ticketmaster said that the breach likely affected UK customers who bought tickets between February and 23 June 2018.

At BA, the attacker changed first-party code. At Ticketmaster, a third-party widget on the payment page was the way in. In both cases, outside parties raised the alarm: a third party at BA, and banks and card companies at Ticketmaster.

Which control stops which step

The table maps each attack step to controls from the PCI SSC supplement and the browser standards.

Attack step Control What the control does
A new script appears on the payment page Script inventory and authorization Only scripts with an approval and a justification belong on the page.
An approved script changes Integrity checks: file hashes, Subresource Integrity (SRI) The browser refuses a file that does not match its hash, or a monitor reports the change.
A script reads the card fields Isolation in a cross-origin iframe, behavior monitoring Scripts on the parent page cannot read fields inside the iframe. A monitor sees unexpected field reads.
The data leaves the page Content Security Policy (CSP), behavior monitoring The connect-src directive limits the URLs that scripts can send requests to.
The attacker gets into the server or build Access control and change detection Strong authentication and file monitoring stop or show the edit.

Each control has limits. The supplement says that SRI is not practical for third-party scripts that change often. It also says that SRI "fails silently" and does not report. A CSP cannot alert on changes to security headers. It also cannot see a change inside an approved script, unless that script contacts a domain that the policy does not allow.

How PCI DSS 6.4.3 and 11.6.1 relate

The supplement gives the text of each requirement.

Requirement 6.4.3 applies to all payment page scripts that load and run in the consumer browser:

  • A method confirms that each script is authorized.
  • A method assures the integrity of each script.
  • An inventory of all scripts exists, with a written business or technical justification for each one.

Requirement 11.6.1 asks for a change and tamper detection mechanism. The mechanism alerts personnel to unauthorized changes to the security-impacting HTTP headers and the script contents of payment pages "as received by the consumer browser". It runs at least weekly, or at a frequency from the entity's targeted risk analysis.

The PCI SSC confirms that these requirements were best practices until 31 March 2025. After that date, they are mandatory in a PCI DSS assessment. They appear in SAQ A-EP, SAQ D for Merchants and SAQ D for Service Providers. SAQ A does not include them, but it has an eligibility criterion: the merchant confirms that its site is not susceptible to attacks from scripts that could affect its e-commerce systems.

The BA skimmer ran for 15 days. A weekly check has two chances in that time to see the change. The supplement also warns that changes "could persist without detection" between checks. It recommends frequent or real-time monitoring where feasible.

Protect your checkout with MonSpark

MonSpark Client-Side Protection finds every script on your payment pages and keeps each version for your auditor. It compares the content of each script, not only its URL. A new, changed or removed script, or a changed header, opens an incident. The page agent can also stop scripts, card field reads and requests that you did not approve.

Book a demo to see the scripts on your own checkout and what 6.4.3 and 11.6.1 need from you.