Skip to main content
Security guideReviewed

Remote code execution: the routes in, and the limits that decide the damage

Remote code execution means someone on the internet gets your server to run their code.

This guide explains what counts as RCE, the flaws that lead to it, and the part that decides the damage: what the process can reach once code runs. It comes with a review worksheet and a harmless-marker lab that needs only Node.js.

Execution-boundary worksheet and harmless-marker lab

An illustration for learning and for checking systems you own. Part 1 is a review form for each place your application runs code: what it runs as, what it can read and write, which secrets it holds, where it can connect and how a patch is confirmed.

How to use it

Part 2 is a Node.js lab whose probe writes a control marker and then tries three harmless actions from inside a restricted process: a marker file outside its allowed folder, a variable it should not hold and a child process. It reports which ones the boundary allowed. Part 3 checks every installed copy of a package in a deployed build against an advisory's fixed versions, with a regression test. The code and outputs were run as shown on Node.js v26.0.0 on macOS.

remote-code-execution.txt

Introduction1 lines

ILLUSTRATION FOR LEARNING. Use the worksheet on systems you run. Run the lab only on a machine you own, and point the patch check only at a build you are responsible for. Nothing here connects to a network, attacks a system or runs a destructive command.

What remote code execution is

Remote code execution (RCE) is an outcome, not one kind of bug.

A person who can reach your application over the network gets code of their choosing to run on your server. That code runs inside one of your processes, so it starts with whatever that process has: its operating system user, the files it can open, the secrets in its environment and the network destinations it can reach.

Two applications with the same flaw can face very different consequences for that reason, and much of this guide is about the difference.

MITRE's weakness catalogue describes the underlying mistake as CWE-94, Improper Control of Generation of Code, and gives code injection as its alternate term: a product builds all or part of a code segment from externally influenced input without neutralising the special elements that could change what that code does.

Its listed consequences explain the severity. Code injection can often result in the execution of arbitrary code, injected code can reach resources the attacker is directly prevented from accessing, and the actions it performs are often unlogged.

The word remote has a definition too. In CVSS v3.1, an Attack Vector of Network means the vulnerable component is bound to the network stack and the set of possible attackers extends up to and including the entire internet; the specification notes that such a vulnerability is often termed "remotely exploitable".

A Privileges Required value of None means the attacker is unauthorised before the attack. An advisory that describes an unauthenticated remote code execution vulnerability describes both at once: anyone who can send a request, with no account.

CVE-2025-55182 in React Server Components is one: both of its GitHub advisory pages describe it that way and give the vector CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:C/C:H/I:H/A:H, a score of 10.0. The Next.js guide in this library covers which applications it reached.

Server-side code execution is also different from what runs in a browser. Cross-site scripting runs an attacker's script in one visitor's browser, inside that visitor's session. Remote code execution runs on the server, with the access of the server process rather than of one visitor.

Six routes to an RCE vulnerability

Different flaws end in the same place.

OWASP's Top 10:2025 maps CWE-94 code injection, CWE-95 eval injection and CWE-78 OS command injection to A05 Injection, and CWE-502 deserialisation of untrusted data to A08 Software or Data Integrity Failures. Each route gets a short summary here and a pointer to the guide in this library that goes deeper. The rest of the page deals with what every route has in common.

Code built from input and evaluated

This is the route this page owns, and the one behind the phrase unsafe code execution. 1 min read

Operating system commands built from input

When an application runs another program, such as an image converter or a PDF tool, and builds the command from request data, CWE-78 applies: OS command injection, where special elements in the input change the intended command. 1 min read

Template engines that process input

Server-side template injection is CWE-1336: input reaches a template engine and is interpreted as template expressions or other code directives. 1 min read

Deserialising untrusted data

CWE-502 covers a product that deserialises untrusted data without making sure the result will be valid. 1 min read

Uploaded files that get executed

An upload feature becomes a route to code execution when the server later treats a stored file as code. 1 min read

Flaws in the framework or a dependency

Your own code can avoid every route above and the server can still run an attacker's code, because the flaw sits in a framework or library you installed. 1 min read

Remote code execution prevention: close the routes, then limit the reach

Prevention has two halves.

The first closes the routes: no code or template built from input, no deserialisation of untrusted data with unsafe mechanisms, uploads that are never executed, and dependencies kept at their fixed versions. The second decides what a missed route costs. A framework flaw can arrive in a version you installed for other reasons, so the second half needs as much attention as the first.

MITRE names the second half's failure CWE-250, Execution with Unnecessary Privileges: an operation performed at a privilege level higher than the minimum required, which creates new weaknesses or amplifies the consequences of other weaknesses. It says an attacker will be able to reach any resources the extra privileges allow.

