DEV Community

Jon Luke Harvey
Jon Luke Harvey

Posted on • Edited on

What is SQL injection?

SQLI: Short for SQL injection.
DBMS: Short for databse management system.

Hello everyone! This is my first post so any constructive criticism would be nice! Since I have been learning about Web application hacking and a lot of people on this website are web developers, I hope to make posts on common website vulnerabilities and how to protect your self against them so you don't fall for these!

First: What is SQL injection?

According to OWASP(Open web application security project) SQL Injection is:
"A SQL injection attack consists of insertion or "injection" of a SQL query via the input data from the client to the application"(https://www.owasp.org/index.php/SQL_Injection)

What does this mean? In simple terms this is an injection(meaning typing in commands or queries) into a field with SQL code that allows the manipulation of the websites database.

So what does it do exactly?

A SQL injection can be dangerous if your website is vulnerable to it and here's some reasons why. If successful a SQL injection can:

  1. Exploit and read sensitive data from the database. A SQL injection if done correctly, can read sensitive data from a DB so something such as phone numbers, addresses, and even passwords (and usually the SQL command would gather ALL of these. So, ALL passwords, ALL addresses, etc. even the admin!!!)
  2. Another thing it has the potential to be able to mess with the actual data. This is pretty straight forward but basically it would be able to insert/update/delete. (NOTE: This can happen unintentionally if a hacker isn't aware of what they are doing. They could input a SQL injection command and not be familiar with the DB and potentially delete specific data or all of it! Same goes for insert or update. Another reason why you should protect yourself against SQLI!)
  3. Mess with the DBMS. A SQLI can also mess with the DBMS. It has the potential to activate administrative commands(such as shut down DBMS), it can also do things like recover files from the DBMS and even can issue commands to the OS.

It is important that you protect your website when just starting out and creating it from SQL injection! (And even if you're google or facebook!) In the next couple of posts I will be posting on what the code looks like and how to protect yourself. I certainly hope this was informing for you and again, any feedback would be nice! :)

Links: OWASP Article on SQLI
Explanation from youtube on SQLI

Top comments (5)

Collapse
 
darkain profile image
Vincent Milum Jr

Each language has toolkits to help mitigate these issues. For me, I develop mostly in PHP for the web. For this, I don't even write SQL anymore, instead delegating the task to a dedicated SQL query generator and data processor library: github.com/darkain/pudl

Collapse
 
randalschwartz profile image
Randal L. Schwartz

Best collection of advice about this is at bobby-tables.com

Collapse
 
mountainmanjon profile image
Jon Luke Harvey

Thank you! I always love new resources that are helpful. :)

Collapse
 
geshan profile image
Geshan Manandhar

Some examples would have been great addition.

Collapse
 
mountainmanjon profile image
Jon Luke Harvey

Yes! Thank you. I am going to be doing that in my next article because I wrote this one up rather quickly during finals week and did not have a lot of time to write a full one. Stay tuned. :)