Common Web Attack Vectors Explained

In the world of web security, understanding common attack vectors is essential to safeguarding websites and services. This article explores some of the most common attacks, including those frequently observed in server logs. By being aware of these attacks, administrators can take appropriate measures to protect their websites. Often, hundreds of rules are needed to cope with various attacks, and this article only provides insight into some of the common attack vectors. It is by no means a complete list of attack vectors or solutions, as there can be many different types and variations.

1. SQL Injection (SQLi)

SQL Injection is an attack that involves inserting or manipulating SQL queries in a web application’s database. Attackers use this technique to execute unauthorized SQL commands by exploiting vulnerabilities in input fields.

Common patterns observed:

Fail2Ban Regex Example:

failregex = ^<HOST> -.*"(GET|POST) .*['"]*(sleep\(|xor\().*HTTP/.*"

Note: This is an example and may not be “drop in code” for production environments.

2. Cross-Site Scripting (XSS)

Cross-Site Scripting is an attack where malicious scripts are injected into trusted websites. These scripts can steal cookies, impersonate users, or manipulate site content.

Common XSS patterns include:

Fail2Ban Regex Example:

failregex = ^<HOST> -.*"(GET|POST) .*(\<script\>|onerror=|javascript:).*HTTP/.*"

Note: This is an example and may not be “drop in code” for production environments.

3. Remote Code Execution (RCE)

Remote Code Execution allows attackers to execute arbitrary code on the server. This type of attack often uses command chaining to run multiple commands, which can lead to system compromise.

Examples of command chains:

Attackers may use tools like wget, curl, or chmod to download and execute malicious scripts.

Fail2Ban Regex Example:

failregex = ^<HOST> -.*"(GET|POST) .*(wget|curl|chmod\s\+x).*HTTP/.*"

Note: This is an example and may not be “drop in code” for production environments.

4. Path Traversal & Directory Traversal

Path traversal involves accessing unauthorized directories and files, often using sequences like ../ to navigate the file system.

Examples include:

Fail2Ban Regex Example:

failregex = ^<HOST> -.*"(GET|POST) .*(\../).*HTTP/.*"

Note: This is an example and may not be “drop in code” for production environments.

5. Bot Probing & Brute Force

Automated bots often probe websites to find vulnerabilities or exploit known ones. They may use brute force techniques to guess credentials or scan for specific vulnerable paths.

Examples of bot activity:

Fail2Ban Regex Example:

failregex = ^<HOST> -.*"(GET|POST) .*/wp-login\.php.*HTTP/.*"

Note: This is an example and may not be “drop in code” for production environments.

6. Exploiting Third-Party Software

Many attacks target known vulnerabilities in third-party software. If a website runs software like Joomla, WordPress, or even web interfaces like OpenWrt’s LuCI, attackers will attempt to exploit them.

Examples:

Fail2Ban Regex Example:

failregex = ^<HOST> -.*"(GET|POST) .*/components/com_jnews/.*HTTP/.*"

Note: This is an example and may not be “drop in code” for production environments.

7. Accessing Invalid Paths or Files

Attackers often look for files and folders that shouldn’t exist, like configuration files or outdated software paths.

Examples:

These attacks often use HTTP 200 or 301 responses to determine if the path exists, even if the intended behavior should have been a 404 response.

Fail2Ban Regex Example:

failregex = ^<HOST> -.*"(GET|POST) .*(/wp/|/blog/|/temp/).*HTTP/.*"

Note: This is an example and may not be “drop in code” for production environments.

8. Denial of Service (DoS) via Multiple 404 Errors

DoS attacks often include making numerous requests to invalid pages, resulting in a large number of 404 responses in a short period of time. This can lead to server resource exhaustion.

Fail2Ban Regex Example:

failregex = ^<HOST> -.*"(GET|POST) .*HTTP/.*".* 404

Note: This is an example and may not be “drop in code” for production environments.

9. Attacks Using Binary Data or Malformed Requests

One of the attack types that is often seen in server logs involves requests with binary data or malformed requests, which can exploit vulnerabilities in poorly configured servers or software.

These requests are generally crafted to confuse or break the underlying software, making it behave unpredictably or exposing vulnerabilities.

Fail2Ban Example:

failregex = ^ -.*".*\\x[0-9A-Fa-f]{2}.*".*"-" "-"

This regex aims to detect and block requests containing hexadecimal byte values, often used for fuzzing or binary payload delivery.

Note: This is an example and may not be “drop in code” for production environments.

Conclusion

Blocking attacks is essential to maintaining the integrity and security of web services. Failing to protect a server against these common attack vectors can lead to unauthorized access, information theft, or complete service failure. In the case of DDoS-type attacks, servers can easily run out of resources, such as bandwidth, CPU, and memory, rendering them unavailable to legitimate users. Properly configured rules, such as those demonstrated here, help mitigate a wide range of attacks. However, it is important to recognize that no solution is perfect. Maintaining effective protection requires constant vigilance, updating rules, and adjusting configurations as new threats emerge.