{"success": false}), invisible to anything reading standard access logs.
This is not a theoretical problem. It means your access logs cannot distinguish a credential stuffing attack that failed entirely from one that compromised fifty accounts.
Why Applications Return 200 for Everything
200 in the log, your monitoring dashboards show a 0% error rate even during an active attack.
What Credential Stuffing Looks Like When Everything Is 200
200 OK, that separation vanishes. You see a bunch of POST requests to /api/login or /wp-login.php, all returning 200. No anomaly. No alert. The attacker who guessed three valid passwords looks identical to three legitimate users logging in.
For more on detecting the distributed pattern itself, see Credential Stuffing Rotates IP Every Request — Schedule Weekly Combo List Checks in Your Logs.
The body_bytes_sent Workaround
$body_bytes_sent is part of the default combined log format. In Apache, %B (or %b) records the response size in bytes. Both are already in your logs if you have not changed the default format.
You can scan for login requests where the response size deviates from the typical failure size. Here is a rough approach using awk against an Nginx access log in combined format:
BASH
# Extract POST requests to /login path, show IP, status, and body bytes
# Adjust field positions (1,7, 9,10) based on your actual log format
awk '6 ~ /POST/ &&7 ~ /\\/login/ {print 1,9, $10}' /var/log/nginx/access.log | sort -k3 -nTEXT
203.0.113.42 200 147
198.51.100.8 200 147
192.0.2.17 200 147
203.0.113.99 200 891
198.51.100.3 200 147203.0.113.99) and the associated account deserve immediate investigation.
This is not foolproof. Response sizes can vary for legitimate reasons (different error messages, localization, CSRF tokens of varying length). But as a triage signal during an active attack, it narrows the search dramatically compared to staring at a wall of 200 OK.
Fix the Root Cause: Return Proper Status Codes
- 401 Unauthorized — invalid credentials. RFC 9110 defines this as "the request lacks valid authentication credentials." This is the correct status for a wrong username or password.
- 429 Too Many Requests — the user or IP has exceeded your rate limit for login attempts.
- 200 OK or 302 Found — authentication succeeded.
res.json({error: 'Invalid credentials'}) to res.status(401).json({error: 'Invalid credentials'}). In PHP, http_response_code(401) before your JSON output. In Django, returning HttpResponse(status=401) or using the REST framework's authentication classes which handle this by default.
One concern developers raise: "Won't returning 401 leak information about whether a username exists?" No — you return 401 for both invalid usernames and wrong passwords, with the same generic message. The status code tells the client (and your logs) that authentication failed. It does not tell anyone why.
Building a Log-Based Detection Rule
- High volume of 401 responses on the login path within a short window.
- Requests spread across many distinct source IPs (not a single brute-force source).
- A small number of 200/302 responses on the same path in the same window — these are the potential account takeovers.
BASH
# Count status codes for POST /login grouped by hour
# Assumes standard combined log format with date in field $4
awk '6 ~ /POST/ &&7 ~ /\\/login/ {split(4,a,":"); print a[2]":00",9}' /var/log/nginx/access.log | sort | uniq -c | sort -rnTEXT
847 14:00 401
12 14:00 200
3 14:00 429
45 13:00 401
8 13:00 200What About Existing Logs Where Everything Is Already 200
auth_result=success user=jane.doe or auth_result=failure user=jane.doe gives you what the access log cannot.
Practical Takeaway
body_bytes_sent differences on your login path to separate successes from failures. And if you are evaluating a new application or framework, check what status code the login endpoint returns on failure before it reaches production. A five-second curl test now saves hours of forensic guesswork later.