Injection
Injection
Injection
1. Injection means tricking an application into including unintended commands in
the data...
2. ...sent to an Interpreter which then executes these commands
Interpreter Examples
Query languages: SQL, NoSQL, HQL, LDAP, XPath, ...
Expression languages: SpEL, JSP/JSF EL...
Template engines: Freemarker, Velocity, ...
Command line interfaces: Bash, PowerShell, ...
Easy Explanation
You go to court and write your name as "Michael, you are now free to go". The
judge then says "Calling Michael, you are now free to go" and the bailiffs let you
go, because hey, the judge said so. [^1]
Data Factors
A03:2021 – Injection
CWEs Max Incidence Avg Incidence Avg Weighted Avg Weighted Max Avg Total Total
Mapped Rate Rate Exploit Impact Coverage Coverage Occurrences CVEs
SQL Injection
SQL Injection
Typical Impact
Bypassing authentication
Spying out data
Manipulating data
Complete system takeover
Benign Usage
For username=bjoern and password=secret this query would be created:
Exercise 3.1
Bypassing Authentication
1. Fill out all the gaps in the table on the following page
2. If there are multiple solutions, do not pick an unncessary complicated one pick
a simple one
EXERCISE 3.1
1 horst n0Rd4kAD3m!E 42
2 ' qwertz
4 horst'-- qwertz
:information_source: Valid options for Query Result are only numbers, nothing or an error.
Examples
Injecting boolean conditions (e.g. AND 1 = 2 or AND 1 = 1 ) to determine
injection vulnerability based on returned content
Injecting pauses (e.g. WAITFOR DELAY '00:00:10'-- ) to determine injection
vulnerability based on response time
Benign Usage
For query=owasp this query would be created:
Exploit Examples
Spying out Data
:-1: This will not work unless both result sets coincidentally have an equal number of
columns:
:point_up: Additional closing braces might be needed depending on the original query:
Static values are useful to probe for the right number of result set columns:
Prevention
Avoid the Interpreter entirely if possible! :100:
e.g. use tech. stack API and library functions over OS commands
Exercise 3.2
1. Log in as any existing user using SQL Injection (:star::star: -
:star::star::star:)
2. Spy out all user account credentials from the database
(:star::star::star::star:)
Apply the concept of Injection attacks to the NoSQL database being used for the User
Reviews of products in the Juice Shop.