Its first mitigation is to run code with the lowest privileges required and, where possible, in isolated accounts used for a single task, so that a successful attack does not immediately give the attacker the rest of the software or its environment. Its example: database applications rarely need to run as the database administrator, especially in day-to-day operations.

The CVSS v3.1 specification builds the same idea into its Environmental metrics. Its example is a vulnerable component whose default configuration may be to run a listening service with administrator privileges, where a compromise might grant an attacker High confidentiality, integrity and availability impacts; in an analyst's environment where the same service might be running with reduced privileges, the modified impacts might each be set to Low.

An advisory's base score assumes the reasonable worst case across deployed environments. What your process can reach decides how close you are to it.

ASVS 5.0 writes this into its architecture chapter. V15 describes a component with "dangerous functionality" as one that performs operations such as deserialisation of untrusted data, raw file or binary data parsing, dynamic code execution or direct memory manipulation. At Level 3 it asks that documentation highlights where that functionality is used (15.1.5), and that those parts get additional protections such as sandboxing, encapsulation, containerisation or network level isolation, to delay and deter attackers who compromise one part of an application from pivoting elsewhere (15.2.5).

Four questions that set the blast radius

Ask these of every place your application runs code, not only the web server.

Background jobs, the build pipeline, serverless functions and admin tools run code too, and OWASP's A08:2025 lists a CI/CD pipeline that pulls code or artefacts from untrusted places, or does not verify them before use, among its examples. The worksheet on this page turns the four questions into a form, adds a fifth on patching, and closes with what code running in each place could do today.

What does the process run as?

Find the operating system user the running process actually has, from the process list or the container's configuration, rather than from a design document. 1 min read

What can it read and write?

Code that runs as your process can change whatever your process can write. 1 min read

Which secrets are in its environment?

Any code running in a process can read that process's environment, as the lab on this page shows, and in Node.js the environment travels further by default: the env option for starting a child process defaults to process.env, so a child started without it receives every variable the parent had. 1 min read

What can it reach on the network?

Outbound access decides where data can be sent and what else the process can talk to. 1 min read

Serverless functions and the same four questions

A function feels disposable, but the platform reuses it. 1 min read

Where the Node.js permission model fits

Node.js has a built-in permission model, documented as stable from versions 22.13.0 and 23.5.0.

Starting a process with --permission restricts its access to the file system through the fs module, the network, child processes, worker threads, native addons, WASI, FFI and the runtime inspector, and an operation that has not been granted throws ERR_ACCESS_DENIED. Flags such as --allow-fs-write and --allow-child-process grant access back, and an audit mode, --permission-audit, reports what an application would need without blocking it.

Its documentation is just as clear about what it is not. It calls the model a "seat belt" that stops trusted code from unintentionally changing files or using resources it was not granted, says it does not protect against malicious code, and says malicious code can bypass it and execute arbitrary code without its restrictions.

It also lists gaps: symbolic links are followed outside granted paths, existing file descriptors bypass it, and process._debugProcess() is not gated, for which the documentation points to running processes under different operating system users or using OS-level isolation.

Code run through an RCE flaw is malicious by definition, so the permission model is not the boundary that contains it. It is still useful: it catches a dependency or feature reaching for files or processes it was never meant to touch, and it makes the lab on this page possible with nothing to install.

For one gap it lists, process._debugProcess(), the documentation itself points to operating system controls: separate OS users per process, or OS-level isolation outside Node.js.

Put the boundary against an attacker's code there, in the container settings, the credentials and the network rules, and run the lab's probe inside it too.

How to confirm a patch took effect

An advisory gives fixed versions.

A patch has taken effect only when every running copy of the affected code is at or above one of them, and only the running system can tell you that.

  • Take affected and fixed versions from the advisory's version fields rather than its description, and compare them with the vendor's own advisory page where the vendor publishes one.
  • Read the version from the deployed build, not from package.json. A version range says what may be installed; the files inside the image or folder the server runs from say what is.
  • Check for more than one installed copy. A nested copy at an older version passes unnoticed when only the top level is read, as the lab's stand-in build shows. A framework can also depend on its own copy: for CVE-2025-55182, the Next.js advisory gives its fixes as next releases, so check the framework's version as well as React's.
  • Confirm the process was replaced. An upgrade on disk does not reach a process that started before it, so compare each process's start time, or the image or function version it reports, with the deploy.
  • Cover every place the code runs: each web server instance, worker, function version and internet-facing staging copy.
  • Prioritise with exploitation evidence. CISA says organisations should use its Known Exploited Vulnerabilities catalogue as an input to their vulnerability management prioritisation framework.

What a patch does not tell you

A patch closes the route from the day it reaches the running build. It says nothing about whether the flaw was used before. For CVE-2025-55182, CISA updated its alert to advise checking internet-accessible React instances for signs of potential compromise after applying mitigations, and the Next.js advisory recommended rotating secrets for applications that were online and unpatched at a stated time.

