Skip to contentExploitQuest

A Query Built From Pieces

SQL injection is not a trick. It is what happens when a program builds a sentence out of your words and then reads the whole thing as an instruction.

1 min readNot yet reviewed
Wrenlearner

Everyone talks about SQL injection like it is some dark art. Is it actually complicated?

Rookmentor

It is one of the simplest bugs there is, which is exactly why it is still everywhere. Somebody built a sentence by gluing pieces together, and one of the pieces came from a stranger.

Wrenlearner

That is it?

Rookmentor

That is it. The hard part is not the attack. It is noticing you have written it.

A sentence with a hole in it

An application wants to look somebody up, so it writes a query with a gap where your search goes. Then it fills the gap by joining strings together.

query = "select * from staff where surname = '" + input + "'"
         \________________________________/     \