SQL Injection: what do you need to know about it?

SQL injection

SQL injection (commonly known as SQLi) is one of the most common web hacking techniques. Basically, hackers place malicious code in SQL statement with the help of webpage input. SQLi has become one of the most recurrent methods to attack any system with the intent of stealing information. Since it helps hackers to compromise data layers and avoid firewalls and other intrusion detection systems the attacker can take control over the database and other systems involving clients and users.

This code injection technique may help them to avoid authentication steps and then subsequently obtain, modify or destroy the information stored in a SQL-based database. SQLi is done in several ways and the major types are In-band, Inferential and Out-of-band SQLi.

SQL injection: how does it work?

When a website asks users for inputs like their username or user ID, hackers provide an SQL input instead of a valid name or an ID. This SQL statement unknowingly runs on the website’s database. In this way, the hacker will be able to obtain personal and sensitive information and many more such useful details.

Moreover, hackers can do an SQL injection in a different way. How? Inserting an input to batched SQL statements. Batched SQL statement is quite common: it is a batch of SQL statements separated by semicolons. If the hacker presents a valid SQL query, he can destroy part of the database.

Through the Union Select statement that combines two unrelated ‘select’ queries the hacker can obtain data from different database tables as well.

SQLi prevention

There are primary and secondary defence mechanisms that you can adopt to stay away from SQLi events. OWASP (Open Web Application Security Project) gives many suggestions, such as:

the use of parameterized queries or prepared statements;

the use of stored procedures in the primary mechanisms;

to enforce least privilege and to carry out additional input validation to strengthen the entire system.

Since the first step to write a database query involves the use of prepared statements, this SQLi prevention mechanism is easy to apply and comprehend. Queries are written to make it impossible for the hacker to change its intent, even with the help of SQL commands. There are language-specific safe query writing procedures that all the developers apply at the very first step. In addition, you can adopt other techniques. As an example: putting codes to help escape user-supplied inputs.

Use the right SQL parameters to prevent SQL injection

In order to prevent SQL injection, you can add SQL parameters to an SQL query at the time of execution. Basically, SQL paramenters are values that you must add in a controlled way. Here you can find two of the most popular and effective techniques to prevent SQL injection attacks:

Sanitization or input validation;

Installation of WAF or web application firewall;

…

In order to ensure absolute protection, Swascan developed a unique Vulnerability Assessment tool.

It spots all the vulnerabilities of a web site or web application (including SQLi) and allows to fix them. Clicking on the button below you can have a free trial of the solution:

Swascan Co-Founder: Raoul Chiesa

One of Swascan co-founders is Raoul Chiesa, one of the major cybersecurity experts wolrdwide. Raoul has a deep knowledge of SQL Injection:

“I brought penetration testing to Italy and explained SQL Injection to Kevin (Mitnick) in 2000. With a bunch of friends I started doing R&D on a satellite hacking, we started discussing about Security by Design in 2010, about Cyber Threat Intelligence in 2012… Basically, geniuses!”

Raoul co-founded Swascan in order to deal with such vulnerabilities as SQLi.

Swascan

In order to assure to your business the best tool available, Swascandeveloped a special ( Premio Cisco-Marzotto winner ) cybersecurity platform. It is completely in Cloud, Pay per Use and SaaS. You can see for yourself in our brochure: Cybersecurity platformand have an in-depth look at our services. Our three services cover all the governance needs in terms of risk management and periodic assessment. Basically, if you need to understand the areas in which your efforts must focus, Vulnerability Assessment, Network Scan and Code Review are the right tools for you. Last but not least, don’t forget GDPR: our platform is 100% GDPR compliant ( GDPR infographic ).