Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New Package Request: fail2ban for SSH protection against malicious servers on the internet #1334

Open
4 tasks
bignay2000 opened this issue Jan 28, 2024 · 5 comments

Comments

@bignay2000
Copy link

bignay2000 commented Jan 28, 2024

Package name and purpose
Fail2Ban actively looks for authentication errors across various logs and add ip addresses to deny list for IPTables firewall. By having the firewall deny the IP, this prevents any further processing from the malicious server.

Impact of adding this package to the Flatcar OS image

The package improves on the following core values:

  • Secure by default
    Currently their is no real alternative to prevent DDOS attacks against SSH or other ports for public facing smaller servers (1 vCPU, 512 MB RAM Digital Ocean droplet).
  • Always up to date
  • Improve container experience
    Ability to firewall incoming traffic at the host. Decreases the possibility of memory and cpu usage caused by a malicious ddos attack.
  • Operate at scale / automation / telemetry

The package will increase the image size by: [estimated] MBytes.

How might this package increase the attack surface:
Built from Python

Benefits of adding this package
Gain the ability to protect a publicly facing Flatcar server from bot attacks.

Additional information
IPTables by themselves is not sufficient to protect against modern bots. Too hard to figure out rules that would block these attacks while ensuring real users can still connect to the server - whether the rate limit causes them to be blocked OR if the DDOS is triggering a lot of CPU, Memory, Disk from SSH processing an invalid user.

jan 28 03:18:49 server.example.net sshd[3376]: Invalid user toma from 34.100.230.128 port 45440

Grabbing a random hour from yesterday shows 63 Invalid user attempts in an hour.

journalctl -x --since "10 hour ago" | grep "Invalid user" | wc -l

So these are happening slowly, so my currrent IPTables is not catching them. So I think Fail2Ban is really the only option...

@bignay2000 bignay2000 changed the title New Package Request: fail2ban New Package Request: fail2ban for SSH protection against malicious servers on the internet Jan 28, 2024
@bignay2000
Copy link
Author

https://hub.docker.com/r/linuxserver/fail2ban might be an option to run in a container

@krishjainx
Copy link

Hi @bignay2000 . https://hub.docker.com/r/linuxserver/fail2ban seems like a good option to run fail2ban in a Linux container, since Flatcar is an immutable Linux distribution for running containers. There has been a lot of progress on the system extension front. Perhaps you could try bundling fail2ban into a systemd-sysext image and then use fail2ban that way.

@t-lo
Copy link
Member

t-lo commented Jan 29, 2024

Hello @bignay2000, thanks for reaching out! As Krish mentioned, we're trying to keep Flatcar lean. I know of a few users who managed to get an alpine docker container of fail2ban working on Flatcar. Needs host networking (obviously) as well as bind-mounts of /var/log and probably other directories into the container for logfile parsing.

This might be a more straightforward (and faster) solution than trying to add fail2ban to the base OS.

@t-lo
Copy link
Member

t-lo commented Jan 29, 2024

Oh, and just as with #1333 if you manage to find a good way to run fail2ban in a container, feel free to add a how-to to our documentation: https://github.com/flatcar/flatcar-website

@pothos
Copy link
Member

pothos commented Jan 31, 2024

Note that Flatcar already sets up pam_faillock

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Development

No branches or pull requests

5 participants