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.
In this guide
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 itHide the instructions
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
Part 1. Execution-boundary review worksheet51 lines
Part 2. Harmless-marker lab: does the boundary hold?185 lines
Part 3. Patch-effectiveness check200 lines
Whole template449 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.
PART 1. EXECUTION-BOUNDARY REVIEW WORKSHEET
Fill in one block for each place your application runs code. Answer from the running system where you can (the process list, the container, pod or function configuration, the cloud role), not from a design document, and note where each answer came from.
Places to cover:
1. Web server process: whatever answers HTTP requests
2. Background jobs and queue workers
3. Build and deploy pipeline: the runner that installs dependencies and builds
4. Serverless functions
5. Admin tools and scheduled tasks: scripts, consoles, cron jobs, anything staff use to run code or change settings
Place: ____________________ Owner: ____________________ Date checked: __________
A. What it runs as
Operating system user and UID: __________ Root or administrator? yes / no
Container image sets a non-root USER? yes / no / not a container
Can it gain privileges (setuid binaries, sudo, allowPrivilegeEscalation, no-new-privileges)? __________
Linux capabilities added beyond the default set, and any dropped: __________
Evidence (the command, console screen or file the answer came from): __________
B. What it can read and write
Folders it can write to: __________
Root or application file system read-only? yes / no
Can it write to any folder the server serves or executes files from? yes / no
Can it change its own application code? yes / no
Evidence: __________
C. Secrets in its environment
Every variable or mounted file holding a key, token, password or connection string:
__________
For each one: what it can reach, and whether this place needs it at all: __________
Cloud role or service account attached, and what it may do: __________
Database account it connects as, and whether that account can change the schema or read every table: __________
Child processes it starts, and whether they receive the full environment: __________
D. Network destinations
Outbound destinations it needs (host and port): __________
Is outbound traffic limited to that list? yes / no / unknown
Can it reach internal services, admin interfaces or a cloud metadata address? __________
Evidence: __________
E. Patch rollout and confirmation
How a dependency or runtime upgrade reaches this place: __________
How the running version is read after a deploy (command, endpoint or log line): __________
Is the process, container or function replaced on every deploy? yes / no
Last advisory checked, the fixed version it names, and the version read from the running build: __________
Who is told when a remote code execution advisory affects this place: __________
F. If code ran here today
What could it read? What could it change? Where could it send data? Which credentials would need rotating?
__________
Reading the worksheet: every "unknown", every root user, every secret a place does not need and every unrestricted outbound rule is a change to schedule. Start with the places that receive input from the internet, and repeat the review after a hosting change or any remote code execution advisory that touches your stack.
PART 2. HARMLESS-MARKER LAB: DOES THE BOUNDARY HOLD?
What it needs: Node.js and nothing else. No packages to install. The permission model it relies on is documented as stable from Node.js 22.13.0 and 23.5.0. The output below was recorded on Node.js v26.0.0 on macOS.
What the probe tries from inside a process: write a marker file in the folder it is allowed to write (the control), write a marker file in a folder outside that, check whether an environment variable it should not hold is visible (without printing its value), and start a child process that prints the Node.js version. It makes no network connection and writes only files named rce-lab-marker.txt.
Steps: create an empty folder, save the two files below into it, then run: node run-lab.mjs
In each output below, the last line is the command's exit code as the shell reported it.
--- probe.mjs ---
// probe.mjs: usage: node probe.mjs ALLOWED_FOLDER OUTSIDE_FOLDER VARIABLE_NAME
// Tries four harmless actions and prints which ones the process was allowed.
// It writes one small marker file per folder, never prints the variable's
// value, and makes no network connection. For learning, on a machine you own.
import { writeFileSync } from 'node:fs'
import { spawnSync } from 'node:child_process'
import { join } from 'node:path'
const allowedFolder = process.argv[2]
const outsideFolder = process.argv[3]
const variableName = process.argv[4] || 'LAB_CANARY_SECRET'
function describeError(error) {
return error.code || error.message
}
function tryWriteMarker(folder) {
try {
writeFileSync(join(folder, 'rce-lab-marker.txt'), 'harmless lab marker')
return 'ALLOWED'
} catch (error) {
return 'BLOCKED (' + describeError(error) + ')'
}
}
function checkVariable(name) {
return process.env[name] === undefined ? 'ABSENT' : 'VISIBLE'
}
function tryChildProcess() {
try {
const result = spawnSync(process.execPath, ['--version'])
if (result.error) return 'BLOCKED (' + describeError(result.error) + ')'
return 'ALLOWED'
} catch (error) {
return 'BLOCKED (' + describeError(error) + ')'
}
}
const results = {
writeAllowedFolder: tryWriteMarker(allowedFolder),
writeOutsideFolder: tryWriteMarker(outsideFolder),
readVariable: checkVariable(variableName),
startChildProcess: tryChildProcess(),
}
console.log(JSON.stringify(results))
--- run-lab.mjs ---
// run-lab.mjs: usage: node run-lab.mjs
// Runs probe.mjs three times and checks each result against what the
// boundary should allow. Exits 1 if any run differs. For learning.
import { mkdirSync, rmSync } from 'node:fs'
import { spawnSync } from 'node:child_process'
import { dirname, join } from 'node:path'
import { fileURLToPath } from 'node:url'
const labFolder = dirname(fileURLToPath(import.meta.url))
const probePath = join(labFolder, 'probe.mjs')
const allowedFolder = join(labFolder, 'allowed')
const outsideFolder = join(labFolder, 'outside')
const canary = { LAB_CANARY_SECRET: 'not-a-real-secret' }
const permissionFlags = [
'--permission',
'--allow-fs-read=' + labFolder,
'--allow-fs-write=' + allowedFolder,
]
const runs = [
{
name: 'Run A: no restrictions, full environment',
flags: [],
environment: Object.assign({}, process.env, canary),
expected: { writeAllowedFolder: 'ALLOWED', writeOutsideFolder: 'ALLOWED', readVariable: 'VISIBLE', startChildProcess: 'ALLOWED' },
},
{
name: 'Run B: permission flags, full environment',
flags: permissionFlags,
environment: Object.assign({}, process.env, canary),
expected: { writeAllowedFolder: 'ALLOWED', writeOutsideFolder: 'BLOCKED', readVariable: 'VISIBLE', startChildProcess: 'BLOCKED' },
},
{
name: 'Run C: permission flags, empty environment',
flags: permissionFlags,
environment: {},
expected: { writeAllowedFolder: 'ALLOWED', writeOutsideFolder: 'BLOCKED', readVariable: 'ABSENT', startChildProcess: 'BLOCKED' },
},
]
function prepareFolders() {
for (const folder of [allowedFolder, outsideFolder]) {
mkdirSync(folder, { recursive: true })
rmSync(join(folder, 'rce-lab-marker.txt'), { force: true })
}
}
function runProbe(run) {
const args = run.flags.concat([probePath, allowedFolder, outsideFolder])
const child = spawnSync(process.execPath, args, { env: run.environment, encoding: 'utf8' })
if (child.status !== 0) throw new Error('probe failed: ' + child.stderr)
return JSON.parse(child.stdout)
}
function listMismatches(results, expected) {
const mismatches = []
for (const check of Object.keys(expected)) {
if (!results[check].startsWith(expected[check])) mismatches.push(check)
}
return mismatches
}
function printRun(run, results, mismatches) {
console.log(run.name)
for (const check of Object.keys(results)) {
console.log(' ' + check.padEnd(20) + results[check])
}
const verdict = mismatches.length === 0 ? 'PASS' : 'FAIL: ' + mismatches.join(', ')
console.log(' ' + 'matches expected'.padEnd(20) + verdict)
console.log('')
}
let failedRuns = 0
for (const run of runs) {
prepareFolders()
const results = runProbe(run)
const mismatches = listMismatches(results, run.expected)
printRun(run, results, mismatches)
if (mismatches.length > 0) failedRuns += 1
}
process.exitCode = failedRuns === 0 ? 0 : 1
--- Output of node run-lab.mjs ---
Run A: no restrictions, full environment
writeAllowedFolder ALLOWED
writeOutsideFolder ALLOWED
readVariable VISIBLE
startChildProcess ALLOWED
matches expected PASS
Run B: permission flags, full environment
writeAllowedFolder ALLOWED
writeOutsideFolder BLOCKED (ERR_ACCESS_DENIED)
readVariable VISIBLE
startChildProcess BLOCKED (ERR_ACCESS_DENIED)
matches expected PASS
Run C: permission flags, empty environment
writeAllowedFolder ALLOWED
writeOutsideFolder BLOCKED (ERR_ACCESS_DENIED)
readVariable ABSENT
startChildProcess BLOCKED (ERR_ACCESS_DENIED)
matches expected PASS
exit code: 0
How to read it:
Run A is the baseline. Every action succeeds, which shows the probe works.
Run B adds --permission with writes limited to the allowed folder. The outside write and the child process are refused with ERR_ACCESS_DENIED, and the dummy variable is still visible.
Run C keeps the flags and starts the probe with an empty environment. Now the variable is absent.
The exit code is 1 when any result differs from what that run expects, so the script can run in CI.
Break it on purpose: add '--allow-child-process' to the permissionFlags list and run it again. On the same machine and Node.js version, Runs B and C reported:
Run B: permission flags, full environment
writeAllowedFolder ALLOWED
writeOutsideFolder BLOCKED (ERR_ACCESS_DENIED)
readVariable VISIBLE
startChildProcess ALLOWED
matches expected FAIL: startChildProcess
Run C: permission flags, empty environment
writeAllowedFolder ALLOWED
writeOutsideFolder BLOCKED (ERR_ACCESS_DENIED)
readVariable ABSENT
startChildProcess ALLOWED
matches expected FAIL: startChildProcess
and the exit code was 1.
Point it at a real boundary: run probe.mjs in a container started from the image you deploy, with the same user, volumes and settings as production, passing a folder it is meant to write to, a folder it is not (such as the application folder), and the name of a secret it should not hold:
node probe.mjs WRITABLE_FOLDER APPLICATION_FOLDER SECRET_NAME
Record the result in Part 1, then delete the rce-lab-marker.txt files it wrote. The Node.js documentation calls the permission model a seat belt for trusted code that does not protect against malicious code, so treat Runs B and C as a lesson in method, and the container, user and network settings as the boundary to check.
PART 3. PATCH-EFFECTIVENESS CHECK
The pattern: read the version installed in the build you deployed, every copy of it, and compare each copy with the fixed version the advisory names for that release line. A range in package.json says what may be installed; the build says what is. The check fails closed: a release line with no listed fix, or a version it cannot read as a plain release number, does not pass.
The advisory file holds the fixed versions both GitHub advisory pages for CVE-2025-55182 (GHSA-fv66-9v8q-g76r) listed when checked on 14 November 2026. Replace it with the advisory you are checking. make-demo-build.mjs writes a stand-in build: two package.json files holding a name and a version, and no package code.
--- version-check.mjs ---
// version-check.mjs: finds every installed copy of a package in a deployed
// build and compares each with the fixed version an advisory names for its
// release line. An illustration for learning.
import { existsSync, readdirSync, readFileSync } from 'node:fs'
import { join } from 'node:path'
function isDigits(part) {
return /^[0-9]+$/.test(part)
}
// Accepts plain release numbers such as 19.2.1. Anything else returns null.
export function parseVersion(text) {
const parts = String(text).split('.')
if (parts.length !== 3 || !parts.every(isDigits)) return null
return { major: Number(parts[0]), minor: Number(parts[1]), patch: Number(parts[2]) }
}
export function judgeVersion(installedText, fixedVersions) {
const installed = parseVersion(installedText)
if (!installed) return { status: 'UNKNOWN VERSION', detail: 'not a plain release number, read the advisory' }
const line = installed.major + '.' + installed.minor
const fixedText = fixedVersions[line]
if (!fixedText) return { status: 'NO FIX LISTED', detail: 'no fixed version for ' + line + ' in the advisory record' }
const fixed = parseVersion(fixedText)
if (installed.patch < fixed.patch) return { status: 'BELOW FIX', detail: 'fixed in ' + fixedText }
return { status: 'AT OR ABOVE FIX', detail: 'fixed in ' + fixedText }
}
function listPackageFolders(modulesFolder) {
const folders = []
for (const entry of readdirSync(modulesFolder, { withFileTypes: true })) {
if (!entry.isDirectory()) continue
const entryPath = join(modulesFolder, entry.name)
if (!entry.name.startsWith('@')) {
folders.push(entryPath)
continue
}
for (const scoped of readdirSync(entryPath, { withFileTypes: true })) {
if (scoped.isDirectory()) folders.push(join(entryPath, scoped.name))
}
}
return folders
}
function collectCopies(modulesFolder, packageName, copies) {
if (!existsSync(modulesFolder)) return
const manifestPath = join(modulesFolder, packageName, 'package.json')
if (existsSync(manifestPath)) {
const manifest = JSON.parse(readFileSync(manifestPath, 'utf8'))
copies.push({ manifestPath: manifestPath, version: manifest.version })
}
for (const packageFolder of listPackageFolders(modulesFolder)) {
collectCopies(join(packageFolder, 'node_modules'), packageName, copies)
}
}
export function findInstalledCopies(buildFolder, packageName) {
const copies = []
collectCopies(join(buildFolder, 'node_modules'), packageName, copies)
return copies
}
--- check-build.mjs ---
// check-build.mjs: usage: node check-build.mjs BUILD_FOLDER ADVISORY_FILE
// Exits 0 only when every installed copy is at or above its fix.
import { readFileSync } from 'node:fs'
import { relative } from 'node:path'
import { findInstalledCopies, judgeVersion } from './version-check.mjs'
const buildFolder = process.argv[2]
const advisory = JSON.parse(readFileSync(process.argv[3], 'utf8'))
const copies = findInstalledCopies(buildFolder, advisory.packageName)
console.log(advisory.advisoryId + ': ' + advisory.packageName)
if (copies.length === 0) {
console.log('No installed copy found. If a framework bundles its own copy, check the framework advisory.')
process.exitCode = 2
}
let failures = 0
for (const copy of copies) {
const verdict = judgeVersion(copy.version, advisory.fixedVersions)
console.log(' ' + relative(buildFolder, copy.manifestPath) + ' ' + copy.version + ' ' + verdict.status + ' (' + verdict.detail + ')')
if (verdict.status !== 'AT OR ABOVE FIX') failures += 1
}
if (copies.length > 0) {
console.log(failures === 0 ? 'RESULT: every copy is at or above its fix' : 'RESULT: copies not at or above their fix: ' + failures)
process.exitCode = failures === 0 ? 0 : 1
}
--- ghsa-fv66-9v8q-g76r.json ---
{
"advisoryId": "GHSA-fv66-9v8q-g76r (CVE-2025-55182)",
"packageName": "react-server-dom-webpack",
"fixedVersions": { "19.0": "19.0.1", "19.1": "19.1.2", "19.2": "19.2.1" }
}
--- make-demo-build.mjs ---
// make-demo-build.mjs: usage: node make-demo-build.mjs NESTED_VERSION
// Writes a stand-in build folder: two package.json files with a name and a
// version, and no package code. An illustration for learning.
import { mkdirSync, rmSync, writeFileSync } from 'node:fs'
import { join } from 'node:path'
const nestedVersion = process.argv[2]
const buildFolder = 'demo-build'
function writeManifest(folder, name, version) {
mkdirSync(folder, { recursive: true })
const manifest = JSON.stringify({ name: name, version: version }, null, 2)
writeFileSync(join(folder, 'package.json'), manifest)
}
rmSync(buildFolder, { recursive: true, force: true })
const modules = join(buildFolder, 'node_modules')
writeManifest(join(modules, 'react-server-dom-webpack'), 'react-server-dom-webpack', '19.2.1')
writeManifest(join(modules, 'example-framework'), 'example-framework', '1.0.0')
const nested = join(modules, 'example-framework', 'node_modules', 'react-server-dom-webpack')
writeManifest(nested, 'react-server-dom-webpack', nestedVersion)
console.log('demo-build written, nested copy at ' + nestedVersion)
--- version-check.test.mjs ---
// version-check.test.mjs: run with: node --test
import { test } from 'node:test'
import assert from 'node:assert/strict'
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs'
import { tmpdir } from 'node:os'
import { join } from 'node:path'
import { findInstalledCopies, judgeVersion } from './version-check.mjs'
const fixedVersions = { '19.0': '19.0.1', '19.1': '19.1.2', '19.2': '19.2.1' }
test('versions the advisory lists as affected are below the fix', () => {
for (const version of ['19.0.0', '19.1.0', '19.1.1', '19.2.0']) {
assert.equal(judgeVersion(version, fixedVersions).status, 'BELOW FIX')
}
})
test('the fixed versions pass', () => {
for (const version of ['19.0.1', '19.1.2', '19.2.1']) {
assert.equal(judgeVersion(version, fixedVersions).status, 'AT OR ABOVE FIX')
}
})
test('a release line the advisory record does not cover fails closed', () => {
assert.equal(judgeVersion('19.3.0', fixedVersions).status, 'NO FIX LISTED')
})
test('a prerelease or unusual version fails closed', () => {
for (const version of ['19.2.1-canary.1', '19.2', '19..1', 'latest']) {
assert.equal(judgeVersion(version, fixedVersions).status, 'UNKNOWN VERSION')
}
})
test('a nested copy below the fix is found beside a patched top-level copy', () => {
const buildFolder = mkdtempSync(join(tmpdir(), 'patch-check-'))
const topLevel = join(buildFolder, 'node_modules', 'react-server-dom-webpack')
const nested = join(buildFolder, 'node_modules', 'example-framework', 'node_modules', 'react-server-dom-webpack')
mkdirSync(topLevel, { recursive: true })
mkdirSync(nested, { recursive: true })
writeFileSync(join(topLevel, 'package.json'), JSON.stringify({ version: '19.2.1' }))
writeFileSync(join(nested, 'package.json'), JSON.stringify({ version: '19.1.1' }))
const versions = findInstalledCopies(buildFolder, 'react-server-dom-webpack').map((copy) => copy.version)
rmSync(buildFolder, { recursive: true, force: true })
assert.deepEqual(versions.sort(), ['19.1.1', '19.2.1'])
})
--- Output: a build with an older nested copy ---
node make-demo-build.mjs 19.1.1
node check-build.mjs demo-build ghsa-fv66-9v8q-g76r.json
demo-build written, nested copy at 19.1.1
GHSA-fv66-9v8q-g76r (CVE-2025-55182): react-server-dom-webpack
node_modules/react-server-dom-webpack/package.json 19.2.1 AT OR ABOVE FIX (fixed in 19.2.1)
node_modules/example-framework/node_modules/react-server-dom-webpack/package.json 19.1.1 BELOW FIX (fixed in 19.1.2)
RESULT: copies not at or above their fix: 1
exit code: 1
--- Output: after the nested copy is upgraded ---
node make-demo-build.mjs 19.1.2
node check-build.mjs demo-build ghsa-fv66-9v8q-g76r.json
demo-build written, nested copy at 19.1.2
GHSA-fv66-9v8q-g76r (CVE-2025-55182): react-server-dom-webpack
node_modules/react-server-dom-webpack/package.json 19.2.1 AT OR ABOVE FIX (fixed in 19.2.1)
node_modules/example-framework/node_modules/react-server-dom-webpack/package.json 19.1.2 AT OR ABOVE FIX (fixed in 19.1.2)
RESULT: every copy is at or above its fix
exit code: 0
--- Output of node --test ---
✔ versions the advisory lists as affected are below the fix (0.884ms)
✔ the fixed versions pass (0.136083ms)
✔ a release line the advisory record does not cover fails closed (0.072291ms)
✔ a prerelease or unusual version fails closed (0.066334ms)
✔ a nested copy below the fix is found beside a patched top-level copy (2.663625ms)
ℹ tests 5
ℹ suites 0
ℹ pass 5
ℹ fail 0
ℹ cancelled 0
ℹ skipped 0
ℹ todo 0
ℹ duration_ms 90.726667
exit code: 0
On your system: run check-build.mjs where the build runs, inside the container image or on the server, pointed at the folder the server was started from rather than a repository checkout. Then confirm the process answering requests started after that deploy. Keep version-check.test.mjs in CI so the check itself stays correct; the last test is the regression case, a patched top-level copy hiding an older copy inside another package.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.
This is the route this page owns, and the one behind the phrase unsafe code execution. CWE-95, which MITRE also calls eval injection, is input used in a dynamic evaluation call such as eval without its code syntax being neutralised.
In a JavaScript codebase, search for eval, new Function and any feature that turns text into code: formula fields, rule builders, "custom script" settings and plugin systems that load code a user supplied.
ASVS 5.0 requirement 1.3.2, at Level 1, asks that an application avoids eval() and other dynamic code execution features, and that where there is no alternative, any user input included is sanitised before it runs.
Node.js has a module that looks like an answer and is not one. The node:vm module compiles and runs code within V8 virtual machine contexts, and its documentation says that it is not a security mechanism and not to use it to run untrusted code.
The fix is structural. CWE-94's first mitigation is to refactor so the program does not generate code dynamically, and CWE-95's is, if possible, to refactor so it does not need eval() at all.
A formula field can be parsed by a small grammar your code owns, and a rule builder can map each choice to a function you wrote.
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.
MITRE adds a detail that matters during an incident: because the application executes the command, malicious activity may appear to come from the application or its owner. ASVS 5.0 requirement 1.2.5 asks that operating system calls use parameterised OS queries or contextual command line output encoding.
How commands get built from input, and how to build them safely, is the subject of the command injection guide.
Server-side template injection is CWE-1336: input reaches a template engine and is interpreted as template expressions or other code directives. MITRE lists it beneath CWE-94, and lists the execution of unauthorised code or commands among its consequences.
ASVS 5.0 requirement 1.3.7 asks that templates are not built from untrusted input, and that where there is no alternative, input included during template creation is sanitised or strictly validated. The server-side template injection guide goes further.
CWE-502 covers a product that deserialises untrusted data without making sure the result will be valid. MITRE says the consequences vary widely with the objects involved, and gives gadget chains used to generate a shell as one example. ASVS 5.0 notes that deserialisation has historically been the cause of various code injection vulnerabilities, and requirement 1.5.2 asks for safe input handling, such as an allowlist of object types, and that mechanisms explicitly defined as insecure are not used with untrusted input.
OWASP's A08:2025 includes an insecure deserialisation scenario that ends in remote code execution on an application server, and the React advisory for CVE-2025-55182 lists CWE-502 as its weakness. The insecure deserialisation guide covers the rest.
An upload feature becomes a route to code execution when the server later treats a stored file as code. CWE-434 describes the upload or transfer of dangerous file types that are automatically processed within the product's environment, and says arbitrary code execution is possible if an uploaded file is interpreted and executed as code by the recipient.
ASVS 5.0 requirement 5.3.1 asks that files uploaded or generated by untrusted input and stored in a public folder are not executed as server-side program code when requested directly over HTTP. The file upload security guide covers checking, storing and serving uploads.
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. CVE-2025-55182 is a recent example: an unauthenticated remote code execution flaw in React Server Components, fixed in versions 19.0.1, 19.1.2 and 19.2.1 of the affected React Server Components packages.
CISA's Known Exploited Vulnerabilities catalogue lists it with a date added of 5 December 2025, and CISA's alert says it was added based on evidence of active exploitation.
The fix is an upgrade, and an upgrade only counts once the running build carries it, which the patch section and the lab on this page deal with.
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.
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. Docker's build guidance says that if a service can run without privileges, use USER to change to a non-root user.
Docker starts containers with a restricted set of Linux capabilities by default, and its documentation recommends removing all capabilities except those a process explicitly needs, while warning that the default capabilities and mounts may provide incomplete isolation, alone or combined with kernel vulnerabilities.
User namespaces, which map the root user in a container to a non uid-0 user outside it, are available but not enabled by default.
Check whether the process can gain privileges as well as what it starts with. In Kubernetes, allowPrivilegeEscalation controls whether a process can gain more privileges than its parent, for example through a setuid binary, and it defaults to true when the container's securityContext does not set it. In Docker, --security-opt no-new-privileges prevents container processes from gaining additional privileges, so commands such as su and sudo no longer raise them.
Code that runs as your process can change whatever your process can write. Docker's --read-only flag mounts a container's root filesystem read-only and limits writes to the volumes you specify, and the Kubernetes readOnlyRootFilesystem setting mounts a container's root filesystem read-only.
The volumes you add are then the only writable places, so keep uploads in one of them, keep that volume out of any path the server executes from, and make sure the process cannot rewrite its own application code.
On a server without containers, file ownership can do a similar job: application files owned by one user, the process running as another.
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.
AWS Lambda puts credentials there too: it sets variables including AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_SESSION_TOKEN in a function's environment, holding the access keys obtained from its execution role, so that role's permissions are what code running in the function can use.
ASVS 5.0 asks that access to secret assets follows the principle of least privilege (13.3.2) and that backend components, including data layers, communicate using accounts with the least necessary privileges (13.2.2). For each secret, ask whether this place needs it at all, and for each account, whether it can do more than this place requires.
A web process that only reads and writes application tables does not need a database account that can change the schema.
Outbound access decides where data can be sent and what else the process can talk to. In Kubernetes, a pod is non-isolated for egress by default, so all outbound connections are allowed, and a NetworkPolicy has no effect unless the cluster's network plugin implements it. ASVS 5.0 requirement 13.2.4 asks for an allowlist of the external resources or systems the application may communicate with, which can be implemented at the application layer, the web server, the firewall or a combination.
Internal services and cloud metadata addresses belong on the worksheet too; the SSRF guide in this library covers metadata endpoints.
A function feels disposable, but the platform reuses it. Lambda's documentation says an execution environment is frozen after an invocation and can be reused for the next request, that the contents of /tmp remain while it is frozen, and that background processes a function started resume if the environment is reused.
It also says environments are terminated every few hours and should not be assumed to persist indefinitely. If code may have run in a function, the environments that served the vulnerable version and the execution role's keys both belong in the response.
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.