nginx / Apache Data Exfiltration

Detecting SQL Injection and Data Exfiltration in nginx Logs

Why this matters

SQL injection is decades old, but it’s still one of the most common ways an attacker turns a public-facing form or API parameter into a path to your database. The dangerous part isn’t the initial probe — it’s almost always followed within minutes by a burst of large, successful (200) responses as the attacker confirms the injection works and starts pulling data. nginx access logs capture every step of that sequence in the request field, even though nginx itself has no idea anything malicious happened.

Indicators to look for in nginx logs

  • Classic SQLi syntax in the query string or path: UNION SELECT, ' OR '1'='1, SLEEP(, encoded variants (%27, %20OR%20)
  • A spike in response size on endpoints that normally return small payloads
  • Sequential probing across multiple parameters on the same endpoint, then a narrowing-in on the one that returns a different response time or size
  • Successful (200) responses immediately following a string of 400/500 errors on the same path from the same IP
  • Requests to endpoints with database-adjacent naming (/export, /report, /api/v1/users?id=)

How LogTriage detects this

The path sensitivity classifier scores endpoints by how sensitive their function is, and combines that with status code and response patterns from the nginx parser. Because this attack chain often touches multiple distinct risk signals at once — a sensitive path, an anomalous user-agent, and (when the attacker pivots to downloading the result) a flagged destination — LogTriage’s compound-signal rule boosts the score by 1.25× once three or more independent high-severity indicators show up on the same event, on top of whatever the individual signals already contributed.

Detection / evidence checklist

  • Identify all endpoints that received SQLi-pattern query strings or path segments
  • Pull the full request/response sequence for the source IP across the incident window, not just the matching line
  • Check for unusually large response bodies immediately after the injection succeeded
  • Determine whether the targeted table/endpoint contains regulated data (PII, payment data, health data) — this changes your compliance notification obligations
  • Patch the underlying query — parameterization, not a WAF rule, is the actual fix

Frequently Asked Questions

Does detecting SQL injection in nginx logs require a WAF?
No. nginx access logs record the raw request path and query string, which is enough to flag SQLi syntax patterns like UNION SELECT and URL-encoded equivalents. A WAF can block SQLi; LogTriage detects that an attempt was made and whether it appears to have succeeded based on response patterns.
How does LogTriage distinguish a successful SQL injection from a failed probe?
By combining the request pattern with the response. A successful injection typically produces a 200 response with an abnormally large response body on an endpoint that normally returns a small payload. The sequence of probing errors followed by a successful large response is what the detection logic targets.
Does path sensitivity classification need to be customized for my application?
No customization is required for common endpoint patterns (/admin, /api/v1/users, /export, etc.) which are covered by the built-in classifier. LogTriage's path signatures work out of the box for standard REST API patterns.
If an SQLi attempt succeeded, does LogTriage tell me what data was exfiltrated?
Not directly — nginx logs don't include response bodies, only response size and status code. But LogTriage will identify which endpoints responded with abnormally large responses, which timestamps to focus on, and which source IP to investigate further.

Related Resources

See this detection run on a real report

Try the live demo with a pre-loaded malicious log set — no signup required — or upload your own log file and get a full AI-reviewed threat report in minutes.