Skip to content
Threat Feed
high advisory

Web Server Potential SQL Injection Attempt Detection

This brief details the detection of potential SQL injection (SQLi) attempts against web servers by identifying common SQLi patterns in URLs and query strings, used by threat actors for reconnaissance, data exfiltration, or command execution, aiming for sensitive information disclosure or system compromise.

This brief addresses the detection of web server potential SQL Injection (SQLi) attempts, as outlined by Elastic's detection rule. SQLi remains a critical threat, enabling attackers to manipulate backend databases, exfiltrate sensitive data, or even execute arbitrary commands. These attempts often originate from automated scanning tools or manual exploitation techniques, probing for vulnerabilities across various SQL dialects (e.g., MySQL, MSSQL, PostgreSQL, Oracle). The detection focuses on identifying characteristic patterns in HTTP request URLs and query strings, encompassing boolean-blind, time-based, error-based, and UNION-based injection methods. Defending against these attempts is crucial as successful SQLi can lead to severe compromises, including full system control and breach of confidential information, impacting any organization running public-facing web applications.

Attack Chain

  1. Reconnaissance & Vulnerability Scanning: Attacker employs automated tools like sqlmap or manual techniques to identify public-facing web applications, discover vulnerable parameters (GET/POST inputs, headers, cookies), and fingerprint the backend database type by sending various SQLi payloads and analyzing server responses (e.g., error messages, time delays).
  2. Initial Access via Injection: The attacker crafts and injects SQL payloads into identified vulnerable parameters of the web application, leveraging vulnerabilities like unsanitized user input to alter the application's intended database queries.
  3. Information Gathering & Credential Access: Upon successful injection (e.g., error-based, union-based), the attacker queries the database for sensitive information such as database schema, table names, column names, system settings (@@version), database users (user(), current_user()), or stored credentials.
  4. Data Exfiltration: The attacker systematically extracts sensitive data (e.g., customer records, intellectual property, internal configurations) from the database using methods like UNION SELECT statements, outfile/dumpfile functions, or by inferring data bit-by-bit in blind SQLi scenarios.
  5. Execution (if applicable): In cases of severe SQLi vulnerabilities (e.g., stacked queries in MSSQL, xp_cmdshell), the attacker executes arbitrary commands on the underlying operating system or database server, potentially installing backdoors or furthering compromise.
  6. Persistence: If OS command execution is achieved, the attacker might write web shells or backdoors to the web server's filesystem (select * into outfile) to establish persistent access and maintain control over the compromised server.
  7. Command and Control (C2): With persistence established, the attacker uses the compromised web server or database as a C2 channel, communicating over application layer protocols (HTTP/S) to issue further commands, transfer files, or pivot into the internal network.
  8. Impact & Lateral Movement: The attacker leverages the compromised web server or database to pivot into the internal network, perform additional reconnaissance, deploy advanced malware, or achieve other objectives, leading to broader system compromise or significant data breaches.

Impact

A successful SQL injection attack can have severe consequences, including full data exfiltration, system compromise, and unauthorized access to internal networks. Observed damage ranges from the theft of sensitive customer data and intellectual property to the complete takeover of web servers and backend databases, potentially leading to financial losses, reputational damage, and regulatory penalties. If attackers gain remote command execution capabilities, they can deploy ransomware, establish persistent access, or pivot to other systems, resulting in widespread infrastructure compromise. The Elastic rule targets generalized SQLi patterns, implying a broad scope of potential victims across various industries using web applications.

Recommendation

  • Deploy the Sigma rule "Detect Web Server Potential SQL Injection Attempts" from this brief to your SIEM/detection platform and tune it for your environment.
  • Review web server access logs (Nginx, Apache, IIS, Traefik, Zeek) for cs-uri-stem and cs-uri-query patterns matching the detection logic in the provided Sigma rule.
  • Enable comprehensive web server access logging on all public-facing web servers, ensuring cs-uri-stem and cs-uri-query are captured.
  • Implement a Web Application Firewall (WAF) to detect and block common SQL injection patterns at the network edge, reducing the attack surface.
  • Prioritize patching and security updates for all web server software and underlying database systems, particularly for known SQLi vulnerabilities.
  • Educate development teams on secure coding practices, emphasizing the use of parameterized queries and prepared statements to prevent SQL injection.

Detection coverage 1

Detect Web Server Potential SQL Injection Attempts

high

Detects various common SQL injection patterns in web server URI stems or query strings, indicative of reconnaissance or exploitation attempts.

sigma tactics: command_and_control, execution, initial_access, persistence, reconnaissance techniques: T1059, T1071, T1190, T1505, T1595, T1595.002, T1595.003 sources: webserver

Detection queries are available on the platform. Get full rules →