Unpopular take: fail2ban is 90% security theater on key-only boxes

bananapeel42

New Member
Messages
53
Reaction score
0
Location
Manchester, UK

Ran a little experiment last month. Spun up a throwaway VPS on a cheap Dutch host, key-only SSH, port 22, no fail2ban, no Cloudflare, nothing fancy. Just sshd with root login disabled. Let auth.log pile up for 30 days.

Roughly 40k failed attempts. Zero successful logins. Not one. The bots aren't targeting your box, they're spraying a whole /8 and hoping somebody left root/root sitting there from a 2019 tutorial.

Meanwhile every hardening guide on the internet tells people to install fail2ban, move SSH to 2222, disable root, blah blah. The port move I'll defend, it's just noise reduction for your logs. But fail2ban on a key-only box is basically a log cleaner with a ban hammer attached. It makes you feel productive more than it makes you safer.

Where it actually earns its keep imo is anything with web logins. WordPress, phpMyAdmin, that kind of thing. Or a mail relay where you can't force keys on every client. Completely different animal there.

So what are you all actually running these days? I've got sshguard on the mail box and plain nftables sets for everything else. Fail2ban always felt like regex duct tape to me and I doubt I'm the only one who's quietly stopped installing it.

jt_loves_tacos

New Member
Messages
75
Reaction score
0
Location
Phoenix, AZ

Ran basically the same thing a couple years back, think I got 30k attempts and the top five usernames were root, admin, ubuntu, test, and oracle. Nobody tried anything clever. It's just a firehose pointed at the whole internet.

But I'll push back on the port move being purely cosmetic. It's not just log noise. It kills a whole class of dumb scans that only ever try 22, and those scans are usually the ones that come back later with an exploit in hand. Cheap change, real if small return. I still do it.

Where I think you're dead right is fail2ban being regex duct tape. Spent a weekend once untangling a jail that was banning my own monitoring box because of a bad failregex. Wrote an nftables set that same afternoon and never looked back. sshguard on the mail relay is a good call though, that's the one place I still want something doing automatic bans on auth failures.

Genuinely though the SSH stuff is a sideshow. The boxes that actually get owned are the ones with a Redis instance listening on 0.0.0.0 or the docker socket mounted into some random container. Found a miner on a client's box last year that way, Redis hadn't even been password protected. 40k ssh attempts and not one hit is the boring outcome. The interesting ones never touch port 22.

LisaW_

New Member
Messages
53
Reaction score
0
Location
Edinburgh, UK

Ok this thread is making me feel dumb in a good way. I set up fail2ban like three weeks ago because literally every guide said to, and now I'm reading it's basically doing nothing on a key-only box lol. Did I just waste an afternoon? Genuinely asking.

The Redis thing scares me though. I've got a docker compose stack on a Hetzner box and I honestly have no idea if anything is listening on 0.0.0.0. How do you even check that properly, is it just ss -tlnp or is there more to it?

And jt, when you say the docker socket mounted into a container, is that the /var/run/docker.sock volume line? Because I've seen that in compose files and just copied it without thinking about it.

ahmed_khan92

New Member
Messages
63
Reaction score
0
Location
Toronto, ON

ss -tlnp is where you start but it lies to you in a very specific way. Anything running in docker with published ports shows up as docker-proxy listening, not the actual app. So you see a process you don't recognize, shrug, and move on. docker ps --format '{{.Names}} {{.Ports}}' is the one that actually shows you the 0.0.0.0:6379->6379/tcp mappings. That's the version of the check that would've caught the redis thing jt found.

Ground truth is still nmap from a different machine. nmap -p- your.ip from a cheap vps somewhere and just look at what answers. Slow but it's the only check that doesn't depend on the box telling the truth about itself. Also don't forget UDP, ss -ulnp, people tunnel vision on tcp and then some metrics agent is wide open on udp.

And yes, that's the exact docker.sock line. /var/run/docker.sock:/var/run/docker.sock in a compose file means the container can talk to the docker daemon, and talking to the daemon means you can ask it to start a new container with the host root mounted. So a compromised container that has that mount is a compromised host, full stop. Watchtower and portainer are the usual culprits because they need it to work. I mount it read-only now when I absolutely have to, which is a speedbump not a fix, but it at least blocks the laziest version of that attack.

Also since you're on Hetzner, go turn on their cloud firewall. It's free, it's in the console, and default-deny with just 22 and 443 open from anywhere kills about 90% of this nonsense before sshd even sees a packet. Easiest win on your list.

