When fail2ban is not enough: our abuse report
Every night a run reads the nginx logs, counts conspicuous requests per address and writes to the provider. What that looks like, how a program and how an agent read a log — and where the procedure ends.
Anyone who puts a server on the net gets visitors. One machine tries login details,
another searches for /.env files, a third asks for everything a content management
system ever had as a path. On your own server a firewall and a tool like
fail2ban help against that.
But the block only works for me. The machine the requests come from sits in a network a provider is responsible for — and that provider hears nothing as long as nobody reports it. That is why we have an abuse report: a run reads the web server’s logs every evening and writes to the provider of the source.
The chain in five steps
| Step | What happens |
|---|---|
| 1 | The run fetches the web server’s two access logs over SSH |
| 2 | It counts the events per source address and sorts them by pattern |
| 3 | For each address it fetches the registered network details — whois, otherwise RDAP |
| 4 | It builds one mail per abuse address with the dossiers of exactly those sources |
| 5 | It sends them and writes each one into a dispatch log |
The run starts at 23:55. That is no accident: on this server logrotate rotates
the nginx logs at midnight. At 23:55 the whole calendar day is still in the current
file; at four in the morning only a quarter of it would be there.
Two minutes later a watchdog checks whether the run wrote a status file. If it is missing or contains an error, only I get a mail — no provider does.
A word about the recipient address: whois and RDAP return the registration and network data stored for an address — an organisation, a network, an abuse contact. It does not follow that this contact is the attacker, nor that the provider currently assigns the address to one of its customers. It is the place to report to; whether the assignment is right only the provider can say.
What a line in the log looks like
nginx writes in the so-called combined format. A line looks like this:
203.0.113.55 - - [30/Nov/2026:03:12:44 +0100] "GET /.env HTTP/1.1" 404 153 "-" "Mozilla/5.0"
From left to right: the address of the requester, a placeholder for the user name, date and time with time zone, the request in quotes, the status code, the size of the response, then referrer and browser identifier. Everything the report needs is in that one line — except the answer to the question who owns the address.
How the program reads
The first step is a pattern that splits the line into its fields: address, timestamp, method, path, status code. What comes after that no longer matters.
The second step is a list of patterns that sorts the path into a category:
| Pattern in the path | Classification |
|---|---|
/.env, /.git/, config.json |
search for credentials |
wp-login.php, xmlrpc.php |
WordPress probe |
phpmyadmin, adminer, info.php |
database or PHP administration |
cgi-bin, .htaccess, security.txt |
classic web vulnerability scan |
vendor/, actuator, _ignition |
search for a known framework fault |
.sql, .bak, .zip, .tar.gz |
search for backup files |
%7C, $(, /bin/sh |
attempt to inject a command |
The list is not final. It grows with what turns up in the logs; a pattern that never occurs does not belong in it.
The third step is counting. For each address an entry appears: how many events, over what period, with which status codes, with which browser identifier, and under which category. Only from ten events per day does a report come out of it.
Without that threshold every provider would get a mail because a single crawler failed to find a page once.
What is in a dossier
A dossier is a text file per address, in English, because the recipient should read it. It begins with a summary: number of events, period in local time and in UTC, services affected, distribution of status codes, the abuse contact from whois, the network the address belongs to — and whether fail2ban now blocks the address, with the time of the block. That detail comes from the server’s fail2ban log, not from the access log.
Then follow the patterns with their counts, the most frequently requested paths, the browser identifiers — and an excerpt from the log: the first five and the last five events, so the recipient does not just see our count but the lines themselves.
That makes the report checkable. A claim — “this address tried our login 92 times” — remains a claim. With timestamp, path, status code and identifier the recipient can verify it.
How an agent reads the same thing
Two very different readers now look at the same lines.
The program works with fixed patterns. It is fast, cheap and repeatable: the same lines produce the same report. But it only recognises what is on its list. An attacker who tries a path nobody thought of falls through.
A language model with tools — an agent — goes about it differently. It first reads a sample: the most frequent paths, the conspicuous status codes, a few lines in the original. Then it looks for patterns that seem unusual to it, has counts calculated instead of guessing them, and checks in a second pass whether the suspicion holds. If it has found something that is not yet on the list, the list can be extended.
The difference lies in the price. An agent costs money per pass and does not always deliver the same result. It can invent a plausible explanation that no line in the log covers — which is why every number in a report has to come from a count and not from a story.
For the abuse report itself the two therefore run separately: the agent proposes patterns and checks entries; the program counts and sends. How such an agent is built is described in When a language model attacks. Anyone wanting to rebuild this does not need both on the first day — a program with a list and a threshold already does most of it.
What is sent and what is not
| Rule | Value |
|---|---|
| Recipient | the abuse contact of the source from whois or RDAP |
| Copy | one address of mine, so I see what goes out |
| Attachment | only the dossiers that belong to this recipient |
| Source without contact | goes as a collected mail to me, not to the provider |
| Cooling-off | the same address gets mail again at the earliest after seven days |
| Threshold | ten events per day |
| Switch | without --senden it builds but does not send |
The cooling-off period is the reason a dispatch log is kept. Without it the same provider would get the same address week after week — and would eventually have our sender blocked, rightly so.
A short list exempts sources whose requests are explained: at the moment entries of the organisation “Google” that clearly belong to the provider’s own services and not to a customer. Such an entry stays visible in the internal report but is not reported.
What can go wrong
Two faults are in our own setup, and both went unnoticed until we looked.
The silent failure. In October a user lacked the group that may read the logs. The run failed twenty times in a row without anyone noticing — a report that runs daily also looks healthy when it does nothing. Since then there is the watchdog at 23:57.
The old dossiers. In November dossiers from earlier runs were reported as the current situation because they lay in the same directory. Since then every run writes into a directory of its own, and the clearing is gone.
While writing this article the watchdog fired for the first time: a test run on 30 November at 05:41 fetched 206 and 304 lines, found 39 blocked addresses in the fail2ban log, built 13 dossiers, let one source fall through the list and established that no address was above the threshold. Nothing was reported. But the watchdog reported that no status file was there — because the test run had written it somewhere else. That is exactly what it is for.
Where the procedure ends
An abuse report is a request, not an instruction. What the provider does with it is not our decision: many answer, some block at once, some never.
Our report contains our own claim “Blocked on our server” — useful for the recipient, but a statement about our machine, not about theirs. And the classification “search for credentials” is an inference from the path, not certainty. A crawler that fails to find a page looks almost the same in the log as one looking for a hole. That is the reason for the threshold and for the excerpt: whoever reads the lines can check our classification.
Anyone running a server themselves and wanting to rebuild this needs no big tool. A log in the combined format, a pattern that splits the fields, a list of paths, a counter per address, a threshold and a rule for when the same address gets mail again. The rest is diligence.
Sources
All addresses retrieved on 30 November 2026, each answered HTTP 200.
- nginx, log format
log_formatand the fields of the combined format: https://nginx.org/en/docs/http/ngx_http_log_module.html - RFC 3912, WHOIS (querying the registered data): https://www.rfc-editor.org/rfc/rfc3912
- RFC 9083, RDAP in JSON format (fallback when no whois is available): https://www.rfc-editor.org/rfc/rfc9083
- logrotate, manual page (daily rotation at midnight): https://manpages.ubuntu.com/manpages/resolute/man8/logrotate.8.html
- fail2ban, manual page
jail.conf(blocks quoted in the dossier): https://manpages.ubuntu.com/manpages/resolute/man5/jail.conf.5.html - RFC 5737, address range for examples (
203.0.113.0/24, used in the text): https://www.rfc-editor.org/rfc/rfc5737