OWASP A03:2021 - Injection

Overview

Injection vulnerabilities occur when untrusted data is sent to an interpreter as part of a command or query. The attacker's hostile data can trick the interpreter into executing unintended commands or accessing data without proper authorization.

Risk Rating: High CWE Mappings: 33 CWEs mapped to this category Prevalence: 94% of applications tested had some form of injection Previous Ranking: A01:2017 (moved to #3 due to better frameworks and awareness)

Types of Injection Vulnerabilities

1. SQL Injection (SQLi)

  • Classic/Union-based: Retrieving data through UNION statements

  • Boolean-based Blind: True/false responses to infer data

  • Time-based Blind: Using delays to infer data

  • Error-based: Extracting data through database error messages

2. NoSQL Injection

  • MongoDB: JSON/JavaScript injection in NoSQL queries

  • CouchDB: JSON manipulation attacks

  • Cassandra: CQL injection vulnerabilities

3. Command Injection (OS Command Injection)

  • Direct: Direct execution of system commands

  • Indirect: Command execution through application functions

4. LDAP Injection

  • Authentication Bypass: Bypassing LDAP authentication

  • Data Extraction: Extracting directory information

5. XPath Injection

  • XML Data Extraction: Extracting data from XML documents

  • Authentication Bypass: Bypassing XPath-based authentication

6. Template Injection (SSTI)

  • Server-Side Template Injection: Code execution through template engines

  • Client-Side Template Injection: XSS through template rendering

SQL Injection Testing Methodology

1. Detection Phase

2. Union-Based SQL Injection

3. Boolean-Based Blind SQL Injection

4. Time-Based Blind SQL Injection

5. Error-Based SQL Injection

NoSQL Injection Testing

MongoDB Injection

Command Injection Testing

Detection and Exploitation

Advanced Command Injection

LDAP Injection Testing

Authentication Bypass

Data Extraction

Server-Side Template Injection (SSTI)

Detection and Exploitation

Tools and Automation

SQLMap Usage

Custom Injection Testing Tools

Advanced Exploitation Techniques

SQL Injection Data Exfiltration

WAF Bypass Techniques

Prevention and Mitigation

1. Parameterized Queries/Prepared Statements

2. Input Validation and Sanitization

3. Template Security

Testing Checklist

SQL Injection Testing

Command Injection Testing

Other Injection Types

Reporting Template

Finding: [Injection Type] - [Specific Vulnerability]

Severity: High/Critical CVSS Score: [Calculate based on impact]

Description: [Detailed description of the injection vulnerability]

Vulnerable Parameter:

  • URL: [Vulnerable endpoint]

  • Parameter: [Parameter name]

  • Method: [GET/POST/etc.]

Proof of Concept:

Last updated