greg_ohio

New Member
Messages
71
Reaction score
0
Location
Columbus, OH

bhai log ye thread padh ke maine turant apna VPS khola lol. I've been running ss -tlnp for months and feeling smart about it, had no idea docker-proxy was hiding the real thing from me. That docker ps --format tip from ahmed is going straight into my notes, thank you seriously.

My setup is way simpler than you guys though. Just a small box running a Telegram bot for my slots group, nothing fancy, no redis, no portainer. So is it even worth doing the nmap from another VPS for a single box or am I overthinking it? Also I never once thought about UDP, that ss -ulnp thing just never crossed my mind.

And Lisa you're not alone. I installed fail2ban like two months back because some YouTube video told me to and I honestly have no idea what it's even banning. At least now I know it's mostly just sitting there looking busy.

ahmed_khan92

New Member
Messages
63
Reaction score
0
Location
Toronto, ON

Greg, for one box with a bot on it, run the nmap once and then forget about it. Twenty minutes, tells you what the box actually looks like from the outside, and you never think about it again unless you add a service. Not a ritual, just a one time sanity check. For a slots bot box you'll probably see 22 and whatever your bot listens on, and that's it.

But your real exposure isn't ports, it's the token. If that thing is sitting in a world readable .env, or worse hardcoded in the script and the script is in a git repo you forgot was public, someone finds it and now they're reading your group's messages or spamming it as you. Watched a guy running a trading alerts bot get cleaned out that exact way. Rotate the token if that code has ever touched a repo, seriously, that matters way more than whether some random port is open. You don't even run redis so the scary stuff in this thread doesn't apply to you.

UDP is mostly paranoia on a VPS since most providers filter it upstream anyway, but it's a ten second command so just run it and move on.

emilyb85

New Member
Messages
67
Reaction score
0
Location
Amsterdam, NL

Lisa, you didn't waste an afternoon, you just spent it on the wrong thing. fail2ban on key-only sshd is basically a very elaborate log formatter, but if you also pointed it at anything with a web login while you were in there, that part's doing real work. Check your jails before you write the whole afternoon off.

The bit I'd push back on is ahmed's "run nmap once and forget about it." Sort of true for greg's single bot box, less true for anyone running compose. Ports drift. You add a service six months from now, or fumble a publish flag and suddenly 5432 is answering to the world, and your one-and-done scan from last spring is telling you a comfortable lie. I re-run mine whenever I touch a compose file, takes two minutes and I've caught my own mistakes that way twice. It's not a ritual, but treating it like a one-time vaccination is how people end up in these threads six months later going "huh, when did that open."

Greg's token thing is honestly the scarier one and I'm glad ahmed brought it up. Nobody gets popped through an open port they know about, they get popped through a secret that leaked into a repo. Rotate it, then check whether your bot logs the token anywhere it shouldn't.

There's a whole subforum for this stuff if you want to stop learning it the hard way:
https://websiteforums.info/forums/website-security.19/

zer0cool99

New Member
Messages
67
Reaction score
0
Location
Seattle, WA

emily's right that the one-and-done scan is a comfortable lie, and I'd extend it past compose files. Your compose file isn't the only thing that can open a port. Had a node_exporter show up on 9100 one time because some apt package dragged it in as a dependency and helpfully started it for me. Nothing in the compose file, nothing in docker ps, just a fresh listener on a box I thought I knew. Took me a week to notice because I wasn't scanning.

ahmed's docker ps --format trick is the good one though. That belongs in every guide instead of the fail2ban sermon. I did the exact dumb thing he described, saw docker-proxy, assumed it was internal plumbing, moved on with my life.

The bit nobody's raised yet is egress. Whole thread is staring inbound. I flipped my nftables to drop outbound by default a while back after a box of mine got popped through some creaky PHP thing and spent the weekend quietly connecting out to a list of IPs I didn't recognise. Inbound was spotless the entire time. Clean inbound just means nobody's gotten in yet, it tells you nothing about what's leaving. Also got my VPS provider mad at me for the outbound traffic, which is its own motivation.

That said, dropping outbound broke my own apt updates for a day until I whitelisted it, so don't just paste that rule in blind. What's everyone actually using to watch what leaves the box? I'm tailing conntrack and grepping, which feels pretty caveman.

You must log in or register to reply here.