Skip to content
Misconfiguration Write-up Intermediate

Privilege Escalation With fail2ban Nopasswd

A user could restart the fail2ban service as root without a password, and the fail2ban action configuration directory was writable by that user. By replacing the iptables-multiport action file and triggering a ban, the user could run arbitrary commands as root.

JAY BHATT Follow

Published on systemweakness.com

Hello Everyone Today I am going to show you how you can escalate your privileges if you discover misconfigured Fail2ban on the server. So let’s get started!!

JAY BHATT, on systemweakness.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely a sudoers rule allowed passwordless restart of fail2ban while the fail2ban action configuration directory was writable by the same low-privileged user, letting them alter a root-executed action script.

Impact

An attacker with a low-privileged account could gain a root shell on the server.

What the attacker needed

Low-privileged shell on the server; passwordless sudo for fail2ban restart; writable fail2ban action directory

The fix

The sudoers rule should not allow passwordless restart of fail2ban, and the fail2ban action configuration directory should not be writable by non-root users.

How it was found

  1. Check that the fail2ban restart command can be run as root without a password.
  2. Find writable directories under /etc and note that /etc/fail2ban/action.d is writable.
  3. Rename the iptables-multiport.conf action file and copy it back so the user owns it.
  4. Change the file permissions to make it readable and writable.
  5. Put a reverse shell command into the actionban line of the action file.
  6. Trigger a ban with failed SSH logins so the action runs and connects back as root.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

This is about a normal user on a Linux server who is allowed to run one specific command as the all-powerful root user without typing a password. Because a configuration folder used by the fail2ban security tool could be changed by that user, they could make the tool run their own command the next time it blocked someone, giving them full control of the server.

What is Misconfiguration?

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.

More by JAY BHATT

View all

1 more disclosed report, best first.

Similar reports

View all

Same bug class and techniques, clearest first.

Security misconfiguration

The lesson behind this report.

Settings left unsafe: exposed panels, open storage buckets, debug modes, default credentials.