OWASP Top 10 Threats and Mitigations: Injection

The OWASP Top 10 lists the most critical security risks for web applications. In its 2013 edition, injection is number one. This post explains what it is and how to prevent it.

What is an injection?

An injection happens when an application sends untrusted input to an interpreter (a database, a shell, an LDAP directory) as part of a command or query. If the input is not properly separated from the code, an attacker can change the meaning of the command.

Classic example, a login query built by concatenation:

SELECT * FROM users WHERE name = '" + username + "' AND password = '" + password + "'

If the attacker types ' OR '1'='1 as a username, the condition is always true, and the query may return every user.

Common types

  • SQL injection: manipulating database queries.
  • OS command injection: running system commands through the application.
  • LDAP and XPath injection: manipulating directory or XML queries.

Possible impact

  • data theft or data loss;
  • authentication bypass;
  • in the worst case, full control of the server.

How to prevent it

  1. Use parameterised queries (prepared statements). The query structure is defined first, and user data is passed separately, so it can never become code.
  2. Validate input with allow-lists: accept only the expected formats.
  3. Escape special characters when parameterised queries are not possible.
  4. Apply the principle of least privilege: the application's database account should only have the rights it needs.
  5. Test regularly with code review and security scanners.

Update (2026): in the OWASP Top 10 2021, injection is ranked third (A03) and now also includes cross-site scripting. Parameterised queries remain the most effective defence.

Boris Guiffot

Comments

Popular posts from this blog

Langues pivots (1/3) : un projet pour passer de la tribu à la culture

Pourquoi l'origine compte-t-elle plus que le programme au Cameroun ? (1/5)

Une langue commune pour les Grassfields : l'informatique au service des communautés