Cybersecurity

Web Skimming: How Checkout Pages Get Quietly Robbed

A web skimming attack hides a few lines of JavaScript on your checkout page and copies every card typed into it. How it works, the British Airways case, and how to stop it.

F

Force Media Team

8 min read
Shopper holding a payment card and a phone showing a payment screen in front of a laptop

Photo: Michael lima on Unsplash

The orders kept coming in. Payments cleared, parcels shipped, customers were happy. Nothing on the server looked wrong, and no alarm went off. Meanwhile, every card number typed into the checkout was being copied, in real time, to a server the shop had never heard of.

That's a web skimming attack. It's the online version of the card skimmer glued to a petrol-pump reader, except it lives in your website's JavaScript and the customer can't see it at all. Security researchers often call it Magecart, after a loose family of criminal groups who made it famous, or formjacking.

How a web skimming attack works

Your checkout page is assembled in the customer's browser from many scripts: your own code, plus analytics, chat widgets, A/B testing, reviews, fonts and tag managers. Every one of those scripts can read what the customer types. A skimmer is just one more script, or a few extra lines hidden inside a script you already trust.

Anatomy of a web skimming attack

  1. 01

    Get in

    Hacked admin login, vulnerable plugin, or a compromised third-party script

  2. 02

    Plant

    A few lines of JavaScript are added to a script the checkout already loads

  3. 03

    Listen

    The code watches the payment form and copies card details as they're typed or submitted

  4. 04

    Send

    Data is sent to an attacker's server, often on a look-alike domain

  5. 05

    Stay quiet

    The real payment still goes through, so nobody complains

The last step is what makes skimming so damaging: the shop keeps working normally, sometimes for months.

The attacker doesn't need your database or your payment provider. They only need the customer's browser, for a few seconds, on the one page where card details are typed.

Case study: British Airways, 2018

The best-documented web skimming attack is still the one against British Airways, because the UK's data protection regulator, the ICO, published its findings in detail.

22

lines of JavaScript added to a script on BA's site

RiskIQ, via The Next Web

429,612

people whose data was affected

ICO, via Bird & Bird

£20m

final ICO fine, down from a proposed £183.39m

ICO, via Bird & Bird

According to the ICO's penalty notice, as summarised by law firm Bird & Bird, the attacker had access to BA's systems for months. Names, addresses, card numbers and CVV codes were taken for about 244,000 people.

  1. 22 June 2018

    Attacker gets into BA's network

    The ICO dates the breach from here. Its findings include that BA's own policy said it should have used multi-factor authentication for this kind of access.

  2. 15 August 2018

    A look-alike domain gets an SSL certificate

    Researchers later found the skimmer sending data to a server path containing 'baways.com', which had a valid certificate so the traffic looked normal (CSO Online).

  3. 21 August 2018

    The skimmer goes live

    RiskIQ found 22 lines added to a copy of the Modernizr library (version 2.6.2) loaded by BA's site. The data of customers using the site and mobile app was captured (The Next Web).

  4. 5 September 2018

    BA is notified and shuts it down

    BA was told about the data being redirected. It had not spotted the change to its own website code.

  5. 16 October 2020

    The fine

    The ICO fined BA £20 million, after reductions for mitigation and COVID-19 from a proposed £183.39 million.

BA should have had monitoring systems in place which would have detected changes to its website code.

One of the ICO's findings against BA

Two details from the case matter for every online store. First, the attackers changed a common, boring library, the kind nobody reviews. Second, according to RiskIQ, the same criminal family had hit Ticketmaster UK earlier that year (The Next Web). These aren't one-off pranks; they're repeatable businesses.

Why small shops are easier targets

British Airways had a security team and still missed it for two weeks. A small store usually has no one watching its front-end code at all, and a long list of plugins and tags added over the years by different people.

  • Plugins and themes that haven't been updated give attackers a way in. Our guide to WordPress plugin security covers how to choose and maintain them.
  • Third-party scripts loaded from someone else's server can change at any time without you knowing. If that supplier is breached, so is your checkout. We covered this wider problem in software supply chain attacks.
  • Stolen admin passwords let an attacker edit a theme file directly. Credential reuse is a common way in, as we explained in our post on credential stuffing.

The defences that work

1. Keep card fields off your page if you can

The simplest defence is not to have card fields on your own page at all. Most payment gateways offer a hosted payment page (the customer is redirected to the gateway) or hosted fields (the card inputs are iframes served by the gateway). A script on your page can't read inside another domain's iframe.

