UNDERSTANDING OWASP TOP 10 SERIES and how to test SQL injection vulnerabilities
Open Source Web Application Consortium releases its list of top 10 web vulnerabilities, every three years. The second time in a row, Injection flaws like SQL and LAPD, have managed to keep their top position secure and have emerged as the worst web vulnerability. Injection flaws, such as SQL injection, OS, and LDAP injection occur when untrusted data is sent to an interpreter as part of a command or query. The attacker’s hostile data can trick the interpreter into executing unintended commands or accessing data without proper authorization.
Threat Agents | Application Specific | Consider anyone who can send untrusted data to the system, including external users, internal users, and administrators. | |
Attack Vectors | Exploitability EASY | Attacker sends simple text-based attacks that exploit the syntax of the targeted interpreter. Almost any source of data can be an injection vector, including internal sources | |
Security Weakness | Prevalence | COMMON | Injection flaws occur when an application sends untrusted data to an interpreter. Injection flaws are very prevalent, particularly in legacy code, often found in:
Injection flaws are easy to discover when examining the code, but more difficult via testing. Scanners and fuzzers can help attackers find them. |
Detectability | AVERAGE | ||
Technical Impacts | Impact of SEVERE | The injection can result in data loss or corruption, lack of accountability, or denial of access. The injection can sometimes lead to complete host takeover. | |
Business Impacts | Application / Business Specific | Consider the business value of the affected data and the platform running the interpreter. All data could be stolen, modified, or deleted. Could your reputation be harmed? |
The following example will explain an injection attack scenario:
For www.vulnerable-bank.com, imagine a typical username and password login page. Let’s take an attacking example and how it works scenario.
Normal Scenario: username = author and password = author123
SQL Query:
SELECT * FROM AUTH_TABLE WHERE user =‘author’ and passw = ‘author123’
Attacking Scenario: username = author and password = ‘ or ‘1’=’1
SQL Query:
SELECT * FROM AUTH_TABLE WHERE user =‘author’ and passw = ‘ ‘ or ‘1’=’1’
The above line says, password equals to null or 1=1 (which is universal truth), so the attacker modifies logical AND to logical OR.
The best way to find out if an application is vulnerable to injection is to verify that all use of interpreters clearly separates untrusted data from the command or query. For SQL calls, this means using bind variables in all prepared statements and stored procedures and avoiding dynamic queries.
Checking the code is a fast and accurate way to see if the application uses interpreters safely. Code analysis tools can help a security analyst find the use of interpreters and trace the data flow through the application. Manual penetration testers can confirm these issues by crafting exploits that confirm the vulnerability.
Automated dynamic scanning which exercises the application may provide insight into whether some exploitable injection problems exist. Scanners cannot always reach interpreters and can have difficulty detecting whether an attack was successful.
How to prevent injections like SQL:
Preventing injection requires keeping untrusted data separate from commands and queries.
Here are some recommended best practices to prevent injection exploits:
This post was last modified on January 2, 2024 17:31
Indusface has once again been recognized as a Gartner® Peer Insights™ Customers' Choice for Cloud… Read More
Protect your business from DDoS attacks with multi-layered DDoS defense, proactive threat modeling, rate limiting,… Read More
A Managed WAF is a comprehensive cybersecurity service offered by specialized providers to oversee, optimize,… Read More