Formjacking is digital skimming: attackers inject a few lines of JavaScript into an e-commerce site's checkout page, and every customer who pays has their card details quietly copied and sent to the attacker's server. The shopper sees nothing — the payment goes through normally — and the business often learns of it from a bank's fraud team weeks later. It is the web equivalent of a card skimmer glued to an ATM, and the victims are the store, not just its customers.
TL;DR
- Formjacking injects malicious JavaScript into checkout or payment forms to steal card details as customers type them.
- The customer's payment succeeds, so the fraud surfaces weeks later through chargebacks and bank alerts.
- Injection routes: a vulnerable third-party script, a compromised admin account, a malicious extension, or a poisoned supply-chain dependency.
- Content Security Policy, subresource integrity, script allow-lists and MFA on admin accounts are the core defences.
- For awareness programs, formjacking is the scam staff and customers meet on the web, not in the inbox — training covers the fake-store and checkout-redirection variants.
What formjacking means in plain terms
Every online checkout is a web form: card number, expiry, CVV. Formjacking adds a hidden listener to that form. When the customer clicks Pay, the form submits normally to the payment gateway — and a second, invisible copy of the same data goes to the attacker's domain. Nothing breaks, no error appears, and the skimmed data is sold or used within days.
Where the code comes from:
- Compromised third-party scripts. The most common route in real incidents: a chat widget, analytics tag or marketing pixel on the checkout page gets compromised, and the skimmer rides in through it.
- Direct site compromise. Stolen admin credentials or an unpatched CMS plugin lets attackers edit the checkout template directly.
- Supply-chain injection. A JavaScript library the site depends on is itself compromised upstream, so the skimmer arrives inside a legitimate update.
- Magecart-style crews are the named actors behind most high-profile cases — the term covers several groups specialising in exactly this skimming pattern since the mid-2010s.
Why formjacking is a business problem, not just a customer problem
The direct cost lands on the store. Payment-card industry rules assign liability for skimmed data to the site whose checkout was compromised: investigation, card-scheme fines, compulsory forensic audits and re-security all follow. Reputationally, the store is the one named in the bank's fraud alerts its customers receive.
The surrounding threat environment sets the stakes: the Australian Signals Directorate logged more than 84,700 cybercrime reports in 2024-25 — one every six minutes — with small business averaging $56,600 per self-reported incident (ASD Annual Cyber Threat Report 2024-2025). For an online retailer, a formjacking incident is squarely in that distribution — and the average incident is long: the code often sits on a checkout page for weeks before anyone notices, skimming every sale in the meantime.
How a formjacking attack runs
- The entry. Attackers obtain a way to change what the checkout page loads: stolen admin credentials (usually phished), an unpatched plugin, or a compromised third-party script.
- The injection. A few lines of JavaScript are added — often obfuscated and loaded from a domain that mimics a legitimate analytics host.
- The skim. Every checkout submission is silently copied to the attacker's collection server. The customer's payment completes normally.
- The quiet period. The code runs for weeks or months, skimming continuously, until a bank's fraud analytics, a researcher, or a customer chargeback surfaces it.
- The aftermath. Forensic investigation, PCI DSS non-compliance findings, card-scheme penalties, and re-issued customer trust.
How to prevent formjacking
- Content Security Policy (CSP) on checkout pages: an allow-list of exactly which script domains may run, so an injected skimmer's domain is blocked by the browser.
- Subresource integrity (SRI) on third-party scripts: the browser refuses a script whose content doesn't match its declared hash — closing the supply-chain route.
- Audit third-party tags quarterly. Every chat widget, analytics pixel and marketing tag on a checkout page is attack surface; remove what you don't need.
- Patch the CMS and plugins on a schedule, with critical patches applied within 48 hours.
- MFA on every admin account — most direct injections start with a phished admin password. Cyber Aware's phishing simulations rehearse exactly those admin-targeted lures and auto-enrol anyone who clicks into same-day remediation.
- Monitor checkout page changes: file-integrity monitoring or an alert on any change to payment templates catches an injection in hours instead of weeks.
- Train the people who hold the keys. The staff who can edit a checkout page are the primary target; human risk reporting shows which roles click and which report, and a security gap assessment evidences whether MFA, patching and monitoring are actually in place.
Signs your site may be formjacked
- Customers report bank fraud alerts after shopping with you — the classic first signal.
- Unknown script domains appear when you inspect the checkout page's network requests.
- The checkout page loads files you cannot identify, or third-party tags you didn't add.
- Card-scheme or acquirer notifications about compromised transactions.
Any one of these justifies an immediate inspection of what scripts your checkout actually loads.
FAQ
What is formjacking in simple terms? Malicious JavaScript hidden in an online store's payment form that quietly copies customers' card details as they pay — the web version of a skimmer on an ATM.
How is formjacking different from phishing? Phishing needs the victim to act on a message; formjacking happens entirely on the store's site without the customer doing anything unusual. One targets people; the other targets code.
Who is liable when formjacking skims customers? The store whose checkout was compromised generally carries the liability under payment-card rules — fines, forensic audits and re-security, regardless of how the code got there.
Can customers tell they've been formjacked? Usually not in the moment: the payment completes normally. The fraud surfaces weeks later as unauthorised charges — which is why banks' fraud analytics, not users, detect most cases.
Does HTTPS protect against formjacking? No. The skimmer runs inside the encrypted page itself, so the padlock says nothing about whether the code on the page is legitimate.
What's the fastest way to check a checkout page? Open the page, list every script domain it loads, and challenge each one: do you know what this script does and who owns it? Anything unrecognised is either removed or allow-listed through a CSP that day.
One last thing
One hour this week closes the most common formjacking door: list every third-party script on your checkout page, remove the ones you can't justify, and put MFA on every admin account that can edit it. Most skimmers ride in through exactly those two gaps — an unjustified script or a phished admin login.
Related guides
- What is a supply chain attack? — the poisoned-dependency route formjacking often uses.
- What is phishing? — how the admin credentials behind most injections are stolen.
- What is a keylogger? — the browser-side cousin that captures the same data from staff machines.