Lab 10: SQL Injection UNION Attack (Retrieving Multiple Values in a Single Column)

Attack Vector Used 

  1. SQL Injection (SQLi) via the product category filter parameter.
  • Exploits improper input sanitization to manipulate the SQL query and extract data from other tables (e.g., `users`) when only one column supports text data. 

Exploitation Steps

  1. Intercept the Request with Burp Suite
  2. Capture the HTTP request containing the category filter.
  3. Send it to Burp Repeater for manipulation.
  • Determine the Number of Columns and Text Compatibility
  • Using: ‘+UNION+SELECT+NULL,'abc'—
  1. If successful, confirms two columns, with only the second column supporting text.
  • Extract Data from the `users` Table (Concatenated in One Column)
  • Using: ‘+UNION+SELECT+NULL,username||’~’||password+FROM+users—
  1. The `||` operator concatenates `username` and `password` with a separator (`~`).
  2. Verify the response contains usernames and passwords in a single column (e.g., `admin~password123`).
  1. Use the provided username and password to login.

Mitigation Strategies

  1. Use Prepared Statements (Parameterized Queries): Ensures user input is treated as data, not executable SQL.
  2. Input Validation & Sanitization: Restrict input to expected formats (e.g., allowlist valid category values).
  3. Limit Database Permissions: Ensure the DB user has minimal privileges (e.g., no unnecessary `SELECT` access).
  4. Web Application Firewall (WAF): Deploy a WAF to detect and block SQLi patterns.
  5. Error Handling & Logging: Avoid exposing database errors to users; log them securely for debugging. 

Conclusion

This lab demonstrates how a UNION-based SQL injection can bypass column limitations by concatenating data into a single text-compatible column. Always secure applications with defensive coding practices and layered protections. 

0 0 votes
Article Rating
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x