← Web Application Security (OWASP) learning path
Web Application Security (OWASP) · Module 2 of 10

Injection prevention

Keep untrusted input from being treated as code or queries.

📖 Key ideas

  1. Injection risks appear when user input is mixed directly into queries or commands.
  2. Use parameterised queries / prepared statements for all database access.
  3. Use well-maintained ORMs and avoid building SQL strings by hand.
  4. Validate input against expected types and formats (allow-lists).
  5. Run database accounts with least privilege.
💡 Real-life example: Parameterised queries are a form with fixed boxes: whatever a user writes stays inside its box and can never change the form.
InjectionUntrusted input interpreted as code
Parameterised queryQuery with placeholders for data
Allow-list validationAccept only known-good input
Least privilegeMinimum permissions needed