Skip to main content
Module 2 · Lesson 2 of 45/42 in the course~16 min
Module lessons (2/4)

UNION Exfiltration from Search

Lesson preview6 hands-on exercises readyApplication & Web Security · Module 2 — Injection & Database Security (PostgreSQL)

Extract hidden API keys via UNION SELECT from a search helper, then lock down column access with bound parameters.

What you'll learn in this lesson

  • Exploit a UNION SELECT vulnerability inside dynamic catalog search to read unrelated vault tables (sec_api_secrets).
  • Align exact column count and PostgreSQL data types required for UNION queries.
  • Remediate search endpoints with parameterized ILIKE $1, then harden against LIKE wildcard abuse (% / _).

Overview

Whenever a query returns result rows back to the user — such as a product catalog search bar or report filter — and interpolates user text into SQL, attackers append a UNION SELECT clause to siphon confidential columns from completely unrelated tables into the HTTP response.

PostgreSQL enforces two strict rules on every UNION SELECT:

Sections covered in this lesson

  1. 11. UNION Type Rules & Wildcard Binding
  2. 22. Interactive SQL UNION & AST Visualizer
  3. 33. Progressive Labs: Warm-Up → Attack → Defend → Harden
  4. 44. Checkpoints & Code Review
Pro Lesson · Module 2 — Injection & Database Security (PostgreSQL)

Unlock "UNION Exfiltration from Search" and the full Application & Web Security curriculum

Extract hidden API keys via UNION SELECT from a search helper, then lock down column access with bound parameters.

Unlock all 6 hands-on exercises in this lesson plus every advanced WebAssembly module with automated checks.

  • Instant access to all advanced modules in Application & Web Security plus 17 more courses
  • Hands-on browser exercises with automated test suites and solutions
  • 14-day money-back guarantee processed via Paddle.com

14-day guarantee · Cancel anytimeModule 1, all 18 interactive games, and cheatsheets are always free.