Card-skimming script on your checkout? Spot it and remove it
Short answer: A card skimmer is a few lines of malicious JavaScript added to your checkout, often through a hacked plugin, admin account or third-party script, that copies what customers type into the payment form and sends it to an attacker. Signs include customers reporting fraud after shopping with you, unfamiliar script URLs on the checkout page, and code that sends form data to domains you don't use. If you suspect one: take the checkout offline or switch to a hosted payment page, preserve evidence, find and remove the injected code and its entry point, change every credential, then tell your payment provider and follow their incident process.
How skimmers work
OWASP's Third Party JavaScript Management Cheat Sheet cites the original Magecart investigation, which documented payment data being stolen through injected JavaScript. The pattern is simple: any script running on your checkout page can read what customers type into fields that page controls. A skimmer listens for the payment form, copies card number, expiry, security code, name and address, then sends them elsewhere, sometimes disguised as an image request or analytics call.
Common ways in:
- A vulnerable or abandoned plugin or extension on your shop.
- A stolen admin password, or an admin account the attacker created.
- A compromised third-party script, such as a chat widget or analytics tag loaded from someone else's server.
- A tag manager account where someone added a "custom HTML" tag. OWASP's sheet points out that tag-manager containers can run custom JavaScript, so publishing access to them is effectively access to your page code.
Warning signs
- Customer reports. Several customers say their card was misused shortly after buying from you.
- Payment provider contact. Your provider or bank tells you your shop is a "common point of purchase" for fraud.
- Unfamiliar scripts. The checkout page loads a script from a domain you don't recognise, or an existing file has new, obfuscated code appended.
- Odd network requests. In your browser's developer tools, the Network tab shows the checkout sending data to an unknown domain when you type into the payment fields.
- Changed files or settings. Modified theme files, new admin users, new tag-manager tags or new footer scripts in the shop settings that nobody on your team added.
Skimmers often hide: they may only run on the checkout URL, only for some visitors, or only after a delay. Check while logged out, on a phone and on desktop.
What to do immediately
- Stop the exposure. Put the shop in maintenance mode or switch payments to your provider's hosted payment page so card details are never typed on your site while you investigate.
- Preserve evidence. Take copies of the infected files, database tables that store settings or scripts, server and access logs, and screenshots of the network requests. Don't just delete and forget.
- Contact your payment provider. They have an incident process and will tell you what they need from you. Follow their instructions on notification; requirements depend on your location and contracts, so check the rules that apply to you.
- Bring in help if you don't have a developer comfortable with incident response.
Find and remove the code, and the way in
- Compare files with clean copies. Restore your theme, plugins and platform code from trusted sources, or compare against a known-good backup or repository.
- Check stored scripts. Many shops let admins add header or footer scripts in settings; skimmers often live there or in database content, not in files.
- Review tag-manager containers and their version history for tags you didn't create.
- List admin users and remove anyone unknown. Check API keys and integration accounts too.
- Update everything: platform, plugins, themes. Remove plugins you don't use.
- Change credentials: admin passwords, hosting, database, FTP or SSH, tag manager, and payment API keys. Turn on two-factor authentication everywhere.
Removing the script without closing the entry point usually means it returns within days.
Reduce the risk next time
Keep card fields off your page. Payment providers offer hosted payment pages and embedded fields that render in the provider's own frame, so your page's scripts can't read the card data directly. That doesn't make your page unimportant, since attackers can replace the whole form, but it raises the bar considerably.
Fewer scripts on checkout. Strip chat widgets, heatmaps and marketing tags from checkout pages. Every script there is a script that could be compromised.
Restrict where scripts come from. A Content Security Policy limits which domains can load scripts and receive data. MDN's documentation explains that the Content-Security-Policy-Report-Only header lets you monitor violations without enforcing the policy, which is a safe way to discover what your checkout loads before locking it down. Reports need a report-to directive to be sent.
Pin third-party files. OWASP's sheet recommends options such as hosting copies of third-party scripts yourself, Subresource Integrity so the browser rejects altered files, and sandboxing.
Watch for changes. Monitor checkout page scripts and theme files for unexpected changes, and alert on new admin users.
An illustrative example
A hypothetical Dunedin outdoor-clothing shop heard from three customers about fraudulent charges within a fortnight. Its developer found an extra script in the shop's "additional footer scripts" setting that only ran on the checkout URL and posted form data to a lookalike analytics domain. The entry point was an old admin account belonging to a former contractor. The shop switched to its provider's hosted payment page, removed the script, deleted the account, rotated every credential, enabled two-factor authentication and followed the payment provider's incident process.
FAQ
Would antivirus on my computer catch this?
No. The code runs on your website, in customers' browsers.
Is my shop safe if I use a big hosted platform?
Safer, but not immune. Apps, custom scripts and stolen admin logins still create openings.
Should I tell customers?
Follow your payment provider's guidance and check the rules that apply to you.
How often should I check?
After every plugin or theme change, and on a regular schedule, such as monthly.
If you suspect injected code on your checkout or want it hardened before something happens, tell us which shop platform you use.