Fix Library: Security

Credit Card Skimmer (Magecart) Found on Checkout

Last updated:

What you see

Customers report card fraud after buying from you, or a scanner found unknown JavaScript on your checkout page.

Quick answer

A skimmer is JavaScript that copies card details as customers type them and sends them to the attacker. In Magento it usually hides in configuration, CMS blocks or a changed theme file. Find and remove it, close the hole it came through, and add a Content Security Policy so unknown scripts cannot run on checkout.

What usually causes it?

  1. Script injected into Content > Design > Configuration (HTML head or footer)
  2. Script hidden in a CMS block or page
  3. A changed theme or extension JavaScript file
  4. A compromised third party script loaded on checkout

How do you check it safely?

These checks only read information. Run them on staging first if you can, from the Magento root folder as the file system owner. Hosting setups differ, so paths and service names may need adjusting.

  1. Open checkout in a private window with browser developer tools. In the Network tab, look for requests to domains you do not recognise while you type test card details.
  2. Search configuration and CMS content for scripts.
    SELECT scope, scope_id, path, LEFT(value, 200) AS value
    FROM core_config_data
    WHERE path IN ('design/head/includes', 'design/footer/absolute_footer')
       OR value LIKE '%<script%';
    SELECT block_id, identifier FROM cms_block WHERE content LIKE '%<script%';
  3. Compare theme and extension files with Git, if the code is in a repository.
    git status --short
    git diff --stat
  4. Check whether the Content Security Policy module is enabled.
    bin/magento module:status Magento_Csp

How do you fix it?

These steps change your store. Run them on staging first, with a backup of code and database.

  1. Contain first: disable checkout or enable maintenance mode for customers while you clean up.
  2. Remove the injected script from configuration, CMS content or files, then flush the cache.
    bin/magento cache:flush
  3. Find and close the entry point: missing patches, an unknown admin user or a vulnerable extension. Follow the first 60 minutes checklist.
  4. Rotate admin, hosting, database and payment gateway credentials.
  5. Use the Content Security Policy in restrict mode on checkout. Magento 2.4.7 and later enforce it on payment pages to support PCI DSS 4.0. List every script your checkout needs in a CSP whitelist.
  6. Tell your payment provider. They may require a forensic investigation.

When should you call an expert?

Call an expert straight away if card data may have been stolen. The clean up, the evidence and the report to your payment provider all need to be right the first time.

Need it fixed today?

I can look at it with you. Book a 20 minute call, or if the store is down, see emergency Magento support.

FAQ

Common questions.

Will antivirus or a malware scanner find a skimmer?

Not always. Skimmers are often stored in the database or loaded from another site, where file scanners do not look. A Magento specific scanner and a manual check of checkout are both needed.

Do I have to report a skimmer?

Tell your payment provider. Depending on where you trade, a breach of personal data may also have to be reported to a regulator. Check with your legal adviser.

Rather have it fixed for you?

Send a few lines about the problem, or book a 20 minute call. You get an honest read and a fixed quote.

Book a 20 minute call Reply within a few hours, 7 days a week.