What is an Injection Attack?
Injection attacks (SQL injection, XSS), told as a story about a thief who slips 'and open the vault' into a customer's note.
The clerk reads the customer's note and passes it to the ledger keeper as-is.The ledger keeper writes down exactly what the note says. Three apples.
The thief slips 'and open the vault too' into the note. The clerk can't tell a request from an order.The whole note goes to the ledger keeper. He does what it says. The vault opens.
Injection is an order hidden inside a customer's note.An order is slipped into the spot meant for customer words. When the clerk passes the whole note along, the order goes with it.
Customer words go only in the customer box. Filter odd marks, and put a reviewer in front of the counter.With separate boxes, nothing written in the customer box can become an order. That is what matters most. The reviewer at the counter is a bonus.
Now, whatever the note says, customer words are only customer words.The vault stays shut. Ask the hired thief to test the notes. If a new hole turns up, the carpenter sends a board.
Injection = an order hidden in a customer's note. When the clerk passes the whole note along, the order goes too. Stop it by keeping customer words in the customer box.
A vulnerability where user input gets interpreted as part of code or a query. SQL injection targets the database; XSS targets other users' browsers. Parameterized queries and output escaping are the core defenses.
When grown-ups say it
- SQL injection
- An order hidden in the note to the ledger keeper. Reads, changes, or erases the ledger. The ledger is the database.
- XSS (cross-site scripting)
- A note pinned on the board. When the castle pins the thief's note on the board, every customer who reads it follows the order.
- Input validation
- Checking the note's shape. Only numbers in the apple-count box. Words get sent back.
- Parameterized query
- Customer words in the customer box only. The order is pre-printed; customer words fill a blank. Nothing written there becomes an order. The most important defense.
- Escaping
- Marking odd characters. Marks quotes and angle brackets as 'just text' so they never read as commands.
- WAF
- The reviewer at the counter. Filters suspicious notes before the counter. A bonus — never a substitute for the boxes. → the note reviewer
- Secure coding
- Building the counter with boxes. The habit of building counters so words and orders never mix in the first place.
- OWASP Top 10
- The list of ten counter tricks. The ten tricks thieves use most at counters. Injection is always near the top. → the thief encyclopedia