What Is a Magecart Attack? How a Trusted Third-Party Script Steals Customer Data

News desk, CyberRank
News recaps on advisories, outages and incidents that change third-party risk, checked against the sources they cite.
Part of: Supply Chain Security
A Magecart attack is a form of web skimming in which criminals plant code in a website's JavaScript to copy what customers type into payment or login forms, often by compromising a third-party script the site trusts. CyberRank helps you see the risk in the companies behind those scripts by rating each vendor, and each vendor's own suppliers, from one web address in 10–60 minutes.
Executive summary
- Magecart is the name for web-skimming attacks that inject malicious JavaScript into checkout and login pages, and CyberRank rates the vendors and fourth parties whose scripts your site loads.
- Many Magecart attacks never touch the victim's own servers: the attacker changes a script supplied by a chatbot, analytics, testing or CDN provider.
- Since 31 March 2025, PCI DSS requirements 6.4.3 and 11.6.1 require merchants to inventory, authorise and monitor every script on their payment pages.
- Regulators treat a compromised third-party script as the website owner's problem: the UK ICO fined British Airways £20m and Ticketmaster £1.25m in 2020.
What is a Magecart attack?
A Magecart attack is a web-skimming attack that adds malicious code to a website's JavaScript so it copies card numbers or passwords as customers type them, and CyberRank helps you judge the vendors whose scripts make that possible.
Magecart started as the name researchers gave to criminal groups attacking online shops built on the Magento platform. It is now used for any web-skimming attack of this kind, whoever carries it out; there is no single Magecart group. Other names for the same thing are formjacking and client-side attacks, because the theft happens in the customer's browser, not on the shop's server.
The customer sees nothing unusual. The payment goes through, the order arrives, and a copy of the card details goes to the attacker in the background.
How does a Magecart attack work?
A Magecart attack works by changing a script that runs on a payment or login page, and the easiest script to change is often one supplied by a third party, which is where CyberRank's vendor ratings come in.
Because the script comes from a supplier, the website owner's own security checks may never notice the change. This is a software supply chain attack: one compromised supplier, many affected websites. Our guide to supply chain attacks covers the wider pattern, with examples beyond web skimming.
- Find a way in: break into the website itself, or into a supplier whose script the website loads, such as a chatbot, analytics, A/B testing or tag-management provider.
- Change the script: add a few lines of code that read what visitors type into card or login fields.
- Wait: every visitor's browser now downloads the changed script from the trusted source.
- Send the data out: the code posts the copied details to a server the attacker controls, often on a look-alike domain.
- Stay hidden: the page keeps working normally, so the skimming can run for days or weeks.
Magecart attack examples
Well-documented Magecart attack examples show the same pattern, a trusted script changed to leak data, and CyberRank lets you rate the third parties whose scripts sit on your own pages.
In the Ticketmaster case, the ICO said the risk of third-party JavaScript in a payment page had been known for some time, and that Ticketmaster could have kept the chatbot off that page. The lesson for buyers is that a supplier's script is your responsibility once it runs on your site.
| When | Who | What happened | Source |
|---|---|---|---|
| Aug–Sep 2018 | WhoBritish Airways | What happenedAttackers edited a JavaScript file on BA's website so card data entered at checkout was sent to an external domain; the ICO estimated about 429,612 people were affected and fined BA £20m in October 2020 | SourceUK ICO penalty notice |
| 2018 | WhoTicketmaster UK | What happenedMalicious code was inserted into the JavaScript of a third-party chatbot on Ticketmaster's payment page; the ICO fined Ticketmaster £1.25m in November 2020 | SourceUK ICO penalty notice |
| June 2024 | WhoPolyfill.io | What happenedAfter the polyfill.io domain was sold, the widely used script service began serving malicious code; on 27 June 2024 the domain was cut off at the registrar and DNS level | SourceNVD entries CVE-2024-38526 and CVE-2024-38537 |
| Nov 2026 | WhoOptimizely Web Experimentation | What happenedA flaw in the sign-up flow let attackers inject malicious JavaScript into customer projects served from Optimizely's content network; Optimizely says fewer than 5% of customers were affected and the flaw was closed within three hours of detection | SourceOptimizely status page; CVE-2026-132224, CISA KEV (added 24 Nov 2026) |
Why third-party scripts are the weak point
Third-party scripts are the weak point because they run with the same access as your own code but are controlled by someone else, and CyberRank rates those suppliers, and their suppliers, on the same scale as your other vendors.
Scripts from suppliers' suppliers are a fourth-party risk. Our guide to fourth-party risk management explains how to see past your direct vendors, and our article on supply chain attack warning signs covers what an outside view can reveal.
- They are everywhere: a typical commercial site loads scripts for analytics, consent banners, chat, payments, testing and advertising.
- They change without you: the supplier can update a script at any time, and every visitor gets the new version.
- They have their own suppliers: a tag manager may load further scripts from companies you have never heard of, which makes them fourth parties.
- They are rarely in the vendor register: marketing tools are often bought on a card, never reviewed by security.
What PCI DSS and GDPR require for payment page scripts
PCI DSS now requires merchants to control every script on their payment pages, GDPR requires appropriate security for personal data, and CyberRank gives you evidence about the vendors those scripts come from.
These rules make script control a compliance duty, not only good practice. CyberRank supports these obligations; it does not by itself make an organisation compliant.
| Rule | What it asks | Since |
|---|---|---|
| PCI DSS v4.0.1, requirement 6.4.3 | What it asksKeep an inventory of every script on the payment page, with a written justification, and confirm each one is authorised and has not been tampered with | SinceMandatory from 31 March 2025 |
| PCI DSS v4.0.1, requirement 11.6.1 | What it asksDetect unauthorised changes to payment-page scripts and security-relevant HTTP headers, at least weekly or at a risk-based frequency | SinceMandatory from 31 March 2025 |
| PCI DSS SAQ A (revised January 2025) | What it asksMerchants that embed a payment provider's form must confirm their site is not susceptible to attacks from scripts that could affect their e-commerce systems | SinceFrom 31 March 2025 |
| GDPR Articles 5(1)(f) and 32 | What it asksAppropriate security of personal data, including against unauthorised disclosure | SinceSince 25 May 2018 |
How to reduce third-party script risk
You reduce third-party script risk by loading fewer scripts on sensitive pages, controlling the ones you keep and checking the companies behind them, and CyberRank covers the last step.
The practical controls, from script inventories to change detection, are covered in our quick answer on how to protect against Magecart. The consent side is in how to check if a website sets cookies before consent.
- Keep payment and login pages as clean as possible: no chat, advertising or testing scripts unless there is a clear need.
- List every script that remains, who supplies it and why it is there.
- Lock scripts to known versions where you can, and watch for changes.
- Rate the supplier behind each script and put the important ones on monitoring.
- Check consent: scripts that set cookies before a visitor agrees create a privacy problem as well as a security one.
How CyberRank helps with Magecart and third-party script risk
CyberRank helps by rating the vendors whose scripts run on your pages, and their own suppliers, so the companies with access to your customers' browsers are on the same scale as the rest of your supply chain.
CyberRank rates what an organisation exposes publicly, and AI-powered questionnaires add internal evidence where you need it.
- Vendor ratings in 10–60 minutes: security, privacy and AI risk for each script supplier, from its web address.
- Fourth-party vendors: a supplier's own suppliers rated with the same pipeline, with combined risk damped by distance.
- Privacy lens: public privacy policy and consent practices, the area where third-party scripts most often cause problems.
- Monitoring: daily re-scans, darknet monitoring and email alerts when a script supplier's findings change.
- Evidence: an audit-ready PDF report for each supplier, useful for PCI DSS and GDPR vendor files.
Why CyberRank for third-party script risk
CyberRank makes the companies behind your scripts as visible as the companies behind your contracts.
Create a free account to see how your organisation rates.
- Minutes, not weeks: a full security, privacy and AI rating from one web address in 10–60 minutes, with no questionnaires, agents or system access.
- Your whole supply chain in one number: fourth parties rated with the same pipeline, combined risk damped by distance, impact tiers mapped to DORA.
- Twelve risk lenses, one rating: privacy, AI & EU AI Act and quantum risk alongside vulnerabilities, leaked credentials and breach history.
- Pay for vendors, not seats: 20 credits ($20) per assessment, unlimited users; see pricing.
- Certified and proven: ISO/IEC 27001 and 42001 certified; 100,000+ assessments.
References
Primary sources for the outside facts on this page (accessed 25 November 2026), and the CyberRank brochure for CyberRank facts.
- UK ICO: Penalty notice, British Airways (16 October 2020)
- UK ICO: Penalty notice, Ticketmaster UK Limited (November 2020)
- CISA Vulnerability Summary bulletin SB24-183 (CVE-2024-38526, polyfill.io)
- Optimizely status page: Web Experimentation security incident (November 2026)
- NIST National Vulnerability Database: CVE-2026-132224
- PCI Security Standards Council: Important updates for merchants validating to SAQ A (30 January 2025)
- PCI Security Standards Council: Payment page security and preventing e-skimming
- Regulation (EU) 2016/679 (GDPR), Articles 5 and 32, EUR-Lex
- CyberRank Product Brochure 2026 (figures as of Oct 2026)
Quick answers
Short, direct answers to questions this article raises.
- Quick answerHow to Protect Against Magecart AttacksHow to protect against Magecart: fewer scripts on payment pages, script inventories, change detection and vendor checks with CyberRank.
- Quick answerCheck if a Site Sets Cookies Before ConsentHow to check if a website sets cookies before consent, step by step in the browser, what EU law says and how CyberRank flags vendor privacy risk.
Frequently asked questions
Create a free account to see how your organisation rates.
CyberRank rates any organisation from its web address in 10–60 minutes: one IISRI® rating across 12 risk lenses, with no questionnaires, agents or system access. Your first assessment is ready within the hour.