Remote code execution (RCE) — class
TL;DR: End state of many chains: command injection, deserialisation, SSTI, file upload, dependency RCE. Track as a bug class to reason about impact.
What it is
Rather than a single technique, RCE is a terminal — the point where attacker bytes become executed instructions on the target host. It is reached from many starting primitives. Treating RCE as a class helps in triage (what does the bug actually grant?), in scoping (which other primitives could lead here?), and in defence (what controls survive once RCE is reached?).
Preconditions / where it applies
- A primitive that controls bytes interpreted by an executor: shell, language eval, deserialiser, template engine, native loader, query engine
- A way to deliver the primitive (HTTP, queue message, file upload, scheduled job, supply chain)
- An executor with reachable side effects (network, filesystem, secrets, cluster API)
Technique — common paths to RCE
- Direct command injection — user input concatenated into
system()/exec(). Inject; id, backticks,$(…), newline. See command-injection. - Deserialisation — language-native object stream lets attacker pick gadget chains: Java
ObjectInputStream+ ysoserial, .NETBinaryFormatter, PHPunserialize, Pythonpickle.loads, Ruby Marshal. See deserialisation. - Server-side template injection —
{{7*7}}returns 49 → Jinja/Twig/Velocity engine eval →{{ self.__class__.__mro__[1].__subclasses__() }}to RCE. See ssti. - File upload to executable path — upload
.php/.jsp/.aspx/.phtmlto a directory the web server interprets; or upload.htaccessto redefine handlers. See file-upload. - SQL → RCE —
xp_cmdshell(MSSQL),COPY ... PROGRAM(Postgres),INTO OUTFILE+ PHP webshell (MySQL), UDF loading. See sql-injection. - SSRF → metadata → cloud RCE — IMDS credentials → assume role → cluster API → workload exec. See ssrf-to-cloud.
- XXE → file read → key reuse → RCE — read
id_rsa, reuse against SSH. See xxe. - Prototype pollution → gadget — pollute
Object.prototype.shellthen a downstream library usesopts.shellinchild_process.spawn. See prototype-pollution. - Dependency / supply chain — vulnerable lib (Log4j JNDI, Spring4Shell, ImageMagick coder), typosquat, malicious post-install.
- Native loader — DLL/SO sideload via a writable plugin dir; admin panel that allows arbitrary plugin install.
- Eval-based features — admin-only “scripting” endpoints exposed to lower roles via auth bug.
Detection and defence
- Defence-in-depth: even granted code exec, limit blast radius — seccomp/AppArmor, read-only FS, non-root, egress allowlist, dropped capabilities, no creds on disk.
- Patch the obvious chains (Log4j, ImageMagick, struts, spring, jackson, fastjson) within hours of advisories.
- EDR signals: child processes from web/app workers, outbound to unusual destinations, suid/setuid spawn, in-memory loader artifacts.
- Honeytokens in
/etc/passwd, AWS creds, JNDI strings to trip attackers exploring after RCE. - Treat any RCE as a full-host compromise; rotate every secret reachable from the workload.
- Related: command-injection, deserialisation, ssti, file-upload, sql-injection, ssrf-to-cloud, xxe, prototype-pollution.
References
- OWASP Top 10 — A03 Injection — class umbrella
- HackTricks — methodology — chain patterns
- PayloadsAllTheThings — payload corpus across every primitive