Glossary

SQL injection

An attack where user input changes a database query, letting someone read or change data they should not.

In plain words

SQL injection happens when an app glues what a user typed directly into a SQL query. A specially crafted input can then change the query's meaning, for example to return every user instead of one.

Think of a form letter: "Give the parcel to ___." If someone writes "anyone who asks" in the blank, and the clerk follows the letter exactly, the rule is broken. The fix is to keep the blank separate from the instructions.

How to prevent it

Use parameters (bindings): the query and the input travel separately, so input can never become part of the command. Laravel's query builder and Eloquent do this automatically.

Practise the fix in Secure a Laravel app.

Found this useful?

Every lesson stays free. Tap the thumbs up so we know what works, or say thanks with a soda or a coffee: it pays for hosting and new lessons.

Buy me a sodaBuy me a coffee

Want more on this?

Tell us which part was not clear, ask for a follow-up lesson, or request a lesson on any topic. We read every request.

I would like
Only to tell you when it is ready.

WhatsApp

Join the channelChat with us

Free lessons and updates in the channel. Questions about learning or training? Chat with us.