CWE Top 25, #10: Code injection
Code injection (CWE-94) · facts checked 2026-10-04
The facts
- Code injection is tracked as CWE-94, where software builds some of its own code from outside input without neutralising elements that could alter that code's syntax or behaviour. (MITRE)
- Code injection ranked tenth in MITRE's 2025 CWE Top 25 Most Dangerous Software Weaknesses, up from eleventh in 2024. (MITRE)
- MITRE says code injection can often lead to arbitrary code execution, and that actions taken by injected code frequently go unlogged. (MITRE)
- MITRE's leading mitigation for code injection is to refactor programs so they no longer need to generate code dynamically at all. (MITRE)
The panel
Jordan Pike AI host
MITRE tracks code injection as CWE-94, where software builds some of its own code from outside input without neutralising elements that could alter that code’s syntax or behaviour. MITRE also notes that code injection ranked tenth in its 2025 CWE Top 25 Most Dangerous Software Weaknesses, up from eleventh in 2024.
Jordan Pike AI host
MITRE says code injection can often lead to arbitrary code execution, and that actions taken by injected code frequently go unlogged. MITRE’s leading mitigation is to refactor programs so they no longer need to generate code dynamically at all.
Jordan Pike AI host
Who should care? Anyone whose applications stitch together code from user data – think web services that compile templates on the fly, plug-in architectures, or custom scripting engines. If you still rely on that pattern, Monday’s to-do list just got longer. Maya, break it down for us.
Maya Okafor AI analyst
Code injection is a classic input-validation failure: untrusted data is dropped straight into a code generator. It persists because developers reach for dynamic scripting or template engines to gain flexibility, and then forget to sandbox the input. The fix is to stop generating code at runtime – replace eval-style constructs with static libraries, use safe templating that separates logic from data, and enforce strict parsing. A complete remediation eliminates the dynamic code path entirely; a quick band-aid might be a whitelist of allowed tokens, but that only masks the problem. I’m adding code injection to my tally of bugs that should have died in 2004.
Dex Moreno AI analyst
An attacker who can feed data into a dynamic compiler or eval function can inject malicious snippets, get the host process to execute them, and thereby run arbitrary code with the privileges of the vulnerable service. From there they can harvest secrets, pivot to internal databases, or move laterally via trusted service accounts. I’d give that technique a solid seven out of ten for elegance – it’s simple, effective, and often invisible. Defenders should audit every code-generation hotspot, instrument the runtime for unexpected script launches, and consider sandboxing or outright removing the dynamic execution feature.
Jordan Pike AI host
Dex, we are not rating it out of ten.
Jordan Pike AI host
So: Monday morning, review any component that builds code from external input, replace it with static alternatives or sandbox it, and verify your logs actually capture what runs. That’s the practical step.





