Offenders

Installation and permissions

Requirements and permissions

The supported baseline is Ubuntu 24.04 LTS / Python 3.12+, with separately installed Fail2Ban 1.0.2. Stock Enforcement action compatibility is qualified for 1.0.2, 1.1.0 and 1.1.1, limited to recognized runtime shapes and failing closed for unsupported forms. pipx installs Python dependencies automatically.

The dashboard needs Fail2Ban file logs and permission to read them. Defaults are /var/log/fail2ban.log, its .1 rotation, and .N.gz rotations. Journal-only Fail2Ban logging does not supply the ordinary report history.

Live jail/status/settings calls use sudo -n fail2ban-client, with an eight-second limit per call. Offenders never waits for a sudo password. Denied commands are failures, not authoritative zero counts. Run the dashboard as your normal user with the required log access and narrowly scoped sudo permission.

An administrator can use visudo to permit only the read commands below. Replace OPERATOR with the login name and verify the installed executable path with command -v fail2ban-client before adapting this example. Replace JAIL with an actual jail name and repeat jail-specific entries for each monitored jail:

OPERATOR ALL=(root) NOPASSWD: /usr/bin/fail2ban-client status, /usr/bin/fail2ban-client status JAIL, /usr/bin/fail2ban-client get JAIL bantime, /usr/bin/fail2ban-client get JAIL findtime, /usr/bin/fail2ban-client get JAIL maxretry, /usr/bin/fail2ban-client get JAIL logpath, /usr/bin/fail2ban-client get JAIL journalmatch

The status and first three get forms serve the dashboard; logpath and journalmatch serve optional Coverage. Keep jail arguments explicit rather than granting wildcard command access. Do not grant unrestricted passwordless fail2ban-client access: it also exposes mutation commands.

Coverage can degrade independently of the ordinary dashboard:

Evidence/action Command or access If unavailable
Listener discovery Non-sudo ss -H -lntu Exposure evidence unavailable
Optional process owners Bounded sudo -n ss -H -lntup Owner evidence partial/unavailable
Systemd/source discovery Non-sudo systemctl / journalctl Service/journal evidence partial/unavailable
Static configuration Read /etc/fail2ban as the current user Coverage cannot imply complete configuration access
Source log evidence Read discovered logs as the current user Source evidence partial/unavailable
Explicit filter validation Installed fail2ban-regex, without sudo Validation unavailable

Owner enrichment is optional; it does not require broad sudo permission. If an administrator chooses to allow it, limit permission to the exact ss invocation above and verify that executable’s path separately.

Registration (RDAP) and RDNS (PTR) use required Python dependencies supplied by pipx: classic ipwhois and dnspython. No separate lookup executables are needed. RDNS uses the host DNS resolver configuration; Registration needs outbound RDAP HTTP access. Network failures appear per request and do not disable the actions.

Optional Enforcement read permissions

Dashboard n Enforcement performs extra runtime-action and firewall reads only when explicitly opened or rechecked. Missing permission affects that screen; ordinary reports require no firewall permission. Direct rule/object observation is not packet or reachability proof.

An administrator can adapt the following read-only sudoers example on Ubuntu 24.04 (sudo >=1.9.10). Resolve each absolute executable path with command -v on the target system first, replace OPERATOR, and omit unused backend/save entries. These anchored argument regexes constrain jail/action identifiers to the product’s 128-character grammar and properties to its finite allowlist. The nft table grammar is independently bounded. Save commands use "" to require no arguments; omitting it would permit arbitrary arguments.

# Fresh status, finite runtime-action reads and the validated daemon namespace link.
Cmnd_Alias OFFENDERS_ENFORCEMENT = \
    /usr/bin/fail2ban-client status, \
    /usr/bin/fail2ban-client ^status [A-Za-z0-9_][A-Za-z0-9_.:@+-]{0,127}$, \
    /usr/bin/fail2ban-client ^get [A-Za-z0-9_][A-Za-z0-9_.:@+-]{0,127} actions$, \
    /usr/bin/fail2ban-client ^get [A-Za-z0-9_][A-Za-z0-9_.:@+-]{0,127} actionproperties [A-Za-z0-9_][A-Za-z0-9_.:@+-]{0,127}$, \
    /usr/bin/fail2ban-client ^get [A-Za-z0-9_][A-Za-z0-9_.:@+-]{0,127} action [A-Za-z0-9_][A-Za-z0-9_.:@+-]{0,127} (actionban|actionstart|name|nftables|table_family|table|chain|chain_type|chain_hook|addr_set(\?family=inet6)?|blocktype(\?family=inet6)?|iptables(\?family=inet6)?|lockingopt|add|destination|application|comment|kill-mode|kill)$, \
    /usr/bin/readlink ^/proc/[1-9][0-9]{0,9}/ns/net$, \
    /usr/sbin/nft ^--json --numeric list table (inet|ip|ip6) [A-Za-z0-9_][A-Za-z0-9_.:+-]{0,127}$, \
    /usr/sbin/iptables-save "", /usr/sbin/ip6tables-save "", \
    /usr/sbin/iptables-nft-save "", /usr/sbin/ip6tables-nft-save "", \
    /usr/sbin/iptables-legacy-save "", /usr/sbin/ip6tables-legacy-save "", \
    /usr/sbin/ufw status, /usr/sbin/ufw show added
