Attacks can execute the code injected by attackers as part of user inputs.

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.

Types of Injection Attacks

SQL injection (SQLi) and Cross-site Scripting (XSS) are the most common injection attacks but they are not the only ones. The following is a list of common injection attack types.

Injection attackDescriptionPotential impactCode injectionThe attacker injects application code written in the application language. This code may be used to execute operating system commands with the privileges of the user who is running the web application. In advanced cases, the attacker may exploit additional privilege escalation vulnerabilities, which may lead to full web server compromise.Full system compromiseCRLF injectionThe attacker injects an unexpected CRLF (Carriage Return and Line Feed) character sequence. This sequence is used to split an HTTP response header and write arbitrary contents to the response body. This attack may be combined with Cross-site Scripting (XSS).Cross-site Scripting (XSS)Cross-site Scripting (XSS)The attacker injects an arbitrary script (usually in JavaScript) into a legitimate website or web application. This script is then executed inside the victim’s browser.

  • Account impersonation
  • Defacement
  • Run arbitrary JavaScript in the victim’s browser
Email Header InjectionThis attack is very similar to CRLF injections. The attacker sends IMAP/SMTP commands to a mail server that is not directly available via a web application.
  • Spam relay
  • Information disclosure
Host Header InjectionThe attacker abuses the implicit trust of the HTTP Host header to poison password-reset functionality and web caches.
  • Password-reset poisoning
  • Cache poisoning
LDAP InjectionThe attacker injects LDAP (Lightweight Directory Access Protocol) statements to execute arbitrary LDAP commands. They can gain permissions and modify the contents of the LDAP tree.
  • Authentication bypass
  • Privilege escalation
  • Information disclosure
OS Command InjectionThe attacker injects operating system commands with the privileges of the user who is running the web application. In advanced cases, the attacker may exploit additional privilege escalation vulnerabilities, which may lead to full system compromise.Full system compromiseSQL Injection (SQLi)The attacker injects SQL statements that can read or modify database data. In the case of advanced SQL Injection attacks, the attacker can use SQL commands to write arbitrary files to the server and even execute OS commands. This may lead to full system compromise.
  • Authentication bypass
  • Information disclosure
  • Data loss
  • Sensitive data theft
  • Loss of data integrity
  • Denial of service
  • Full system compromise.
XPath injectionThe attacker injects data into an application to execute crafted XPath queries. They can use them to access unauthorized data and bypass authentication.
  • Information disclosure
  • Authentication bypass

It’s easy to test if your website or web application is vulnerable to all the injection attacks listed above. All you need to do is run an automated web scan using the Acunetix vulnerability scanner. Take a demo and find out more about running scans against your website or web application.

Frequently asked questions

What are injection attacks?

In an injection attack, the attacker is able to provide malicious input to a web application (inject it). The application processes this malicious input, which causes the application to behave in an unexpected way. For example, it may reveal information that should not be revealed, give the user permissions that the user should never have, or run harmful code on the server or on the client.

Learn more about the basics of web security.

What are the common types of injection attacks?

Some of the most common types of injection attacks are SQL injections, cross-site scripting (XSS), code injection, OS command injection, host header injection, and more. A large part of vulnerabilities that exist in web applications can be classified as injection vulnerabilities.

Read about SQL injection – one of the most serious types of injection attacks.

How to detect injection vulnerabilities?

The most efficient way to detect injection vulnerabilities, which make injection attacks possible, is by using an automated web vulnerability scanner. You can detect them manually through penetration testing but this takes a lot more time and resources. Acunetix is able to detect, assess, and manage all types of injection vulnerabilities.

See what Acunetix Premium can do for you.

How to avoid injection attacks?

To avoid injection attacks you must code your web applications in a secure way to avoid injection vulnerabilities. The most important part is: never trust user input. The more you restrict, control, and monitor any form of user input, the more you can avoid your application being hacked.

Learn more about secure coding best practices.

Get the latest content on web security
in your inbox each week.

We respect your privacy

SHARE THIS POST

THE AUTHOR

Attacks can execute the code injected by attackers as part of user inputs.

Ian Muscat

Ian Muscat used to be a technical resource and speaker for Acunetix. More recently, his work centers around cloud security and phishing simulation.

What type of attack is code injection?

Code injection is the term used to describe attacks that inject code into an application. That injected code is then interpreted by the application, changing the way a program executes. Code injection attacks typically exploit an application vulnerability that allows the processing of invalid data.

Which attack can execute the code?

Code Injection is the general term for attack types which consist of injecting code that is then interpreted/executed by the application. This type of attack exploits poor handling of untrusted data.

Which attack allows attackers to directly execute system commands?

Command injection is a cyber attack that involves executing arbitrary commands on a host operating system (OS).

Which attack is a type of injection where malicious scripts are injected?

Cross-site scripting attacks, also called XSS attacks, are a type of injection attack that injects malicious code into otherwise safe websites.