OWASP : INJECTION Attacks

Isha Kudkar
ShallVhack
Published in
8 min readJan 16, 2021

In the period of time of the internet, one among the foremost common attack methods was basic, simple brute force. Bots usually performed these attacks –or persons with lots of time off– who tried zillions of combinations of usernames and passwords until they found one that may grant access to the target application.

Brute force attacks are not any longer a threat, due to password policies, limited login attempts, and captchas. But cybercriminals like to discover new exploits and to use them to perform new sorts of attacks. Long ago, they found that text fields on applications or sites may well be exploited by entering –or injecting– unexpected text into them that will force the appliance to try to do something it absolutely was not alleged to do. In this way, the so-called injection attacks entered the scene.

Injection attacks are one in all the foremost common attacks we saw in 2020. In fact, injections are ranked at number one within the OWASP Top Ten Web Application Security Risks. From our scans we consistently see that websites are prone to these kinds of attacks, sometimes critically.

There are many sorts of injection attacks that may be harmful for your web apps and cause severe loss or damage to the information.

Here are a number of the most dangerous attacks:

Code Injection : Code Injection may be a specific style of injection attack where an executable program statement is made involving user input at an attack surface that becomes vulnerable when it may be manipulated in an unanticipated way to invoke functionality which will be used to cause harm. Code injection could be a risk with languages that execute or interpret scripts due to the convenience of running a string as an executable statement or statements at runtime. As an example, languages that have this ability include JavaScript, Perl, Python, and Ruby.

Code injection is potentially the foremost dangerous type of these attacks since it literally provides a chance for the attacker to own their own arbitrary code injected and subsequently executed. Nonetheless, building statements at runtime could be a very powerful and tantalizing technique that’s hard for programmers to resist. There are situations where this method may be a very reasonable choice, but like any powerful tool it’s important that you simply recognize the danger and fully understand the danger so as to make a wise decision about it and when necessary know precisely the way to protect against creating a nasty vulnerability.

SQL Injection : SQL is a database language that stands for Structured query language. it had been designed for operating database systems like MySQL, Oracle, Microsoft SQL Server or SQLite. On the other hand, SQL injection may be a cyber-attack which targets the database with the assistance of specific SQL statements that are crafted to trick the system into performing uncalled and undesired tasks. The SQL injection attack changes the code from what it’s originally commanded to try and do.

A successful SQL injection attack is capable of:

  • Modifying, altering or deleting data from the database
  • Reading sensitive and confidential data from the database
  • Retrieving the content of a selected file present on the management system (DBMS)
  • Enforcing administrative operations like shutting down the DBMS

Without proper mitigation controls and security measures, the SQL injection attack can leave an application at an enormous risk of information compromise. It can impact the data’s confidentiality and integrity similarly because the authentication and authorization with regard to the appliance. It can even empower an adversary to steal confidential information like user credentials, financial information, or trade secrets by misusing the vulnerability existing in an application or program.

Command Injection : In the case of command injection, the vulnerability is because of clumsily constructing a shell command that includes runtime data that the attacker can influence. This class of injection attacks is also called “shell injection”.

The essence of these attacks is that malicious input from an attack surface is employed to coerce a constructed command to perform unanticipated harmful actions when executed by a shell the program invokes. The difference in naming is simply between the changed meaning of the command, or the changed effect of the shell process executing that very same command.

When an untrusted origin supplies values that are potentially controlled by a hacker, always assume the string could also be maliciously crafted. Inputs that contain special characters that will affect how the shell command is parsed must be validated, with troublesome characters quoted, escaped, or otherwise avoided.

There are some strategies, the only is to decide on a secure subset of characters that cover all reasonable uses of the input and you know won’t influence command parsing, and reject strings that contain the other characters being sure to not execute the resulting command. Alternatively, scan and removal of any offending characters and proceed using only the safe characters that remain.

XPath Injection : It’s quite similar to SQL injection, So XPath injection attacks occur when a website constructs an XPath query for XML data from user-supplied information. Thus, the problems that occur when using XML to store data are quite like those faces with SQL.

XPath injection is a style of attack where malicious user inputs are often wont to grant unauthorized access or reveal sensitive information like XML document structure and content. This variety of attack is carried out by making the user’s input be utilized in the development of the query string. Unlike SQL attacks which rely on the SQL dialect utilized by the target database, XPath injection attacks are way more adaptable and ubiquitous.

