Skip to content
FunnelGuard

Fix guide by FunnelsGuard

Magecart card skimmer on checkout: how to find and remove it

OPS-195High impactPartlyBy FunnelGuardPublished Updated
On this page

What this issue is

Magecart is the common name for web skimming attacks. An attacker gets a line of JavaScript onto your checkout page. The script reads the card number, expiry date and CVV from the form and sends them to a server the attacker controls. The customer still completes the order, so nothing looks wrong.

The script usually arrives in one of four ways: a hacked admin or hosting account, a vulnerable plugin or theme, a compromised third-party script or library you load, or a tag manager container edited by someone who should not have access. It is often tiny, obfuscated (made hard to read) and named to look like analytics.

Why it costs you leads or sales

The direct cost is stolen cards. Customers see fraud on their statements, card brands and your payment provider may investigate, and you can face fines, forced security audits, chargebacks and in the worst case losing the ability to take cards. You may also have legal duties to notify customers and regulators.

The indirect cost is trust. Browsers and security vendors can flag a site as dangerous, which drops traffic and conversions. Because checkout keeps working, skimmers can run for weeks before anyone notices.

How a skimmer steals a card
  1. Attacker gains accessWeak admin password, plugin flaw or tampered third-party script
  2. Script added to checkoutA few lines of obfuscated JavaScript
  3. Customer types cardFields are read as they are typed
  4. Data sent outRequest to the attacker's domain
  5. Order completesLooks normal to you

The order succeeds, so the theft goes unnoticed.

How to check if your site has it

You are looking for scripts or network requests on the checkout that you did not put there. Do this in a normal browser window on your real checkout page, ideally with a test product in the basket.

