Home
/
Blog
/
Attacks

What is formjacking?

The mechanism behind most card skimming: two implementations, each with a different structural fingerprint and a different detection route.
TL;DR
Formjacking
WHAT IT IS
Malicious code that hijacks a web form to capture what a visitor types, most commonly payment card details at checkout.
TWO IMPLEMENTATIONS
Listen to the existing form, or replace it with an identical one you control and pass the data through.
RELATION TO OTHER TERMS
Formjacking is the mechanism. Web skimming is the outcome. Magecart names the groups. They describe the same incidents.
Short on time? The replaced-form variant is harder to see and easier to detect structurally.

What is formjacking?

Formjacking is an attack in which malicious JavaScript takes control of a web form so that the information a visitor types into it is copied to an attacker before, or as well as, reaching its intended destination. The term describes the mechanism rather than the target, so formjacking can apply to any form worth stealing from: a checkout, a login, an insurance quote or a patient intake form. In practice it is most associated with payment pages, where it is the mechanism behind what is otherwise called web skimming, e-skimming or a Magecart attack.
The alert queue: n0rthwind.com at 10.0 Critical with its payment skimmer and the flagged destination it sent data to, then Google Tag Manager at 8.0 High, each with the domain and Allow, Remediate… or Block
Blocks match a script URL, a host or a domain, and blocking a vendor stops everything it serves, on every domain in your team.

The two implementations

1
Listen to the existing form
The script attaches event listeners to the real inputs and reads values on keystroke, change or submit. The form on the page is genuinely yours, so it looks correct in the DOM. Detection comes from noticing which script is reading those fields.
2
Replace the form
The script removes your form and inserts a visually identical one it controls, collects the data, then forwards it so the purchase completes. Visually indistinguishable, and structurally obvious: the form is no longer the one your application rendered.

Why it works so well

JavaScript on a page has full access to the DOM of that page. There is no privilege boundary between the script you wrote and the script your analytics vendor's vendor loaded. Both can read any input on the page. The browser has no concept of 'this script is allowed to touch the card field and that one is not', which is precisely the gap PCI DSS 6.4.3 is trying to close administratively.
Most tags on a checkout have no reason to touch the card field.

Detecting each variant

Signal
Catches listener variant
Catches replaced-form variant
Script reading payment inputs
Yes, directly
Yes
Form structure differs from what was rendered
No
Yes, clearly
New outbound destination
Yes
Yes
Unapproved script in the inventory
Yes, if the script is new
Yes, if the script is new
Changed payload hash on an approved script
Yes, compromised-vendor case
Yes

Vendor guardrails rather than removing the script

The useful middle option on a payment page: allow a vendor's scripts but limit what they can do, such as reading form fields. Most tags on a checkout have no legitimate reason to touch the card input, and deciding what each vendor may do on your pages is a smaller and more defensible action than removing a vendor the business wants. Vendor guardrails are on Pro and Enterprise.
In the docs
How to do this in Script Monitoring: Respond to a malicious script walks through blocking a flagged script from its alert, checking which pages it ran on and confirming the block.
Sources and methodology
PCI DSS requirement text is quoted from PCI DSS v4.0.1 (June 2024), published by the PCI Security Standards Council, which is the current version at the time of writing. Requirements 6.4.3 & 11.6.1 became mandatory on 31 March 2025. Where we describe a competitor, we describe publicly available information and say so when something should be verified with the vendor. We publish this product and that is a bias worth knowing about while you read.
ASK AN AI
Don’t just take our word for it
Ask your assistant what to look for in a tool for PCI DSS 6.4.3 & 11.6.1.

Frequently asked questions