This reduces the risk a lot, but not to zero. A skimmer on your page can still swap the iframe for a fake form or redirect the "Pay" button. That's why the current PCI DSS rules, below, also cover the page that hosts the payment form.

2. Lock down what the browser may load and where it may send data

A Content Security Policy (CSP) is a response header that tells the browser which sources of scripts are allowed and which servers the page may talk to. A skimmer that can't load, or can't send its stolen data anywhere, is useless.

Here's a starting policy for a checkout page, in a Next.js config. The domains are examples; yours will be your payment gateway and the few services your checkout really needs.

// next.config.js: a strict CSP for the checkout route only
const checkoutCsp = [
  "default-src 'self'",
  // Only your own scripts and your gateway's. No tag managers on checkout.
  "script-src 'self' https://js.examplegateway.com",
  // The card fields live in the gateway's iframe.
  "frame-src https://js.examplegateway.com",
  // Where the page may send data: this is what blocks exfiltration.
  "connect-src 'self' https://api.examplegateway.com",
  "img-src 'self' data:",
  "form-action 'self' https://pay.examplegateway.com",
  "base-uri 'self'",
  "object-src 'none'",
  // Tell you when the browser blocks something.
  "report-uri /api/csp-report",
].join('; ')

module.exports = {
  async headers() {
    return [
      {
        source: '/checkout/:path*',
        headers: [{ key: 'Content-Security-Policy', value: checkoutCsp }],
      },
    ]
  },
}

connect-src, img-src and form-action matter as much as script-src. Skimmers often send stolen data as an image request or a quiet fetch, and those lines are what block them. Start with Content-Security-Policy-Report-Only for a week to see what breaks, then enforce it.

3. Pin third-party scripts with Subresource Integrity

If you must load a script from someone else's server, add an integrity hash. The browser will refuse to run the file if a single byte changes.

<script
  src="https://cdn.example.com/widget/4.2.1/widget.min.js"
  integrity="sha384-<hash of the exact file you reviewed>"
  crossorigin="anonymous"></script>

This only works for versioned files that don't change. If a vendor insists on serving an ever-changing script, think hard about whether it belongs on your checkout.

4. Watch the page, not just the server

The BA attack was a change to a file the site served to customers. File-integrity monitoring on your server, or a service that loads your checkout like a customer and alerts you when its scripts change, would catch exactly that.

What PCI DSS now requires

If you take card payments, the payment industry's security standard now addresses skimming directly. Two requirements in PCI DSS version 4 became mandatory on 31 March 2025 (SecurityMetrics):

RequirementWhat it asks for, in plain language
6.4.3Keep an inventory of every script on the payment page, with a written reason for each. Confirm each script is authorised, and check its integrity.
11.6.1Run a mechanism that detects unauthorised changes to the payment page's scripts and security headers and alerts you. It must run at least weekly, or at a frequency set by a documented risk assessment.

Even if PCI isn't your direct concern because a gateway handles your cards, these two requirements are a good checklist for any page where people type something valuable.

Your checkout security checklist

Before your next sale

  • Use your gateway's hosted payment page or hosted fields, not card inputs you build yourself
  • List every script that loads on checkout, and remove anything that doesn't need to be there (tag managers, heatmaps, chat)
  • Add a Content Security Policy to checkout, starting in report-only mode
  • Pin any third-party script with Subresource Integrity, or self-host a reviewed copy
  • Turn on multi-factor authentication for every admin, hosting and CDN account
  • Keep your platform, theme and plugins updated, and delete the ones you don't use
  • Set up monitoring that alerts you when checkout scripts or headers change

Not sure what's actually running on your checkout page? Ask us for a checkout security review. We'll list every script that loads, tell you which ones can see card data, and help you lock it down.

Speak to our experts

From AI agents to secure, fast websites, we build technology that does real work for your business.

Get in touch
FAQ

Common Questions

Everything you need to know about working with Force Media.

Ask Us Anything
We primarily serve businesses in Sri Lanka and Australia, but our remote-first approach means we can work with clients globally.
Project timelines vary by scope. A standard website takes 2–4 weeks. Custom software projects range from 6–16 weeks depending on complexity.
Yes. All our projects include a support period, and we offer ongoing retainer packages for maintenance, SEO, and feature development.
Absolutely. We specialize in integrating with existing platforms, APIs, and legacy systems to extend their capabilities.