One of our three Next.js frontends was using almost four CPU cores to serve a marketplace that, at the time, had a handful of test orders. The work it was really doing was mining cryptocurrency for someone else, and it had been at it, on and off, for about five weeks.
Short answer: our Next.js frontends ran a version vulnerable to React2Shell (CVE-2025-55182), a public remote-code-execution flaw in React Server Components. Attackers used one crafted HTTP request to run a miner and a reverse shell inside the containers. Rebuilding did not help because the hole was in our code's dependencies. Upgrading Next.js and React, then rotating secrets, did.
This is the postmortem for MONTRA, the B2B elevator spare-parts marketplace we build and run. We are publishing it because the mistakes are common, the fix is cheap, and most teams running Next.js should check the same things this week.
The business problem: frameworks have security holes, and someone has to be watching
Every business that runs a website or app built on a popular framework inherits that framework's security advisories. React and Next.js are maintained by serious teams who disclosed this one responsibly and shipped fixes the same day. That does not protect you. It only gives you a patch. Somebody on your side still has to notice the advisory, upgrade, rebuild, and deploy.
The patch for React2Shell was published on December 3, 2025. Our frontends were still running the vulnerable versions in June 2026. Nothing broke, nothing looked wrong in the browser, and the app kept serving pages. That is the uncomfortable part of this class of problem: a compromised server can look perfectly healthy to a customer.
What five unnoticed weeks cost us:
- Compute. A miner uses all the CPU it can get. One container alone was at roughly 400% CPU, about four cores, on a server that also runs the database and the API. On a cloud bill that is real money. On a shared VPS it is slower pages for real users.
- Risk. The attacker also had an interactive shell on the internal Docker network, which can reach the database and the API. The malware included a credential harvester that looked for cloud keys, SSH keys and database connection strings. Even when nothing is stolen, you have to assume it might have been and rotate everything.
- Time. Two wrong theories cost us weeks before we found the real cause.
We were lucky in one respect: MONTRA was pre-launch, and the database held essentially test data. A live store with thousands of customers would have faced a far more expensive conversation.
Who is responsible? The options for a business owner
If an outside team builds and hosts your product, the contract decides who watches for advisories. Most contracts say nothing, which means nobody does. These are the realistic arrangements:
| Arrangement | Who patches | Works when | Risk |
|---|---|---|---|
| Build-only contract, you host | You | You have someone technical in-house | Advisories go unread after handover |
| Build plus a maintenance retainer | Vendor, within an agreed window | The window is written down (for example, critical fixes within 72 hours) | Retainers that only cover "bug fixes" may exclude dependency upgrades |
| Managed hosting platform | Shared: platform can block some attacks, you still upgrade | You deploy to a platform with framework-aware protection | Platform rules are a mitigation, not a fix |
| Nobody named | Nobody | Never | This is the default, and it is how incidents like ours happen |
Questions worth asking any vendor, including us:
- Who receives security advisories for the frameworks in my product, and how fast do you act on a critical one?
- Is a dependency upgrade covered by maintenance, or billed as new work?
- What monitoring would tell us a server is doing something it shouldn't, such as sustained high CPU?
- If we are compromised, who rotates the secrets, and do you have a written list of them?
How we found it in MONTRA (and why our first theories were wrong)
MONTRA runs as Docker containers behind nginx: a NestJS API, a MySQL database, and three Next.js App Router frontends (the customer storefront, the trader portal and the admin panel). Each frontend runs as a non-root user inside its container.
The Montra storefront home page, the public-facing Next.js app
The timeline, reconstructed from our incident notes and commits:
Dec 3, 2025 React and Next.js publish fixes for CVE-2025-55182 / CVE-2025-66478
Dec 5, 2025 CISA adds CVE-2025-55182 to its Known Exploited Vulnerabilities list
... our frontends stay pinned to next 16.0.3 / react 19.2.0
Jun 10, 2026 signs of compromise on the trader portal; we blame its public port
and bind every app port to 127.0.0.1 (only nginx stays public)
Jun 15 earliest malware artifact we later found
Jul 8 clean redeploy of the storefront container
days later storefront infected again
Jul 20 root cause found; next 16.0.10 + react 19.2.1 in all three apps;
database passwords and token-signing secret rotated
Wrong theory one: the open port. In June the trader portal's container port was published directly to the internet, bypassing nginx. Docker's port publishing skips the host firewall, so a firewall rule would not have covered it. Closing it was the right thing to do. But it was not the way in. The vulnerability is reachable through any normal HTTP request that nginx happily forwards.
Wrong theory two: containers infecting each other. When infection showed up in more than one frontend, we assumed the attacker was moving sideways from one container to the next. So we cleaned and rebuilt. On July 8 we redeployed the storefront from a clean image. Within days it was infected again.
That reinfection is what finally pointed at the real cause. A fresh image built from our own code getting compromised again means the vulnerability lives in the code, not in leftovers. Rebuilding containers alone was never going to fix it.
The evidence that settled it:
| Observation | What it points to |
|---|---|
| All three Next.js frontends compromised | All three use App Router and React Server Components |
| NestJS API on the same Docker network clean | No React Server Components there |
| MySQL, nginx and the certificate container clean | Not React |
| Clean storefront reinfected days after redeploy | The entry point was still open over HTTP |
| All malware ran as the frontend's non-root user, no host persistence | Code executed inside the Next.js server process |
If the attacker had been moving between containers, the API would have been the obvious next target. It was untouched. The pattern followed the framework, not the network.
Under the hood: what React2Shell does
React Server Components use a protocol called Flight to send data between browser and server, including the arguments to Server Functions. In the affected versions, the server deserialized that payload unsafely. A single crafted request to a Server Function endpoint, with no login, could run code on the server. React rated it CVSS 10.0, the maximum.
Per the official advisories:
- React:
react-server-dom-webpack,-parceland-turbopack19.0.0, 19.1.0, 19.1.1 and 19.2.0 are affected; 19.0.1, 19.1.2 and 19.2.1 fix it. - Next.js (tracked as CVE-2025-66478): App Router apps on 15.x, 16.x and 14.3 canaries are affected. First fixed releases include 15.5.7 and 16.0.7. Pages Router apps and the Edge Runtime are not affected.
- Follow-ups: a week later, researchers found denial-of-service and source-code-exposure bugs in the same area. For the 16.0 line, the release that fixes everything is 16.0.10, which is why we went there instead of 16.0.7.
React's own guidance adds a detail many teams miss: an app can be exposed even if it never defines a Server Function, as long as it supports Server Components.
What the attacker left behind
Our incident notes describe a fairly standard mass-exploitation kit. A loader script dropped files into the usual writable places (/tmp, /dev/shm, /var/tmp), started an XMRig miner, and opened a reverse shell back to a remote server. The processes renamed themselves with bracketed names that imitate kernel threads and log daemons, and blanked their command lines, so a quick ps looked ordinary. The loader also carried modules for harvesting credentials and probing for container escapes.
None of it reached the host. The containers had no Docker socket mounted, none were privileged, and the host showed no tampering and no unknown SSH logins.
The fix
The real fix was four lines per frontend:
- "next": "16.0.3",
- "react": "19.2.0",
- "react-dom": "19.2.0",
+ "next": "16.0.10",
+ "react": "19.2.1",
+ "react-dom": "19.2.1",
Note the exact pins. We had pinned next to 16.0.3 in November 2025, before the advisory. Exact pins plus a lockfile give you reproducible builds, which is good. They also mean a rebuild installs the same vulnerable version forever, and no step in our build checked dependencies against published advisories. Pinning is only safe when something else tells you when to move the pin.
Around the upgrade we also killed the malware, recreated all frontends from clean images, blocked the attacker's servers outbound, rotated the database passwords and the token-signing secret, and set SSH to key-only. One SSH detail is worth sharing: the cloud image shipped a config drop-in that enabled password login, and since sshd uses the first value it reads, our hardening file had to sort before it:
# /etc/ssh/sshd_config.d/00-hardening.conf (must sort before 50-cloud-init.conf)
PasswordAuthentication no
Limiting the next one
Patching closes this hole. The September audit that followed made the next one smaller. Each Next.js container now has a CPU cap, a memory cap, a process limit, no Linux capabilities and no privilege escalation, and the database sits on an internal network the frontends cannot reach:
frontend-client:
mem_limit: 640m
cpus: ${FRONTEND_CPUS:-1.0}
pids_limit: 512
security_opt:
- no-new-privileges:true
cap_drop:
- ALL
ports:
- "127.0.0.1:3001:3000" # only nginx is public
networks:
- elevator-network # database lives on a separate internal network
A CPU cap does not stop an attacker. It does stop a miner from starving the database, and it turns "the server feels slow" into a clear signal: a container pinned at exactly its limit.
We also added a reinfection check that runs every 15 minutes and a daily, self-verifying database backup.
What we learned
- Reinfection after a clean rebuild means the door is still open. Stop cleaning and look for the entry point.
- Sweep every container, not only the loud ones. Our first cleanup pass missed the trader portal, the one using the most CPU.
- Follow the pattern of what is clean. The untouched API ruled out lateral movement faster than anything else.
- A commit that has never been deployed is untested. A large remediation commit we shipped the same day took production down on first deploy because of two configuration regressions. We fixed it within hours, but security work deserves the same staging run as features.
The Montra trader portal, the frontend where CPU usage was highest
Checklist: run this on your Next.js app this week
- Check your versions. Run
npm ls next react react-domin every app. On 15.x or 16.x, move to the latest patch release in your line. At the time of writing (November 2026), the floor is the set listed in the Next.js December 11, 2025 advisory (16.0.10 for 16.0.x, 15.5.9 for 15.5.x), and later advisories have raised it again, so check the current Next.js security page. - Check every deployed app, not just the main one. Admin panels, staging and forgotten landing pages run the same framework.
- Add an advisory check to your pipeline.
npm audit, Dependabot or a similar tool, with a named person who reads the output. - Publish only the reverse proxy. Bind app ports to
127.0.0.1. Docker bypasses host firewalls like UFW. - Run Node as non-root, drop all capabilities, and set
no-new-privileges. It kept our host clean. - Cap CPU and memory per container, and alert on sustained high CPU. It is the loudest symptom of a miner.
- Keep secrets out of the frontend's environment. Ours held only public API URLs, which kept the exposure small.
- After a patch, rotate secrets. Next.js recommends this for any app that was online and unpatched in early December 2025.
- Write down who patches. One line in the maintenance agreement with a response time.
Frequently asked questions
Is my Next.js site affected by React2Shell?
It is affected if it uses the App Router with React Server Components and runs an unpatched 15.x or 16.x release, or a 14.3 canary. Pages Router apps and the Edge Runtime are not affected. Check with npm ls next and compare against the Next.js advisories.
Does rebuilding or redeploying the server remove the infection?
It removes the current malware but not the vulnerability. If the same vulnerable version is deployed again, the server can be reinfected within days, which is exactly what happened to us. Upgrade first, then rebuild.
How do I know if a cryptominer is running on my server?
The most common sign is sustained high CPU with no matching traffic. Look also for unfamiliar processes, especially ones with bracketed names or empty command lines inside app containers, and for new files in /tmp or /dev/shm.
Should I rotate secrets if I found no evidence of theft?
Yes. If an attacker could run code on a server, assume they read whatever that server could read, including environment variables and anything reachable on its network. Rotation is cheap compared with finding out later.
Who is responsible for security patches, me or my software vendor?
Whoever the contract names. If it names nobody, in practice nobody is. Agree in writing who monitors advisories, how fast critical fixes ship, and whether dependency upgrades are part of maintenance.
Next step
If you run a Next.js or React product and are not sure which versions are deployed, start with the first checklist item today. It takes minutes. If you want a second pair of eyes on your stack or a maintenance arrangement with a written patch window, tell us about your setup. For more on how we build MONTRA, read how we handle money correctly with idempotency and ledgers, and if you are choosing how to contract a team, see fixed price vs time and materials.