Yes in practice. Formjacking is the mechanism and Magecart names the groups who use it. An incident described as Magecart is almost always formjacking underneath.
No. Any form worth stealing from can be targeted: logins, insurance quotes, patient intake, account registration. Payment forms attract the most attention because card data has immediate resale value.
Partly. A CSP can prevent an unlisted origin loading a script and can restrict where data is sent, which helps. It cannot tell you that an allowed script is reading your card field.
By passing the data through: the attacker's form collects the details, then submits them to the real endpoint so the purchase completes and the customer receives their order. Nothing appears wrong from the customer's side.
Partly, and it raises the cost. Client-side encryption of field values means a listener captures ciphertext rather than a card number. A script that replaces the form controls the encryption step too, so it is not a complete answer.
No, and that is what makes it difficult. The usual route is a compromised third-party script or tag manager, so your own infrastructure is untouched and your logs show nothing.
Yes. Browser autofill populates fields programmatically, and a listening script sees those values the same way it sees typed ones.
Quickly, which is part of the problem. Skimmer kits are sold ready to configure, so the time between compromising a script and collecting card data can be minutes.
Blocking, at whichever level fits: one script by URL, everything from a host or domain, or every resource a vendor serves. If you need the script to keep working, vendor guardrails (on Pro) let you allow it but limit what it can do, such as reading form fields.
Yes, it is the attack requirements 6.4.3 & 11.6.1 were written to address. 6.4.3 asks you to know and authorise every script on the page; 11.6.1 asks you to detect when the page changes.
Limit which scripts run on pages with forms, watch the ones that do, and act fast. A strict Content Security Policy, Subresource Integrity on static scripts, and monitoring that alerts when a script starts reading form fields or posting to a new destination cover most cases. Blocking the script, or Magecart protection more broadly, stops it once found.

Watch the short answer

What Is Formjacking? How Checkout Forms Get Hijacked

Formjacking can hit any form worth stealing from, but it is most associated with card numbers at checkout. This video explains the two implementations (listening to your real form, or replacing it with an identical one that passes the data on), why the browser lets any script read any input, why your servers and logs never see it, and the five signals that catch each variant. It also covers where a Content Security Policy helps and where it stops, and how vendor guardrails (on Pro) let you keep a vendor but stop it reading the card field.

Read the transcript

Formjacking is an attack where malicious JavaScript takes control of a web form, so whatever a visitor types is copied to an attacker. It can hit any form, but it's most associated with card numbers at checkout. The name describes the mechanism, not the target. So it can hit any form worth stealing from: a checkout, a login, an insurance quote, a patient intake form. Card forms get the most attention because card data resells immediately. You'll hear three names for this. Formjacking is the mechanism. Web skimming is the outcome. Magecart names the groups. They describe the same incidents. There are two ways it's done. The first listens to your real form, reading the inputs as they're typed or submitted. The form really is yours, so the page looks correct. The second replaces your form with an identical one the attacker controls. It collects the card, then passes it on, so the purchase completes and the customer gets their order. Nothing looks wrong. Why does it work? Any script on a page can read any input on that page. There's no boundary between the code you wrote and the script your analytics vendor's vendor loaded. And it doesn't need your servers. The usual route is a compromised third-party script or tag manager, so your logs show nothing wrong. Each variant leaves a signal. A script reading payment fields. A form that differs from the one your app rendered. A new outbound destination. A script nobody approved. Or an approved script whose code changed. Can a CSP stop it? Partly. It can block an unlisted origin and restrict where data is sent. It can't tell you that an allowed script is reading your card field. Once you find it, block it at the level that fits: one script by its URL, a host or domain, or everything a vendor serves. If the business needs that vendor, allow it but limit what it can do, like reading form fields. Script Monitoring watches every script on your checkout, in every session, and flags the ones that read forms or send data somewhere new. It's free for 1,000 page views a month, and Pro starts at $99 a month. Start for free at scriptmonitoring.com.

Video page with transcriptWatch on YouTube

See every script on your own checkout.

Install the tag, mark your payment pages, and watch the inventory fill in. Free forever on 1,000 page views a month, no credit card.

Free forever plan. No credit card.