SQL Injection: UNION Based Injection
In a standard SQL query, data is retrieved from one table. The UNION operator allows multiple SELECT statements to be combined. If an application is vulnerable to SQL injection, an attacker can inject a crafted SQL query that appends a UNION statement to the original query.
Let's assume a vulnerable web application retrieves product details based on a product ID from a database:
SELECT product_name, product_price FROM products WHERE product_id = 'input_id';An attacker could modify the input_id to include the data from another table like users.
1' UNION SELECT username, password FROM users --After submitting our payload, the query become the following SQL:
SELECT product_name, product_price FROM products WHERE product_id = '1' UNION SELECT username, password FROM users --';:warning: The 2 SELECT clauses must have the same number of columns.
Comments
No comments yet.