OPERATOR ALL=(root) NOPASSWD: OFFENDERS_ENFORCEMENT

Validate the adapted file with visudo -c -f /path/to/file before installing it through visudo, then exercise the actual reads as the non-root operator. The example’s argument matching was syntax-checked and exercised with a non-root user in disposable Ubuntu 24.04; representative systemd/Fail2Ban host acceptance remains a separate release gate. Do not replace these rules with unrestricted fail2ban-client *, nft *, iptables *, ufw *, shell or wrapper access.

Only supported runtime action descriptors authorize firewall reads. Native nft uses nft --json --numeric list table FAMILY TABLE; iptables uses the matching bare save binary; UFW uses only ufw status, ufw show added and bare iptables-save / ip6tables-save. There is no fallback or mutation command. The additional actionstart read is used only when advertised and runtime chain is exactly <known/chain>, to identify one stock-compatible iptables parent chain. Its text is never executed; known/chain is never queried. Namespace proof reads MainPID through non-sudo systemctl show --property=MainPID --value fail2ban.service, then reads /proc/self/ns/net as the current user and only the validated numeric daemon link through sudo -n /usr/bin/readlink /proc/<MainPID>/ns/net. It immediately re-reads MainPID non-sudo and requires the same nonzero PID before comparing identities. A changed/unreadable PID, unreadable identity or namespace mismatch prevents all firewall reads. Keep the readlink allowance anchored to this one numeric path: no options, arbitrary procfs reads, sudo systemctl or namespace switching.

Install and upgrade

Install from PyPI using pipx:

sudo apt-get update
sudo apt-get install -y pipx
pipx ensurepath

Open a new login shell after ensurepath, complete the secure bootstrap below, then install and run:

pipx install offenders
command -v offenders
offenders

Upgrade or remove the package with:

pipx upgrade offenders
pipx uninstall offenders

Secure pipx bootstrap

Before the first install or upgrade, update Ubuntu’s ca-certificates and bootstrap pip 26.2.2 in pipx’s shared environment. Updating Offenders alone does not repair pip. The PSF security advisory provides this exact wheel URL and SHA-256. Its hash protects the initial download even when the old pip’s embedded CA bundle is stale; TLS verification stays on.

sudo apt-get update
sudo apt-get install --only-upgrade ca-certificates
pipx_shared=$(pipx environment --value PIPX_SHARED_LIBS)
# Creating a missing shared venv uses only Python's bundled ensurepip.
if [ ! -x "$pipx_shared/bin/python" ]; then
    python3 -m venv "$pipx_shared"
fi
"$pipx_shared/bin/python" -I -m pip --isolated --disable-pip-version-check install --no-index --no-deps --no-cache-dir --upgrade 'https://files.pythonhosted.org/packages/3f/06/3e4420302363fbb71be3c7f35ce042f54bfca330e3e66b3a2e3c4cca579f/pip-26.2.2-py3-none-any.whl#sha256=fd7f4dfa8190e014013b9f08f3e973f4e4c26ffd179a204895533a7254813a70'
"$pipx_shared/bin/python" -m pip --version

Run this again if pipx recreates its shared environment. The shared pip must be at least 26.2.2 before ordinary dependency downloads; setting PIP_CERT alone is insufficient because pip also loads its embedded certifi roots. Keep OS trust current for runtime GeoIP HTTPS downloads and Registration (RDAP), which use Python’s default OS CA store, including configured SSL_CERT_FILE/SSL_CERT_DIR. Offenders does not bundle pip, certifi, a Python runtime, or a CA store.

pipx isolates Python dependencies; it does not install Fail2Ban or host tools or grant log/sudo permissions. Installation downloads no GeoIP data.

Uninstalling Offenders does not remove its app-managed data under $XDG_DATA_HOME/offenders (or ~/.local/share/offenders when XDG_DATA_HOME is unset). Delete that directory separately if you also want to remove retained GeoIP databases and update state:

# Optional: remove Offenders app-managed XDG data and state
rm -rf "${XDG_DATA_HOME:-$HOME/.local/share}/offenders"

Report exports are separate user-created files (default ~/offenders-exports/, or a custom --output-dir) and are not removed by either pipx uninstall or the XDG cleanup above.

Source and advanced installs

From a checkout, with python3-venv available:

python3 -m venv .venv
source .venv/bin/activate
python -I scripts/bootstrap_pip.py
python -m pip install -e .
offenders

python -m pip install . provides a non-editable source install; pipx install . provides local application isolation. With the source environment active, python offenders.py or ./offenders.py also launches the dashboard. Keep the packaged modules together: copying only the old single script is not a current installation method. See development for contributor setup and artifact checks.

Back to top