Injection & Code Execution
Injection & Code Execution vulnerabilities at a glance
Overview
Injection vulnerabilities occur when an application sends untrusted data to an interpreter (SQL database, system shell, template engine, etc.) without proper validation or escaping. The interpreter treats the malicious input as part of a command or query, allowing attackers to execute unintended operations.
These vulnerabilities are among the most dangerous because they often provide complete control over the affected system. SQL injection can dump entire databases, command injection can execute system commands, template injection can achieve remote code execution, and other injection variants can compromise application logic, authentication, and data integrity.
Where it occurs
Injection flaws commonly occur when building database queries by string concatenation, executing system commands with user-supplied input, evaluating templates with untrusted data, deserializing user-controlled data, dynamically evaluating code based on user input, and constructing XML, JSON, or other structured data without proper escaping. These issues arise when developers trust user input or fail to use safe APIs that properly separate data from code.
Impact
Injection vulnerabilities can lead to complete data breaches with theft of sensitive information, authentication bypass and unauthorized access, data manipulation or destruction, remote code execution on application servers, lateral movement to internal systems, denial of service through resource exhaustion, and compliance violations with severe penalties.
Prevention
Prevention varies by scenario, but generally use parameterized queries for database access, avoid string-built SQL, and replace shell commands with secure API calls.
Specific Vulnerabilities
Explore specific vulnerability types within this category:
Detect These Vulnerabilities in Your Code
Sourcery automatically identifies injection & code execution and related vulnerabilities in your codebase.
Scan Your Code for Free