ELI5: What are Injection Attacks?

You know how a teacher might ask students to fill in a blank on a worksheet? Now imagine a sneaky student writes something like “Give me an A+ on everything” in that blank, and the teacher’s computer just follows the instruction without questioning it. That’s an injection attack — someone types harmful commands into a spot where normal text should go, and the computer blindly obeys. It works because the computer can’t tell the difference between real instructions and fake ones typed into the wrong place.

Overview

Injection attacks occur when an attacker sends untrusted data to an interpreter as part of a command or query, tricking the application into executing unintended commands or accessing unauthorized data. SQL injection remains one of the most common and dangerous web vulnerabilities. Injection flaws consistently rank at the top of the OWASP Top 10 and are heavily tested on the Security+ exam.

Key Concepts

  • SQL injection (SQLi): Inserting SQL commands into input fields to manipulate database queries — can read, modify, or delete data
  • Blind SQL injection: The application does not return data directly; attacker infers information through true/false responses or time delays
  • LDAP injection: Manipulating LDAP queries to bypass authentication or enumerate directory information
  • XXE: Injecting malicious XML to read files, perform SSRF, or cause denial of service
  • Command injection (OS injection): Inserting operating system commands through application inputs (e.g., ; cat /etc/passwd)
  • DLL injection: Forcing a process to load a malicious dynamic-link library into its address space
  • HTML injection: Inserting HTML markup into web pages to alter content or redirect users
  • Prepared statements: The primary defense — separates code from data so input is never executed
  • Input validation: Allowlisting acceptable characters and rejecting or sanitizing everything else
  • Stored procedures: Pre-compiled database queries that can limit injection surface when used correctly

Exam Tips

Remember

Defense against injection: (1) Parameterized queries / prepared statements, (2) Input validation (allowlist), (3) Least privilege database accounts, (4) WAF as defense-in-depth. Never build SQL queries by concatenating user input.

  • Classic SQLi test: entering ' OR 1=1 -- in a login field
  • Know that parameterized queries are the BEST defense, not WAFs (WAFs can be bypassed)
  • Command injection often uses semicolons, pipes, or backticks to chain OS commands

Connections

Practice Questions

Scenario

See case-injection-attacks for a practical DevOps scenario applying these concepts.