From SSH Brute Force to SQL Injection: How SafeLine and Fail2ban Split the Work

●6 ●93
calendar_today • schedule3 min read

From SSH Brute Force to SQL Injection: How SafeLine and Fail2ban Split the Work

Most server compromises start with one of two things: someone guessing a password, or someone slipping a malicious payload into a web request. Those two attacks live on completely different layers — which is exactly why Fail2ban and SafeLine aren't competitors. Walk through both attack paths and it becomes obvious where each tool belongs.

Attack path 1: SSH brute force

What happens: a bot hammers your SSH port with thousands of password attempts.

Who stops it: Fail2ban reads your authentication logs, counts the failures, and bans the offending IP by pushing a rule into your firewall (iptables, nftables, or firewalld).

Why SafeLine isn't in the loop: SafeLine sits in front of your web app, inspecting HTTP traffic. SSH isn't HTTP, so it never sees the attempt. That's not a limitation — it's scope. Fail2ban owns the host; SafeLine owns the app.

Attack path 2: SQL injection in a login form

What happens: a crafted POST hits /login carrying a malicious payload designed to manipulate your database query.

Who stops it: SafeLine reads the request, and its semantic detection engine recognizes the injection attempt for what it is — regardless of the IP's reputation — and drops the request before it reaches your code.

Why Fail2ban struggles here: it sees an IP making a POST that returned a 200, which looks perfectly normal in a log. It has no visibility into the payload, so it can't tell a legitimate login from a malicious one.

The split, stated plainly

Fail2ban SafeLine
Sees IPs and log patterns The actual HTTP request
Stops Brute force, scanners, repeat offenders Injection, XSS, malicious bots
Layer Host / network (L3–L4) Application (L7)
Acts by Banning the IP at the firewall Dropping the bad request

Same server, two doors. Fail2ban locks the side door (SSH and service brute force); SafeLine locks the front door (your web app).

A sane setup order

  1. Expose only what you must. Close unused ports; that alone shrinks your attack surface.
  2. Fail2ban on the host. Protect SSH and any other services with login attempts. Tune the filters to your logs.
  3. SafeLine in front of the web app. Install it as a reverse proxy and point your app's traffic through it:
bash -c "$(curl -fsSLk https://waf.chaitin.com/release/latest/manager.sh)" -- --en

Your app keeps running exactly as before — it's just now shielded by a filter that understands what a request is trying to do.

FAQ

Can one tool replace the other?

No. Fail2ban can't inspect request payloads; SafeLine doesn't ban IPs at the host level. They cover different layers.

Does SafeLine protect SSH?

No — and it's not meant to. SSH is handled by host-level tools like Fail2ban. SafeLine focuses on your web traffic.

Is Fail2ban open source?

Yes, Fail2ban is open-source and widely used for host intrusion prevention. SafeLine is a self-hosted WAF with a free Community Edition (up to 10 apps at 800 QPS).

If I only pick one, which?

If your risk is a public web app, start with SafeLine — that's where application attacks land. If your risk is SSH or service brute force, start with Fail2ban. Most servers end up with both.


Different attacks, different layers, different tools — used together, they close both doors.

🔥 Join developers growing publicly
Share your knowledge, build in public, and grow your developer presence with a global community.

More Posts

Attention-Free Score: How Domain Reports Show Which Pages Need Work

ApogeeWatcherverified - Sep 1

How I Built a React Portfolio in 7 Days That Landed ₹1.2L in Freelance Work

Dharanidharan - Feb 9

I’m a Senior Dev and I’ve Forgotten How to Think Without a Prompt

Karol Modelski - Mar 19

SafeLine WAF vs Fail2ban: App-Layer vs Host-Level Defense

Lia - Oct 9

AAIF Hits 10 Projects. Its CTO on What to Adopt Now and the Security Gaps Left Open

Tom Smithverified - Oct 23
chevron_left
1.8k Points • 99 Badges
74Posts
0Comments
Web Dev

Related Jobs

View all jobs →

Commenters (This Week)

1 comment
1 comment
1 comment

Contribute meaningful comments to climb the leaderboard and earn badges!