Here is an attack that needs no vulnerability, no credentials and no cleverness.
You keep 90 days of activity log, purged daily. That is a sensible setting and probably the default. An attacker points a botnet at wp-login.php for six hours.
Every attempt writes a row. When the purge runs, it removes the oldest entries. If the six hours produced more rows than your retention window normally holds, everything that was in there before is now outside it.
Your audit trail is gone. Nothing was deleted maliciously. Your own retention policy did it, exactly as configured.
The arithmetic
A quiet site writes maybe 3,000 activity rows a month — sign-ins, edits, plugin updates. Call it 9,000 in a 90-day window.
A modest credential-stuffing run does 20 attempts per second. That is not a large botnet.
20 × 60 × 60 × 6 = 432,000 rows in six hours
Forty-eight times your entire retention window, written overnight. Everything that mattered is now the oldest data in the table, and the next purge takes it.
You do not even need retention by count for this to work. Retention by *age* is enough, because the flood is what makes you notice, and by the time you look the interesting rows are 91 days old.
And the second-order effect arrives first: the table gets big enough that the log screen stops loading, so the tool you would use to investigate is the tool the attack disabled.
The obvious fix, and why it is wrong
*Stop logging failed logins.*
No. Failed logins are among the most valuable rows you have. A spray against admin, administrator, root looks like three unrelated failures until you can see them together. Discarding the category to protect the table throws away the signal to save the storage.
The other obvious fix — a bigger table, longer retention — buys you a factor of two against an attacker who can trivially buy a factor of ten.
What actually works: aggregate, don't discard
Cap the number of *individual* rows a single source can write in a window, and roll the rest into one.
Concretely: log up to 20 individual failures per IP per hour. Beyond that, write one aggregated row for the remainder of the hour and increment a counter inside it.
Six hours of attack from one address then costs you a bounded number of rows instead of 432,000. And you have lost nothing you needed:
- The first 20 attempts, individually, with usernames, timestamps and user agents
- One row per hour thereafter saying *and 71,980 more from this address*
That is strictly more useful than 432,000 identical rows, because nobody was ever going to read row 200,000. The shape of the attack survives; the volume does not.
The part that is genuinely hard
That aggregated row has a counter in it that goes up. An append-only log has no rows that go up.
If your log is hash-chained for tamper evidence — each entry hashed together with the one before it, so an edit breaks the chain visibly — then incrementing a counter inside a row *is* an edit. Every increment breaks the chain. You have built a flood defence that makes your integrity guarantee fail continuously.
The two properties are in direct tension, and it is worth knowing how any tool you rely on resolves it, because there are three ways and two are bad:
- Don't chain the log. No tension, no guarantee.
- Don't aggregate. No tension, and the flood works.
- Exclude the counter from what gets hashed. Everything else in the row — the event, the address, the time, the rest of the metadata — is covered. The one mutable field is named, excluded, and documented.
Three is the right answer and it is only defensible if you can say precisely which field is excluded and why. An integrity guarantee with an undocumented hole in it is worse than none, because you will trust it.
The duplicate-counting bug you will also have
While you are counting failures, one more thing that inflates the numbers — and this one is subtle enough that it shipped here before it was caught.
Every control that refuses a sign-in does so by returning an error from WordPress's authenticate chain. WordPress reacts to *any* such error by firing wp_login_failed. So a generic failed-login listener records a credential failure — for an attempt where the password was never checked at all.
One blocked attempt, two rows: the real reason it was stopped, and a password failure that never happened.
The effects are all in the wrong direction. Brute-force numbers read roughly double. Your aggregation budget is spent twice per attempt. And the "repeated failed logins" alert fires alongside the bot-defence alert for the same traffic, so the operator learns to trust neither.
The obvious fix — match on the error code — does not work either, and the reason is interesting. Good bot defence deliberately returns an error *byte-identical to a wrong password*, so an automated client learns nothing from the difference. That is correct behaviour, and it means the log genuinely cannot tell the two apart after the fact. The blocker has to declare it at the time: already logged, stand down.
What to check on your own site
SELECT COUNT(*) FROM wp_your_log_table
WHERE created_at > NOW() - INTERVAL 1 DAY;
Compare it to a normal day. If a bad day is more than about ten times a good day, your retention window is measured in incidents rather than in time.
Then ask your logging tool two questions:
- Does it cap per-source rows and aggregate the rest? If not, your log length is set by whoever wants to attack you.
- If it claims tamper evidence, which fields are hashed? If the answer is "all of them" and it also aggregates, one of those two claims is not true.
The one-line version
You do not need write access to a log to destroy it. You need only the ability to make it long enough that the owner's own policy deletes the interesting part — and an unauthenticated POST to wp-login.php is enough.
—
*ITX UserOps caps individual failed-login rows at 20 per IP per hour and aggregates the remainder into a single counted row, with that counter excluded from the hash chain by name. Blocked attempts declare themselves so they are never double-counted as credential failures. All of it is in the free plugin — the activity log and tamper evidence are documented in full.*