Due to the similarity to SQLi attacks, the most methods of prevention also are alike. These methods are identical additionally for other typical code injection attacks.

  • Input Validation: The developer ensures that the appliance accepts only legitimate input.
  • Parameterization: during this method, the queries are precompiled and thus pass user input as parameters rather than expressions.

Mail Command Injection : An application that features a mail server that’s not accessible on to the web is at risk of this attack. The attacker can access the port number at which the mail server is running, he will be able to access the mail server directly. This injection attack will be exploited on applications that communicate with a mail server. Vulnerable server allows injection of IMAP or SMTP commands to the mail servers through webmail application. The Mail command injection is feasible because of improper validation of user-supplied data. For an application to be liable to Mail command injection, there are many factors just like the type, scope of injection and mail server technology and plenty of more.

This vulnerability can have the subsequent impacts:-

  • Exploitation of vulnerabilities within the mail protocol.
  • Application restrictions evasion. Using this attack, the attacker will be able to bypass restrictions applied on the server.
  • Data Breach: The attacker can access sensitive information about the appliance.
  • Spamming: Through this attack, the attacker will be able to spam all the users of the mail server.

CRLF Injection : CRLF Injection attack is a very simple, yet a really strong web attack. CRLF stands for carriage return Linefeed, which is a special sequence of characters utilized by the HTTP protocol as a line separator. This attack occurs when an attacker makes the application to return the CRLF sequence plus data that is provided by the attacker as a part of the response headers.

The hackers are exploiting actively this sort of web application vulnerability in performing a large form of attacks, which involve the cross-user defacement, XSS cross-site scripting, and web pages hijacking along with other similar attacks.

The best prevention technique is to not let users put any input directly inside response headers. If that’s impossible, you must always use a function to encode the CR and LF special characters. it’s also advised to update your artificial language to a version that doesn’t allow CR and LF to be injected into functions that set headers.

Host Header Injection : In servers that host many websites or web applications, the host header becomes necessary to see which of the resident websites or web applications –each of them referred to as a virtual host– should process an incoming request. the worth of the header tells the server to which of the virtual hosts to dispatch a request. When the server receives an invalid host header, it usually passes it to the primary virtual host within the list. This constitutes a vulnerability that attackers can use to send arbitrary host headers to the primary virtual host in a very server.

Manipulation of the host header is often associated with PHP applications, although it may be through with other web development technologies. Host header attacks work as enablers for other sorts of attacks, like web-cache poisoning. Its consequences could include the execution of sensitive operations by the attackers, as an example, password resets.

Mitigating against the host header is straightforward — don’t trust the host header. However in some cases, this can be easier said than done. For identifying the situation of the net server if you want to use the host header as a mechanism, it’s highly advised to create use of a whitelist of allowed hostnames.

LDAP Injection : The LDAP ( Lightweight Active Directory Protocol ) is a service and protocol used to access and maintain directory services in IP servers. LDAP works on a client-server model, so apart from providing access to a directory database, it is used for authentication, resource management, and privileges management.

When an attacker inserts malicious statements into a question, then they will send malicious LDAP requests to the server, which successively ends up in security implications. Successful exploitation of LDAP injections could allow attacker to:

  • Access unauthorized information
  • Evade application restrictions
  • Hijack browser sessions
  • Add or modify objects within the LDAP structure

It is important to confirm your LDAP environment is safely configured. the foremost effective solution may be a strong validation of untrusted input. If you’ll properly encode and sanitize all input within the application layer, then you’ll be able to significantly minimize the probabilities of those threats. As a norm, always safeguard sensitive information within the LDAP directory. Configuring user permissions safely is very important for directories used for logging purposes on mobile and web applications.

Preventing injection attacks :

As we saw during this article, all injection attacks are focused towards servers and applications with open access to any internet user. The responsibility to stop these attacks is distributed among application developers and server administrators.

Application developers must know the risk factors involved within the incorrect validation of user input and learn best practices to validate user input with risk prevention purposes. Server administrators have to audit their systems periodically to detect vulnerabilities and correct them as soon as possible.

--

--