Inspect the checkout for unknown scripts
  1. List every script domain

    Open the checkout, press F12, go to the Network tab, filter by JS and reload. Write down every domain that is not yours or a vendor you know (payment provider, analytics, chat).

  2. Watch for requests when you type

    Keep the Network tab open, type fake test data into the card fields (never a real card) and look for new POST or image requests to unfamiliar domains.

  3. Search the page source

    View source and search for eval(, atob(, fromCharCode, long encoded strings and script tags with odd domains or recent look-alike names such as google-analytics typos.

  4. Check the tag managerGoogle Tag Manager

    In Google Tag Manager, review Custom HTML tags and the version history for changes you did not make.

  5. Check recently modified files

    On your server or in your theme and plugin editor, look for files changed recently that nobody on your team edited.

  6. Run a malware scan

    Use your platform's or host's malware scanner and compare theme and core files against clean copies.

How to fix it

If you find a skimmer, treat it as a security incident. Act in this order so you stop the theft first and then close the door it came through.

Contain, clean and close the entry point
  1. Stop the data flow

    Take the checkout offline or switch to a hosted payment page of your provider while you clean up. Keep a copy of the malicious code and logs as evidence.

  2. Remove the malicious code

    Delete the script from templates, files, database fields (such as footer or header injection settings) and tag manager tags. Restore changed files from a clean backup or fresh download.

  3. Find the entry point

    Review admin users, recent logins, plugin and theme versions and who can edit your tag manager. Remove unknown accounts and update or delete vulnerable plugins.

  4. Rotate every credential

    Change passwords and API keys for the CMS, hosting, database, FTP/SSH, payment and tag manager. Turn on two-factor authentication.

  5. Tell your payment provider

    Contact your payment provider and acquirer. They will advise on card brand notification, a forensic review and customer notification rules in your country.

  6. Restrict scripts with a CSP

    Add a Content Security Policy that only allows script sources you trust (see the snippet below).

Where to look by platform
  1. Check users and plugins

    Under Users, remove unknown administrators. Under Plugins, delete anything unused or abandoned and update the rest.

  2. Check injected code

    Look in Appearance > Theme File Editor (header.php, footer.php, functions.php) and any header/footer injection plugin settings. Reinstall WordPress core from Dashboard > Updates.

Example Content Security Policy (start in report-only mode)html
<meta http-equiv="Content-Security-Policy-Report-Only" content="script-src 'self' https://js.stripe.com https://www.googletagmanager.com; connect-src 'self' https://api.stripe.com;">
<!-- Adjust the allowed domains to the vendors you actually use.
     Prefer sending the header from the server; move to Content-Security-Policy once reports are clean. -->
Checkout script exposure

Before

  • Any script can load on the payment page
  • Nobody owns the list of scripts
  • Shared admin logins, no 2FA

After

  • CSP allows only named script sources
  • Documented list of checkout scripts with owners
  • 2FA and least-privilege access

How to confirm it's fixed

Confirmation checklist
  • The Network tab on checkout shows only domains you can name and justify
  • No unknown requests fire when you type into test card fields
  • A fresh malware scan is clean
  • Unknown admin users and tag manager tags are gone
  • All passwords and API keys have been rotated and 2FA is on
  • CSP reports show no blocked unknown sources
  • Your payment provider has confirmed next steps

How to prevent it happening again

Skimmers thrive on scripts nobody is watching. Keep the checkout as small as possible and know what runs on it. If you take card payments, standards such as PCI DSS 4.0 ask you to keep an inventory of the scripts on payment pages and to detect unauthorised changes, so check what applies to you.

Prevention habits
  • Use a hosted or iframe payment form from your provider so card fields are not on your own page
  • Keep an inventory of scripts on checkout with a reason and owner for each
  • Remove tags and apps you no longer use
  • Apply a Content Security Policy and Subresource Integrity where you can
  • Limit who can publish in the tag manager and CMS, and require 2FA
  • Update plugins, themes and dependencies promptly
  • Review tag manager version history monthly
How a skimmer can run unnoticed (example)
  1. Day 0

    Example: a plugin flaw lets an attacker add a script to the footer.

  2. Day 1-30

    Example: orders complete normally while cards are copied.

  3. Day 31

    Example: a bank or customer reports fraud linked to your store.

  4. Day 32

    Example: script removed, access closed, provider informed.

How FunnelGuard handles this

FunnelGuard detects this only partly. Its robot visitor runs your real checkout journey on a schedule and the check looks for new third-party domains. Today, a new third-party domain on the checkout is not flagged as a skimmer warning, so a new domain showing up there will not on its own trigger a skimmer alert.

FunnelGuard is not a malware scanner and does not read or judge what a script does, so it cannot confirm that a script is a skimmer. It never enters real card details and stops before payment unless your store's test mode is set up, so it will not see skimming behaviour that triggers only on real card entry.

Cover the rest by hand: keep a script inventory, review the Network tab on checkout after every release, set up a CSP in report-only mode, and watch your tag manager version history. FunnelGuard still helps by catching a broken checkout step or missing tracking hit that follows a bad script change, with a screenshot and a likely cause. The Free plan covers 1 site and 2 journeys with daily checks and no card, and paid plans have a 3-day free trial.

Questions people ask

What is a Magecart attack?

Magecart is the name for web skimming attacks where criminals inject JavaScript into an online checkout. The script copies card details as the customer types and sends them to the attacker. The purchase still goes through, so it is hard to notice.

How do I know if my checkout has a card skimmer?

Open the checkout, press F12 and check the Network tab for script domains and requests you cannot explain, especially when typing into test card fields. Also review page source, theme files, tag manager Custom HTML tags and run a malware scan. Skimmers can hide, so repeat while logged out and with items in the cart.

How do I remove a skimmer script from my website?

Take or switch the checkout to a hosted payment page, delete the malicious code from files, database settings and tag manager, and restore changed files from clean copies. Then remove unknown users, update plugins, rotate all passwords and keys, and tell your payment provider.

How do skimmers get onto a checkout page?

Common routes are stolen admin or hosting credentials, vulnerable plugins or themes, a compromised third-party script or library, and unauthorised edits to a tag manager container. Anything that can add code to the page can add a skimmer.

Does a Content Security Policy stop Magecart?

A CSP can block scripts from unapproved domains and stop data being sent to unapproved destinations, which makes skimming much harder. It is not a complete defence, because an attacker who controls an allowed domain or your own files can still inject code. Use it alongside access controls and monitoring.

Does using Stripe or PayPal protect me from card skimmers?

A hosted payment page or iframe from your provider keeps card fields off your own page, which greatly reduces the risk. Skimmers can still target other pages, redirect customers to fake forms or steal other data, so you still need to control scripts on your site.

Can FunnelGuard detect a Magecart skimmer?

Only partly. FunnelGuard runs your checkout journey on a schedule, but a new third-party domain on checkout is not flagged as a skimmer warning, and it does not analyse script behaviour. Use it to catch broken steps and tracking, and check scripts by hand or with a CSP.

Does FunnelGuard catch this?

Partly

FunnelGuard checks part of this.

How: New third-party domain not flagged.

Stop finding out from your customers

FunnelGuard runs your real forms and checkouts on a schedule, checks the tracking and the leads behind them, and alerts you once, with a screenshot. Try any paid plan free for 3 days.