Anatomy of a Magento Hack: CosmicSting → Card Skimmer → ClickFix
In June 2026 our team cleaned a compromised, end-of-life Magento 2.3 store. It wasn't a single backdoor — it was a full intrusion kit: a server-side card decryptor, a credential harvester, multiple webshells, an OS-level reverse shell persisted via cron, rogue admin accounts, and a public-facing ClickFix fake-CAPTCHA that served malware to the store's own visitors. The entry point was almost certainly CosmicSting (CVE-2024-34102), the same critical Magento bug mass-exploited across the world since 2024.
This is the full anatomy of that attack — who's at risk, what the malware can do, the exact patch that closes the door, and how to clean up without taking the store down. Names and indicators are anonymised; the techniques are exactly as found.
Not sure if you're exposed? Run a free MageArgus scan — it checks your version against CosmicSting's fixed patch levels and looks for web-reachable signs of compromise.
- CVE-2024-34102 — CVSS 9.8, unauthenticated — Adobe APSB24-40 / NVD
- Thousands of stores mass-compromised by CosmicSting — Sansec research, 2024
- Magento 2.3 reached end-of-life in 2022 — no security patches since
The attack chain, step by step
Modern Magento attacks are rarely "one and done." Here's how this one unfolded — a pattern you'll see again and again on unpatched stores:
1. Entry — CosmicSting (CVE-2024-34102)
An unauthenticated XML External Entity (XXE) flaw in the Commerce REST API let the attacker make the server read local files — most importantly app/etc/env.php and the store's encryption key.
2. Escalation — forged admin access
With the stolen encryption key, the attacker forged admin session tokens (and, chained with the glibc iconv bug CVE-2024-2961, can reach full remote code execution). They then created rogue admin users with throwaway email addresses.
3. Foothold — webshells & a DB client
They dropped multiple PHP webshells (including filename-evasion polyglots like x.php8, x.php. and fake images such as x.php_00.png under pub/media) and a full Adminer database client — a one-file backdoor into the entire database.
4. Monetisation — card decryptor + credential harvester
A "VENI VIDI VICI" panel combined a credit-card decryptor with a Stripe / AWS / SMTP credential harvester — designed to pull money and third-party keys straight out of the store.
5. Persistence — reverse shell + cron
An OS-level gsocket reverse shell, disguised as a kernel process ([kcached]) and relaunched hourly via cron using a base64-encoded ... | base64 -d | bash one-liner — so even file cleanup wouldn't lock them out.
6. Payload — ClickFix fake-CAPTCHA
The public payload was a cloaked ClickFix overlay: a fake "verify you are human" box that copied a PowerShell command to the visitor's clipboard and told them to press Win+R → paste → Enter — installing an info-stealer on the shopper's PC. It was cloaked to show only to real browsers, so it stayed invisible to most remote scanners.
Who is impacted
You should treat your store as at risk if any of these is true:
- You run Adobe Commerce / Magento Open Source below the CosmicSting fixed patch level for your branch (see the table below).
- You run an end-of-life branch (2.3.x or earlier) — these receive no security patches at all and are permanently exposed.
- You patched late — if your encryption key leaked before you patched, attackers can still forge admin access until you rotate it.
- You've never rotated the encryption key, admin passwords or API tokens since the store launched.
What this malware can do
| Component | What it does to you |
|---|---|
| CosmicSting XXE | Reads your secret encryption key and config files without logging in. |
| Card decryptor | Decrypts stored card data — direct cardholder-data theft (PCI breach). |
| Credential harvester | Steals Stripe, AWS, SMTP and gateway keys — money movement & lateral access. |
| Webshells / Adminer | Full remote control of files and database; persistence and re-infection. |
| Reverse shell (cron) | Always-on OS access that survives file deletion. |
| ClickFix overlay | Turns your storefront into a malware-delivery site — infects your own customers and destroys trust. |
| Rogue admins | Re-entry even after you change passwords, until the accounts are removed. |
Which patch fixes the entry point
CosmicSting (CVE-2024-34102) is fixed in these patch levels — anything below your branch's fixed level is vulnerable. Check with bin/magento --version:
| Your branch | Fixed in (apply this or newer) |
|---|---|
| 2.4.7 | 2.4.7-p1 |
| 2.4.6 | 2.4.6-p6 |
| 2.4.5 | 2.4.5-p8 |
| 2.4.4 | 2.4.4-p9 |
| 2.3.x and older (EOL) | No official patch — upgrade to a supported branch (see stop-gap below) |
Patch and rotate the key — patching alone is not enough if the key already leaked:
composer require magento/product-community-edition=2.4.7-p1 --no-update
composer update --with-dependencies
bin/magento setup:upgrade && bin/magento setup:di:compile
bin/magento encryption:key:change # rotate the (already-exposed) key
bin/magento cache:flush
Full walkthrough in our how to apply a Magento security patch guide and the CosmicSting deep-dive.
Can't upgrade today? A stop-gap for EOL stores
EOL branches (2.3 and older) get no patch, and big upgrades take time. As a temporary shield, you can neutralise the XXE at the PHP layer with an auto_prepend guard that disables external-entity loading and blocks XXE payloads to the API — no core files modified. The MageArgus module ships this as a one-command mitigation:
bin/magento mageargus:shield:cosmicsting install
bin/magento mageargus:shield:cosmicsting status
This is a stop-gap, not a cure: it stops future exploitation, but you must still rotate the already-stolen key and plan the upgrade off EOL Magento.
How to clean a store that's already hit
- Contain. Enable maintenance mode (or take checkout offline). Snapshot the server first for forensics.
- Remove web backdoors. Delete every PHP file under
pub/media/pub/static(none should execute there), alladminer.php/ DB clients, and any polyglots — match the whole filename, not just the extension (.php8,.php.,.php_00.png). - Kill persistence. Inspect
crontab -l,~/.bashrc,~/.profileand~/.configforbase64 -d | bash,gs-dbusor[kcached]; remove the line, kill the process, delete the dropped files. - Restore core files. Re-install Magento packages from clean releases so any injected core/vendor file is overwritten.
- Purge rogue admins & tokens. Delete unknown
admin_userrows and integration tokens, especially any created around the exposure window. - Clean the database. Search
cms_block,cms_pageandcore_config_data(header/footer/Misc HTML) for injected<script>,data:URIs,clipboardorpowershellstrings — that's where ClickFix and skimmers hide. - Rotate everything. Encryption key, all admin passwords, DB password, SSH credentials, and every gateway/SMTP/cloud key the harvester could have touched. Verify
~/.ssh/authorized_keysfor unknown keys. - Patch the entry vector and re-scan to confirm clean.
If you've found indicators, follow the full Magento hacked recovery plan.
Why a free remote scan can't promise "clean"
The most dangerous part of this case was the cloaking. The ClickFix payload only rendered for real browsers, so a quick "view source" or basic scanner saw nothing. On-disk webshells and database-level skimmers are invisible from outside entirely. A remote scan is great for catching version/CVE exposure and web-reachable indicators — but a definitive "clean" answer needs a file + database scan on the server. That's exactly the gap the MageArgus module fills.
Frequently asked questions
Which Magento versions are affected by CosmicSting (CVE-2024-34102)?
Any Adobe Commerce / Magento Open Source below the fixed patch levels 2.4.7-p1, 2.4.6-p6, 2.4.5-p8 or 2.4.4-p9 (APSB24-40). End-of-life branches like 2.3.x are permanently vulnerable because Adobe ships no patch for them.
If I patch CosmicSting, am I safe?
Patching stops future exploitation, but if your encryption key was already stolen the attacker can keep forging admin access. You must also rotate the key with bin/magento encryption:key:change and audit for rogue admins, tokens and planted files.
What is the ClickFix fake-CAPTCHA malware?
ClickFix is an injected overlay that copies a Windows PowerShell or mshta command to a visitor's clipboard and social-engineers them into running it (Win+R, paste, Enter), installing an info-stealer or RAT. It is often cloaked so it only shows to real browsers, making it invisible to many remote scanners.
Was credit card data stolen?
In this incident the attacker deployed a card decryptor and credential harvester, so any card data the store processed must be treated as compromised. Stores that offload payment to a hosted/iframe gateway (PayPal, Amazon Pay, hosted Stripe) and never store PANs are far less exposed — but the breach must still be reported to your PSP/acquirer.