E-commerce sites have spent years dealing with payment skimming attacks, and the threat shows no sign of slowing. Magecart, the loose grouping of criminal operations that target online checkout flows, continues to evolve techniques that compromise card data through legitimate-looking JavaScript. The pattern is straightforward: malicious code lands on the checkout page, captures card details as customers type them, and exfiltrates the data to attacker-controlled infrastructure. The damage to brand and customer trust outlasts the financial cost by years.
How Skimming Attacks Work
Most successful Magecart attacks compromise a third-party JavaScript loaded by the checkout page rather than the e-commerce platform itself. Analytics tags, customer support widgets, advertising trackers, and various enrichment scripts all execute on the same page as the payment form, with the same access to its contents. An attacker who compromises any of these third parties gains access to every site that loads the affected script. The blast radius can run into the thousands of merchants from a single compromise.
Direct Site Compromise Still Happens
Beyond third-party compromise, attackers also target e-commerce platforms directly through outdated CMS plugins, weak admin credentials, and vulnerabilities in custom code. Once they have access, they inject the skimming JavaScript directly into the site’s templates or stored files. Detection becomes harder because the malicious code lives within trusted assets. web application penetration testing that includes a careful look at the checkout flow surfaces both first-party and third-party risks.
Expert Commentary
Name: William Fieldhouse
Title: Director of Aardwolf Security Ltd
Comments: Skimming attacks are particularly painful because the customer experience appears entirely normal. The card payment processes successfully, the order confirms, and only weeks later do the chargebacks reveal that the data was stolen at point of capture. By that stage the damage has spread to thousands of customers, and the cleanup involves regulators, payment processors, and a great deal of customer communication.

Subresource Integrity Reduces Exposure
Subresource integrity allows a page to specify a cryptographic hash of any external script it loads. If the script changes, the browser refuses to execute it. Used on third-party scripts, SRI prevents silent compromise from automatically reaching your site. The trade-off is that legitimate updates to those scripts also break, requiring a manual hash refresh. For checkout pages specifically, that trade-off is usually worthwhile, since the consequences of silent compromise are severe.
Content Security Policy Adds Another Layer
A well-tuned content security policy restricts which domains a page can load resources from and where it can send data. Properly configured, CSP makes exfiltration significantly harder by blocking outbound connections to attacker-controlled domains. The policy has to be tight enough to be useful but loose enough not to break legitimate functionality, which takes effort to tune. The tuning pays off when an attacker tries to exfiltrate data and finds the browser silently refusing to cooperate.
Payment Iframes Reduce the Attack Surface
Hosting the actual card entry form within an iframe served by a payment service provider, rather than within your own page, removes most of the attack surface entirely. The card data never touches your domain, which means a compromise of your site cannot capture it. PCI DSS scope shrinks at the same time, which simplifies compliance. The trade-off is reduced control over the user experience, but most modern PSP iframes offer reasonable customisation.
Monitoring and Response
Set up integrity monitoring on critical files, alert on unexpected changes to checkout templates, and monitor outbound connections from your servers for traffic to unfamiliar domains. Pair these technical controls with regular reviews and request a penetration test quote specifically focused on payment flows. The detection investment is modest. The cost of a successful skimming campaign is anything but, both financially and in terms of the customer trust that takes years to rebuild.

