CAPEC-242: Code Injection
An adversary exploits a weakness in input validation on the target to inject new code into that which is currently executing. This differs from code inclusion in that code inclusion involves the addition or replacement of a reference to a code file, which is subsequently loaded by the target and used as part of the code of some application.
Last updated
Overview
CAPEC-242 (Code Injection) is a meta-level attack pattern catalogued by MITRE in the Common Attack Pattern Enumeration and Classification (CAPEC). It describes a recurring method attackers use to exploit software weaknesses.
What the attacker needs
Prerequisites
- The target software does not validate user-controlled input such that the execution of a process may be altered by sending code in through legitimate data channels, using no other mechanism.
Consequences
What a successful CAPEC-242 attack can achieve.
Other
Affects: Confidentiality, Integrity, Availability
Code Injection attack patterns can result in a wide variety of consequences and negatively affect all three elements of the security triad.
How to mitigate it
Defenses that reduce the risk of CAPEC-242.
- Utilize strict type, character, and encoding enforcement
- Ensure all input content that is delivered to client is sanitized against an acceptable content specification.
- Perform input validation for all content.
- Enforce regular patching of software.
Terminology & mappings
Mapped taxonomies
- OWASP Attacks: Code Injection
Frequently asked questions
Common questions about CAPEC-242.
- What is CAPEC-242?
- An adversary exploits a weakness in input validation on the target to inject new code into that which is currently executing. This differs from code inclusion in that code inclusion involves the addition or replacement of a reference to a code file, which is subsequently loaded by the target and used as part of the code of some application.
- How do you prevent CAPEC-242?
- Utilize strict type, character, and encoding enforcement
- What weaknesses does CAPEC-242 target?
- CAPEC-242 exploits one CWE weakness: CWE-94 (Improper Control of Generation of Code ('Code Injection')).
- How severe is CAPEC-242?
- MITRE rates CAPEC-242 as High severity with high likelihood of attack.
Sources
References
Attack-pattern data is sourced from the MITRE CAPEC catalog (v3.9). Weakness associations link to the corresponding CWE entries on RadicalNotion.AI.
Defend against CAPEC-242
Track the CVEs and weaknesses this technique exploits, with AI-written analysis and remediation steps.