Injection attacks refer to a broad class of attack vectors. In an injection attack, an attacker supplies
untrusted input to a program. This input gets processed by an interpreter as part of a command or query. In
turn, this alters the execution of that program.
Injections are amongst the oldest and most dangerous attacks aimed at web applications. They can lead to data
theft, data loss, loss of data integrity, denial of service, as well as full system compromise. The primary
reason for injection vulnerabilities is usually insufficient user input validation.
This attack type is considered a major problem in web security. It is listed as the number one web application
security risk in the OWASP Top 10 – and for a good reason. Injection attacks, particularly SQL Injections
(SQLi attacks) and Cross-site Scripting (XSS), are not only very dangerous but also widespread, especially in
legacy applications.
What makes injection vulnerabilities particularly scary is that the attack surface is enormous (especially for
XSS and SQL Injection vulnerabilities). Furthermore, injection attacks are a very well understood
vulnerability class. This means that there are many freely available and reliable tools that allow even
inexperienced attackers to abuse these vulnerabilities automatically.
Preventing injection requires keeping data separate from commands and queries:
Scenario: Use LIMIT and other SQL controls within queries to prevent mass disclosure of records in case of SQL injection.
String query = "SELECT \* FROM accounts WHERE custID='" + request.getParameter("id") + "'";