UNDERSTANDING OWASP TOP 10 SERIES and how to test SQL injection vulnerabilities
By Venkatesh Sundar, Chief Technology Officer, Indusface
Open Source Web Application Consortium releases its list of top 10 web vulnerabilities, every three years. 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.
|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
SELECT * FROM AUTH_TABLE WHERE user =‘author’ and passw = ‘author123’
Attacking Scenario: username = author and password = ‘ or ‘1’=’1
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:
Founder & Chief Marketing Officer, Indusface
Venky has played multiple roles within Indusface for the past 6 years. Before this, as the CTO @ Indusface, Venky created the product/service offering and technology team from scratch and grew it from ideation to getting initial customers with a proven/validated business model poised for scale. Before joining Indusface, Venky had 10+ years of experience in the security industry and had held various mgmt/leadership roles in Product Development, Professional Services, and Sales @Entrust.