What is SQL Injection? How to Prevent SQL Injection Attack? SQL Queries, SQL Attack Examples
SQL Injection |
SQL injection is a type of security exploitation in which the web form adds structured query language (SQL) code to the input form in the input box to gain access to the attacker resources or to change the data. SQL is a code injection technique.
SQL injection attacks cause attackers to spoil the identity, tamper with existing data, issues such as forward transactions or changing the balance, allow complete disclosure of all data on the system, destroy data or otherwise make unavailable, and administrators become the database server. While this technique can be used to attack any SQL database, most websites are attacked.
SQL Injection |
WHAT ARE SQL QUERIES
SQL is a standard language that is used to access and efficiently access the database to create customizable data views for each user. SQL queries are used to execute commands, such as data retrieval, update and record removals.
Various SQL Elements implement different actions, for example, to query data by using the SELECT statement to retrieve data based on the parameters provided by the user.
Here are four main subtypes of SQL injection
· Classic SQLI
· Blind or Inference SQL injection
· Database management system-specific SQLI
· Compounded SQLI
· SQL injection + insufficient authentication
· SQL injection + DDoS attacks
· SQL injection + DNS hijacking
· SQL injection + XSS
How SQL Injection works
For a SQL injection attack, the weak website needs to include user input directly within the SQL input. An attacker can then insert a payload that will be included as part of the SQL query and will run against the database server.
The following server-side pseudo-code is used to authenticate users in the web application.
# Define POST variables uname = request.POST['username'] passwd = request.POST['password'] # SQL query vulnerable to SQLi sql = “SELECT id FROM users WHERE username=’” + uname + “’ AND password=’” + passwd + “’” # Execute the SQL statement database.execute(sql)
This script is an example of authenticating the user with the username and password against a database with a table named users, and a username and password column. This script is vulnerable to SQL Injection. Because an attacker can submit malicious input in a way that will change the SQL statement executed by the database server.
What’s the worst an attacker can do?
A good attacker will use SQL injection for bypass authentication or even impersonate specific users.
One of the primary tasks of SQL is to select the data based on a query and output the result of that query. A SQL injection vulnerability may allow complete disclosure of data on the database server.
Using SQL to change the data within the web application database, an attacker can use SQL injunctions to change the data stored in the database. Changing the data affects data integrity and, for example, may cause rejection issues, such as changing transaction transactions, balances and other records.
SQL is used to remove records from the database. An attacker could use a SQL injection vulnerability to delete data from the database. Even if the appropriate backup strategy is employed, removing the data may affect the availability of the application until the database is restored.
Servers are configured to allow arbitrary execution, looking at the right conditions, an attacker can use SQL injection as an initial vector in an internal network attack that sits behind the firewall.
Vulnerable to a SQL injection attack??
It is the first step in stopping a SQL injection attack to determine which of your applications (if any) is weak. The best way to do this is to see if they are successful or not, to launch their own attacks. But SQL is a complex language, so it's not a small task to create code snippets that can be injected into a query to try to compromise a database. You need to run an automated SQL injection attack tool to work for you.
These tools put a powerful SQL injection attack arsenal which looks like attacking your applications, it is worth to test their applications with these devices and fix any vulnerabilities in light before finding any malicious in them.
Read Also: The Best Portable Bluetooth speakers 2018
Steps to prevent SQL injection attacks
You can take the following steps to reduce the risk of suffering a SQL injection attack:
Do not trust anyone
Assume that the data submitted by all users is bad, so to ensure that any dangerous characters such as the data have not been passed in the SQL query, to make sure mysql mysql_real_escape_string () Use input validation through the medium. You should also clean everything by filtering user data according to the reference. For example, the email address should be filtered to allow only letters allowed in the e-mail address, phone numbers must be filtered to allow the numbers allowed only in the phone number, and so on.
Update Patch
Vulnerabilities are detected on regular basis in applications and databases exploiting hackers using SQL injection, so it is important to apply patches and updates practically. A patch t solution may be worth the investment.
Firewall
A web application firewall (WAF) to help filter malicious data. The good ones will have a wider set of default rules, and whenever necessary, it will be easy to add new ones. Before providing patches, a WAF can be especially useful to provide some safety against a new vulnerability.
Use appropriate privileges
Do not connect to your database using an administrator-level privileged account unless there are some mandatory reasons for doing so. Using a limited access account is safer, and what the hacker can do is limited to what is capable of doing.
Reduce surface attacks
To limit permissions on the database login used by the web application, it can only help to reduce the effectiveness of any SQL injection attacks, which takes advantage of any bug in the web application.
Encryption
Secured all important data and do not tell anyone your secrets.
Continuously monitor SQL statements
This will help in identifying counterfeit SQL statements and vulnerabilities. Monitoring tools that use machining learning and behavioral analysis can be particularly useful.
0 comments:
Post a Comment