Whether a system was compromised in the past is incident response work, so call an incident response specialist first.

RCE testing without running an exploit

Where a published flaw is known to run code on the server, the safe check is the version and configuration, not the exploit.

Sending a working exploit to a live server runs the attacker's code path there, with side effects that cannot be known in advance. Version, configuration and host evidence answer the question that matters, whether this build is affected, without that risk.

For your own code, testing a route means showing that input reaches an interpreter, using harmless markers whose only effect is visible in a response or a log, and never a command. The same rule shapes the lab on this page: it proves what a boundary allows with a marker file, a dummy variable and a child process that prints a version number.

In a Clever Ops web application and API penetration test, file uploads are in scope, and read-only code access can be added for a closer look at the riskiest areas. Where a known flaw runs code on the server, the version and configuration in the deployed build are confirmed instead, and no exploit payload is sent to your server.

A test can confirm what the build in scope exposes. It cannot rule out a past compromise, which we refer to an incident response specialist.

If a tender or contract requires a CREST-accredited provider, Clever Ops is not CREST accredited, so we refer that work to a provider that is. If Clever Ops built or hosts the application, the work is a security review rather than an independent test, and the report says who built it and who hosts it.

Running the lab and reading its results

The lab in Part 2 of the worksheet and lab on this page is an illustration for learning and for checking systems you own.

It needs Node.js and nothing else, makes no network connection, and writes only a small marker file named rce-lab-marker.txt in each folder it tests. The output shown was recorded on Node.js v26.0.0 on macOS.

Run A is the baseline: with no restrictions every action succeeds, which shows the probe works. Run B adds --permission with writes limited to the allowed folder. The write outside it and the child process are refused with ERR_ACCESS_DENIED, while the dummy variable stays visible, because environment variables are not among the things the documentation lists --permission as restricting.

Run C keeps the flags and starts the probe with an empty environment, and the variable is gone. Keeping a secret from a process means not passing it in.

run-lab.mjs exits with code 1 when any result differs from what its run expects, so it can sit in a CI pipeline as a regression check. To see a failure, add --allow-child-process to its flag list: on the same machine, Runs B and C then reported the child process as allowed and failed.

The probe also takes its folders and a variable name as arguments, so you can run it in a container started from the image you deploy, with production's user, volumes and settings, against the folders it really writes to and the name of a secret it should not hold. It reports only whether the variable is visible, never its value.

The patch check follows the pattern in the section above. It reads every installed copy of the package an advisory names from a build folder, compares each with the fixed version for its release line, and fails closed on a release line or version string it cannot judge.

Its tests run with Node's built-in test runner through node --test, and the regression test is the nested-copy case: a patched top-level copy must not hide an older copy inside another package.

Frequently asked questions

It is a flaw that lets someone who can reach your application over the network run code of their choosing on your server. The causes differ: code or templates built from input, unsafe deserialisation, uploaded files executed as code, or a flaw in a framework. The result is the same: the attacker's code runs with everything your process has. That is why the fix has two parts: close the route, and limit what the process can reach.

No. Command injection, CWE-78, is one route to it: input that changes an operating system command the application runs. Remote code execution is the wider outcome, which can also come from evaluated code, template engines, deserialisation, uploads or a framework flaw. Fixing command injection closes that route only, and the limits on the process still decide what any other route could do.

No. A container does not stop a flaw from being exploited; it limits what the code can do afterwards, and only as far as it is configured. Docker's documentation warns that the default capabilities and mounts may provide incomplete isolation, recommends a non-root user where a service can run without privileges, and recommends removing every capability a process does not explicitly need. Add a read-only root filesystem, no privilege escalation, only the secrets that container needs and limited outbound traffic.

No, and its documentation says so. It describes the model as a seat belt for trusted code, says it does not protect against malicious code, and says malicious code can bypass it. Use it to catch mistakes in code you trust, and rely on operating system users, container settings and network rules as the boundary around code you do not.

The base score assumes the reasonable worst case across deployed environments. The CVSS v3.1 specification says consumers should supplement it with Temporal and Environmental scores for their own use of the product, and in its own example the modified impacts might each be set to Low for a service running with reduced privileges. Patch either way, and sooner for a flaw on CISA's Known Exploited Vulnerabilities catalogue. The environmental view tells you how much a missed patch, or a compromise before the patch, could have cost.

No. A test covers the routes, roles and build in its scope during the window it ran, and checks that found nothing are recorded as negative results for what was tested rather than as proof. Where an advisory describes code execution, the test confirms the version and configuration instead of running an exploit, and it cannot tell you whether the flaw was used before you patched.

Scope the right test for your application

Tell us what you have built, who uses it and when it needs to launch. You will get a plain-English recommendation: a website audit, a web application test or a referral to a specialist.