A card skimmer, often called Magecart, is a small piece of JavaScript that copies what customers type on checkout, including card details, and sends it to the attacker. The store keeps working normally, so a skimmer can run for months before anyone notices. Usually the first sign is a bank or a customer reporting fraud.

Where skimmers hide in Magento

Attackers like places that load on every page and that nobody reviews in code:

  • Design configuration: the HTML head and footer fields under Content > Design > Configuration, stored in core_config_data.
  • CMS blocks and pages, especially blocks shown in the footer.
  • Email templates, sometimes with template injection code.
  • JavaScript files in pub/static or a theme, edited directly on the server.

Search the database

Look for script tags in the places above. Most stores have few or none, so every result deserves a look:

SELECT config_id, path, scope, scope_id FROM core_config_data
 WHERE value LIKE '%<script%' OR value LIKE '%eval(%' OR value LIKE '%atob(%';

SELECT block_id, identifier, is_active FROM cms_block WHERE content LIKE '%<script%';
SELECT page_id, identifier, is_active FROM cms_page WHERE content LIKE '%<script%';

Check every script that loads from a domain you don’t recognise. Skimmer domains are often made to look harmless, imitating analytics or payment services.

Check what the browser actually loads

Open checkout in a private window with developer tools on the Network tab and place a test order. Look for requests to unknown domains, especially ones sent when you type in the card fields or press “Place Order”.

Removing it

  1. Copy the malicious code somewhere safe as evidence, then remove it from the admin field, CMS block or file.
  2. Flush the cache so the clean version is served: bin/magento cache:flush.
  3. Find how they got in. Removing the script without closing the entry point means it will be back within days. Look for new admin users, unknown PHP files (see PHP backdoors in pub/media) and missing security patches.
  4. Change all admin passwords, enable two-factor login, and rotate the database password and encryption key.
  5. Run a full malware scan, for example Sansec eComscan.

Legal duties

If card data may have been stolen, you may have to notify your payment provider and, depending on your country, customers or authorities. Talk to your payment provider early.

Prevent it

  • Keep Magento patched every month.
  • Use a strict Content Security Policy on checkout, so the browser refuses scripts from domains you haven’t approved.
  • Check the head, footer and CMS fields automatically, not once a year during an audit.

Catch it automatically

MageMonitor checks for this every few minutes as part of its Security Center checks for injected JavaScript, and alerts you by email, Slack or webhook the moment it appears, with the exact commands to fix it. See MageMonitor for Magento 2.

Related fixes