Objective
Verify that untrusted input cannot alter the intended structure or meaning of commands, queries or instructions interpreted by application components.
Injection occurs when application-controlled data is incorporated into an interpreter or execution context in a way that allows the supplied data to influence the intended operation.
The vulnerability is not limited to SQL. Depending on the application architecture, injection can affect database queries, operating-system commands, directory services, template engines, expression languages, XML processors, interpreters and other execution contexts.
Allowlisting and input validation can reduce attack surface, but they should not be treated as the primary defense where a safer parameterized or structured API exists. The application should keep data separate from executable instructions.
Scope
Review all application-controlled input that reaches an interpreter or parser, including:
Prerequisites
| Authorization | Confirm authorization to test the target application and associated interfaces. |
|---|---|
| Application map | Identify relevant endpoints, forms, APIs, background jobs and administrative functions. |
| Test account | Use an appropriately authorized test account where authentication is required. |
| Technology information | Identify databases, frameworks, template engines, operating-system interfaces and other interpreters used by the application. |
| Test environment | Prefer a controlled non-production environment for active injection testing. |
Methodology
Injection testing should establish the complete path from an attacker-controlled input to the interpreter that consumes that input.
| Review stage | Primary question |
|---|---|
| Source | Where can an untrusted value originate? |
| Processing | Is the value transformed, decoded, concatenated or otherwise processed? |
| Sink | Does the value reach an interpreter, parser or execution API? |
| Separation | Does the implementation keep data separate from executable instructions? |
| Runtime behavior | Can controlled input alter the intended operation? |
Test procedure
Input and sink mapping
A professional assessment should maintain a traceable relationship between an input source and the interpreter that ultimately consumes it.
| Source | Potential sink |
|---|---|
search parameter
|
Database query |
filename parameter
|
Operating-system command or file-processing operation |
| User search/filter input | SQL, NoSQL or search-engine query |
| User-controlled template value | Server-side template engine |
| Directory search field | LDAP or directory query |
| XML input | XML parser or expression processor |
There is no single generic "sanitize the input" solution for injection. SQL parameterization, OS command APIs, LDAP escaping, template isolation and XML parser configuration address different execution contexts.
Injection classes
Untrusted input changes the structure or behavior of a relational database query.
Application input changes the structure or semantics of a NoSQL database operation.
Application-controlled input influences an operating-system command or shell execution context.
Untrusted values alter the structure or semantics of a directory-service query.
Attacker-controlled data is interpreted as template instructions rather than ordinary data.
User-controlled content reaches an expression language or interpreter that can evaluate unintended instructions.
Crafted input manipulates a parser or structured processing context in an unintended manner.
Any execution context where untrusted data can cross the boundary between data and instructions.
Controlled reproduction
Reproduction should demonstrate the security property being violated without causing unnecessary damage to the target system or its data.
Baseline request
GET /products?search=example HTTP/1.1
Host: application.example
Accept: application/json
Controlled test input
GET /products?search=[controlled-test-value]
HTTP/1.1
Observe:
- HTTP status
- Response structure
- Error behavior
- Result-set changes
- Timing differences
- Application logs, where authorized
WebOTG procedures should prioritize controlled, non-destructive verification. Do not delete data, alter production records, execute arbitrary commands, extract unrelated information or intentionally disrupt availability merely to demonstrate a finding.
Confirming the finding
A reliable injection finding normally requires more than seeing a database error. The tester should establish that the input changes interpreter behavior in a way that is attributable to the tested parameter.
Assessment
| Condition | Assessment consideration |
|---|---|
| Safe parameterization | User-controlled values remain data and cannot alter interpreter structure. |
| Unsafe concatenation | User input is directly combined with an executable query or command. |
| Incomplete validation | Validation can be bypassed or is not appropriate for the execution context. |
| Unsafe interpreter API | The application uses an execution API that unnecessarily interprets user-controlled content. |
| Confirmed manipulation | Controlled input demonstrably changes the intended interpreter behavior. |
A verbose database or interpreter error may indicate an injection risk, but it does not automatically prove that attacker-controlled input can alter execution. Reproducibility and causal evidence are required.
Failure criteria
A user-controlled search parameter is incorporated into a database query through unsafe string construction. Controlled test input produces a repeatable change in query behavior, demonstrating that the parameter can influence the structure of the database operation.
Remediation
The preferred remediation is to eliminate the interpreter boundary where possible or use an API that maintains strict separation between data and executable instructions.
General controls
- Use parameterized queries for relational database operations.
- Use safe, structured APIs for NoSQL databases.
- Avoid shell invocation when an equivalent direct API exists.
- If command execution is unavoidable, use a restricted argument interface and strict allowlisting appropriate to the application.
- Use context-specific encoding or escaping where required by the interpreter.
- Apply allowlist validation to values with a clearly defined business format.
- Avoid dynamically constructing executable template or expression content from untrusted input.
- Use safe parser configurations for structured formats.
- Apply least privilege to database and service accounts so that an injection flaw has reduced impact.
- Do not rely on client-side validation as a security boundary.
SQL parameterization example
$stmt = $db->prepare(
"SELECT id, name
FROM products
WHERE name = ?"
);
$stmt->bind_param("s", $search);
$stmt->execute();
Manual escaping is error-prone and context-dependent. Where parameterized queries are supported, they should be the default approach.
Post-remediation verification
Controlled input remains data and cannot alter the intended interpreter operation.
Controlled input can still influence interpreter structure or execution.
The injection behavior could not be adequately evaluated with the available access or evidence.
Evidence requirements
Redact authentication tokens, passwords, personal information, database credentials, private records and other unrelated sensitive information from screenshots, HTTP captures and source-code excerpts.
Classification
| WebOTG procedure | WebOTG-ID-001 |
|---|---|
| OWASP category | A05:2025 — Injection |
| Procedure type | Injection vulnerability assessment |
| Assessment result | PASS / FAIL / NOT TESTED |
| Finding severity | Determine according to the affected interpreter, privileges available, accessible data or functionality, exploitability and resulting impact. |
WebOTG-ID-001 is a WebOTG-defined verification procedure. The identifier is not an OWASP-defined test identifier.
References
| Source | Relevance |
|---|---|
| OWASP Top 10:2025 — A05 | Primary category definition for Injection. |
| OWASP Web Security Testing Guide | Testing guidance for injection and interpreter-related vulnerabilities. |
| OWASP Application Security Verification Standard | Verification requirements relating to input handling and injection prevention. |
| CWE-89 | Improper Neutralization of Special Elements used in an SQL Command. |
| CWE-78 | Improper Neutralization of Special Elements used in an OS Command. |
| CWE-90 | Improper Neutralization of Special Elements used in an LDAP Query. |
WebOTG should maintain the authoritative source references, document versions and review dates through its content management system rather than embedding mutable reference information into application logic.