A security analyst reviews an Apache access log entry: 192.168.1.5 - - [10/Jan/2024:08:12:35 +0000] "GET /index.php?id=1 UNION SELECT username,password FROM users-- HTTP/1.1" 200 4321 "-" "Mozilla/5.0". What type of attack is MOST likely indicated?
Trap 1: Cross-site scripting (XSS)
The log entry contains SQL UNION syntax, whereas XSS payloads rely on script tags, event handlers like onerror, or javascript: URIs that execute in the victim's browser. XSS attacks target client-side interpretation of dynamic HTML, not the server-side database query. A UNION SELECT clause is a structured query language operation that fuses result sets from the database, which has no effect on raw HTML rendering. Therefore, the observed payload does not match the injection pattern expected for cross-site scripting.
Trap 2: Path traversal
Path traversal typically constructs sequences such as ../../etc/passwd or encoded variants like %2e%2e%2f to escape the webroot and read arbitrary files. The apache log entry cited here does not contain any dot-dot-slash or similar traversal pattern; it contains the SQL keyword UNION SELECT. Path traversal manipulates file path strings used by file system functions, while UNION SELECT manipulates a database query. Hence the attack is not a path traversal.
Trap 3: Remote file inclusion
Remote File Inclusion requires the attacker to supply an external resource URL, e.g., http://evil.com/shell.txt or ftp://attacker/payload, in a parameter that is passed to an include function such as PHP's include() or require(). The log entry shows no URL scheme or external host; the payload is SQL syntax. RFI seeks to execute a remotely hosted script on the web server, whereas UNION SELECT merely extends an SQL result set to extract database content. The absence of any URI-based payload rules out RFI.
- A
Cross-site scripting (XSS)
Why wrong: The log entry contains SQL UNION syntax, whereas XSS payloads rely on script tags, event handlers like onerror, or javascript: URIs that execute in the victim's browser. XSS attacks target client-side interpretation of dynamic HTML, not the server-side database query. A UNION SELECT clause is a structured query language operation that fuses result sets from the database, which has no effect on raw HTML rendering. Therefore, the observed payload does not match the injection pattern expected for cross-site scripting.
- B
Path traversal
Why wrong: Path traversal typically constructs sequences such as ../../etc/passwd or encoded variants like %2e%2e%2f to escape the webroot and read arbitrary files. The apache log entry cited here does not contain any dot-dot-slash or similar traversal pattern; it contains the SQL keyword UNION SELECT. Path traversal manipulates file path strings used by file system functions, while UNION SELECT manipulates a database query. Hence the attack is not a path traversal.
- C
Remote file inclusion
Why wrong: Remote File Inclusion requires the attacker to supply an external resource URL, e.g., http://evil.com/shell.txt or ftp://attacker/payload, in a parameter that is passed to an include function such as PHP's include() or require(). The log entry shows no URL scheme or external host; the payload is SQL syntax. RFI seeks to execute a remotely hosted script on the web server, whereas UNION SELECT merely extends an SQL result set to extract database content. The absence of any URI-based payload rules out RFI.
- D
SQL injection
The presence of UNION SELECT in the request parameter is a hallmark of in-band SQL injection. By injecting a quote to close the original SQL string and then using UNION, the attacker can append arbitrary columns to the result set and exfiltrate data from other tables. The server-side SQL query executes the combined statement, and the output is reflected in the HTTP response, allowing non-blind data extraction. This is why the log entry is correctly classified as SQL injection.