Card skimming
Magecart and card skimming
A skimmer is JavaScript on your checkout page that reads the card fields and sends a copy somewhere else. It needs no vulnerability in your payment processor and leaves the transaction working, so these run for weeks.
Nothing reaches your servers, so nothing upstream of the browser sees it. It is the attack client-side security exists for. When your policy names where the payment page may send data, the browser reports the exfiltration. When the policy already allows the destination, it reports nothing at all.
What the attack is
"Magecart" started as one group's name and now means the technique: get JavaScript onto a page that handles card data, read the fields as they are typed, and post them to a server you control. The code is small, often obfuscated, and often fires only on URLs containing checkout or payment, which keeps it off the pages a developer usually has open.
It arrives one of two ways. An attacker adds a new script to your page through a compromised vendor, a tag manager or an injection, or modifies a script already served from an origin you trust. The first violates a tight script-src. The second violates nothing.
Both end the same way. The stolen data has to leave over the network, to a host that is not yours, and a policy can name that step.
What the report looks like
A payment page whose connect-src names only the origins it talks to produces this the first time a skimmer tries to send anything:
{
"csp-report": {
"document-uri": "https://shop.example.com/checkout/payment",
"referrer": "https://shop.example.com/checkout/delivery",
"violated-directive": "connect-src",
"effective-directive": "connect-src",
"original-policy": "default-src 'self'; script-src 'self' https://js.stripe.com; connect-src 'self' https://api.stripe.com; report-uri https://k3x9mp2nq7ab.ingest.us.headerhawk.com/r",
"disposition": "report",
"blocked-uri": "https://cdn-payments.example.net/collect",
"status-code": 200,
"script-sample": ""
}
}How it appears in HeaderHawk
connect-src blocking cdn-payments.example.net
- document-uri is the page the request came from. A connect-src issue seen only on the payment step is a very different thing from one spread across the site, which is almost always a globally loaded SDK.
- blocked-uri is where the data was going. For a cross-origin connection browsers sometimes report only the origin, so the value may be shorter than the URL the code used. Grouping is by host either way.
- connect-src covers fetch, XMLHttpRequest, sendBeacon and WebSocket. A skimmer that exfiltrates by setting an image src reports under img-src instead, so a payment page wants both named.
- original-policy is stored with every report, so you can tell a new host from one you removed from the allowlist last Tuesday.
- disposition: report means the request went through. Report-only mode watches and blocks nothing.
Field by field: the connect-src reference.
What HeaderHawk does with it
Reports arrive grouped by problem: one row per directive and blocked host, with its report count, the number of pages it appeared on, and first- and last-seen times. For a skimmer, first seen is roughly when the code went live, the first thing an incident timeline needs and the hardest to reconstruct afterwards.
Open the issue for the reports behind it: the exact page, the source file and line the browser attributed the request to, the policy in force, and the browser and OS. The source file tells you which script made the call, and so what to remove.
Every host your pages tried to send data to is also listed in one place, on every plan. Each one a discovery run saw or your policy refused is there, with the date it was first seen, kept after its reports expire. On the Professional plan and above, a filter narrows the list to what your payment pages talk to.
The origins your pages load in a frame have a list of their own, on every plan. On a checkout that is usually where the card fields live. When your policy refuses a new one on a payment page, the alert says so first.
Alerts go by browser agreement. Violations gather in 15-minute windows. A window reported by two or more browser families, or carrying twenty or more reports from one, goes straight to Slack, email or a webhook, and an ongoing problem alerts once, then goes into the digest. A refused host your pages tried to send data to alerts as a new data destination of its own, so a rule can be about exactly that. Quieter windows go into a daily or weekly digest. Extension and bot traffic is marked as noise first and triggers nothing.
On the Team plan and above, the Scripts view lists the SHA-256 hashes of scripts browsers ran, the other half of the picture. It is a sample. On the Professional plan and above, a new or changed script on a page you mark as a payment page raises an alert once two networks have reported it or the page's daily scan fetches it, and each script there can be authorized or rejected with a written justification. The limits are below, and the PCI DSS 4.0 page maps them to requirements 6.4.3 and 11.6.1.
Where CSP alone is not enough
- A script allowlist does not catch a modified first-party file, and this is the most important limit on this page. The British Airways skimmer lived inside a file BA already served from its own origin, so script-src 'self' allowed it. Subresource Integrity and a build pipeline you trust address that. An allowlist does not.
- Report-only mode prevents nothing. It tells you what an enforcing policy would have refused. When there is a block, your own header does it. HeaderHawk is never in the request path and never sees your visitors' traffic.
- Alerts about new and changed scripts cover payment pages only, on the Professional plan and above, and wait for two networks or the page's daily scan. A new script, or an unpinned version of one you pinned, alerts once browsers on two different networks have reported it on a page you marked as a payment page, or once that page's daily scan fetches it. The scan reads the page's HTML and runs no JavaScript, so a skimmer another script injects at run time is seen only when browsers report it. Elsewhere, and on the Free and Team plans, new and changed scripts are collected for inspection and alert nobody.
- An exfiltration endpoint you already allow produces no report. A skimmer that posts to your own origin, or to an analytics host already on your connect-src, violates nothing. Tighten connect-src on the payment page itself to sharpen this signal.
- The script inventory is a sample, not a census. Hash reports come from Chrome and Edge only and cover only scripts the browser fetched, never cached or inline ones, and repeat sightings are sampled. A first sighting gets priority but no guarantee. Over quota or over the daily per-site ceiling, a new hash waits for its next sighting. The view starts on the Team plan.
- If your CSP stops being served, after a misconfigured cache rule or a rolled-back deploy, reports stop arriving and it looks like a quiet week. On the Professional plan and above, the daily scan of your payment page catches it and alerts. On the Free and Team plans, nothing here turns red.
- None of this is a PCI DSS control on its own, and nothing here makes anyone compliant.
Where to go next
- PCI DSS 4.0 maps all of this onto requirements 6.4.3 and 11.6.1, including which halves of them nothing here addresses.
- The
connect-srcreference explains what the directive covers and the navigations it never sees. - Third-party scripts is the other arrival route: a vendor's code changing without telling you.
- The British Airways write-up shows the report above against the real incident, and Magecart skimmers in CSP reports covers which of a skimmer's moves report and which never do.
Watch what your checkout talks to
Add a report-only connect-src to the payment
step and see every origin it reaches. Nothing breaks while you look.