Skip to main content

[DEPRECATED] Use bodyguard-of-bits instead: https://github.com/Masbateno/bodyguard-of-bits

Project description

Lire en franรงais ยท Technical documentation

[!WARNING] This repository is deprecated and will no longer receive updates.

Development continues under a new name: BOB โ€” Bodyguard Of Bits. The new repository is not yet active, but a first release is expected soon. Please watch the new repository for updates.

๐Ÿ”’ ufw-audit

Smart UFW security audit โ€” fast, readable, actionable.

Analyses your UFW configuration, exposed services and logs to detect real risks, with clear recommendations.


โšก TL;DR

sudo apt install pipx && pipx ensurepath
# open a new terminal, then:
pipx install ufw-audit
sudo ~/.local/bin/ufw-audit --install-completion
sudo ufw-audit

๐Ÿ›  Installation

Prerequisites

  • Linux: Debian, Ubuntu, Mint or derivative
  • UFW: sudo apt install ufw
  • pipx: sudo apt install pipx && pipx ensurepath

Open a new terminal after pipx ensurepath to activate the PATH.

Install

pipx install ufw-audit

Enable sudo + bash completion

pipx installs the binary in ~/.local/bin/, which is not in sudo's restricted PATH. --install-completion creates the symlink /usr/local/bin/ufw-audit and installs the bash completion script:

sudo ~/.local/bin/ufw-audit --install-completion
source /etc/bash_completion.d/ufw-audit

After this step, sudo ufw-audit works normally.

Update

pipx upgrade ufw-audit

Uninstall

pipx uninstall ufw-audit

๐Ÿš€ Why ufw-audit?

  • ๐Ÿ” Full audit โ€” firewall, services, ports, logs, DDNS, Docker, virtualisation
  • ๐ŸŽฏ Smart prioritisation โ€” score + classification (OK / Warning / Action required)
  • ๐Ÿง  Context-aware โ€” network exposure + service criticality
  • ๐Ÿ›  Optional auto-fix โ€” corrections proposed or applied automatically
  • ๐Ÿ“Š Clear output โ€” human-readable + scriptable
  • ๐ŸŒ Bilingual EN/FR

๐Ÿ”Ž What the tool analyses

๐Ÿ”ฅ Firewall (UFW)

  • Active/inactive status
  • Dangerous rules (allow from any)
  • IPv4 / IPv6 consistency
  • Duplicates and errors

๐ŸŒ Exposed services (28+)

  • SSH, Redis, PostgreSQL, Docker, etc.
  • Detection via systemd / active ports
  • Real exposure, risk level, UFW consistency

๐Ÿ“ก Ports

  • Open ports (ss)
  • Interfaces (loopback / LAN / public)
  • Unintended exposures

๐Ÿ“œ UFW logs

  • Suspicious attempts, brute-force detection
  • IP analysis (optional GeoIP)

โ˜๏ธ DDNS / Docker / Virtualisation

  • Advanced network correlations
  • Indirect exposure detection

๐Ÿ“Š Example output

โœ” Firewall active
โš  SSH exposed to the Internet
โœ– Redis open without restriction

Score: 6/10
โ†’ Action required

โ–ถ๏ธ Usage

sudo ufw-audit           # standard audit
sudo ufw-audit -f        # interactive fix mode
sudo ufw-audit -f -y     # auto-fix without confirmation
sudo ufw-audit -v        # verbose
sudo ufw-audit -q        # silent โ€” exit code 0/1/2/3
sudo ufw-audit --french  # French interface

๐Ÿ”Œ Custom services (plugin system)

Drop a .json file into ~/.config/ufw-audit/services.d/ to add services that are not in the built-in registry.

mkdir -p ~/.config/ufw-audit/services.d/
# create my-services.json โ€” same format as ufw_audit/data/services.json

Note (pipx / sudo): ufw-audit requires sudo. Under sudo, ~ resolves to /root.
Place your plugin files in /root/.config/ufw-audit/services.d/ for them to be active at runtime.

This will change in a future .deb release, where the system-wide directory /etc/ufw-audit/services.d/ will be used instead.


๐Ÿค– Automation

  • ๐Ÿ•’ Built-in cron (--install-cron)
  • ๐Ÿ“ง Email notifications (HTML + plain text)
  • ๐Ÿ“ Report management (--manage-logs)
  • ๐Ÿ” Multi-job scheduling (--manage-cron)

Email notifications require a working Postfix setup. See AUTOMATION.md for step-by-step configuration instructions.


๐Ÿงช Quality & reliability

  • โœ… 4134 unit tests
  • ๐Ÿงฑ Modular architecture (snapshot / check separated)
  • ๐Ÿงช Tested on Debian, Ubuntu, Kali, Mint

๐Ÿ†• v1.25.0

  • ๐Ÿ—‚๏ธ CIS compliance mapping inline โ€” each finding in the summary box now shows its machine-readable CIS code [CIS:X.Y.Z] (dimmed); full CIS ref text shown dimmed in --verbose mode after each WARN/ALERT finding
  • ๐Ÿท๏ธ Best-practice entries clarified โ€” 34 entries without a formal CIS section number now use the "Best practice โ€” ..." prefix instead of a misleading "CIS..." label
  • ๐Ÿ”ง cis_refs.json restructured โ€” {"ref": "...", "code": "CIS:X.Y.Z"|null} per entry; 133 entries (99 formal CIS, 34 best-practice, 4 Docker); new get_cis_code() function
  • ๐Ÿงน Locale cleanup โ€” explain_cis section (170 strings) removed from en.json and fr.json; CIS refs now served from JSON, language-independent
  • ๐Ÿ›ก๏ธ 5 new services โ€” SMTP/Postfix (25/tcp), NFS (2049/tcp+udp), Jenkins (8080/tcp), OpenVPN (1194/udp), Squid (3128/tcp); registry now covers 32 services
  • ๐Ÿ› _ipt_has_conntrack ACCEPT fix โ€” regex now requires -j ACCEPT; --ctstate ESTABLISHED -j DROP no longer treated as valid conntrack rule
  • ๐Ÿ”ง FORWARD DROP/REJECT โ†’ โœ” OK โ€” symmetric with INPUT; was previously silent
  • โœ… 4200/4200 unit tests (+60)

v1.24.1

  • ๐Ÿ› Debian kernel parsing hotfix โ€” _KVER_RE now handles 6.12.74+deb13+1-amd64 format (+ separator); _query_apt_kernel_update adds linux-image-$(uname -r) path for Debian (no linux-image-generic meta-package); ABI sort group made optional
  • โœจ CHECK 46 โ€” iptables/nftables audit โ€” when UFW is inactive, audits the underlying firewall layer (INPUT/FORWARD policies, conntrack, iptables vs nftables backend); INPUT ACCEPT โ†’ ALERT โˆ’3 pts
  • โœจ 5 new critical services โ€” Telnet (23/tcp), RDP/xRDP (3389/tcp), MongoDB (27017/tcp), Elasticsearch (9200/tcp), Memcached (11211/tcp+udp) โ€” registry now covers 28 services
  • โœจ Installed-but-inactive critical services โ€” CRITICAL/HIGH packages installed but not running now show โš  [ATTENTION] + risk context block (was โ„น [INFO])
  • โœจ Kernel apt update check โ€” โœ” [OK] when kernel is confirmed current; detects available updates; Ubuntu and Debian supported
  • โœ… 4140/4140 unit tests

v1.23.0

  • โœจ --format=FORMAT โ€” unified output flag: json | json-full | csv | markdown | html; legacy flags (-j, -J, --output csv, --html) kept as aliases
  • โœจ --check=list โ€” prints all 31 filterable section names (no sudo required)
  • โœจ --manage-logs log preview โ€” Enter opens a scrollable viewer; s toggles full/summary mode (score + ALERT/WARN only); g/G top/bottom
  • โœจ Risk context scope qualifier โ€” [CRITIQUE โ€ข LAN] on all service labels when network context is local
  • ๐Ÿ”ง TUI help bar harmonization โ€” consistent hints across --explain, --manage-logs, preview viewer
  • โœ… 4042/4042 unit tests (+35)

v1.22.3

  • ๐Ÿ› Snakeoil cert filter extended โ€” now covers nginx/apache/postfix config paths (previously only /etc/ssl/private)
  • ๐Ÿ› DDNS reflected in exposure view โ€” internet-facing row shows โš  warn when DDNS is active
  • ๐Ÿ› High-numbered listen ports shown โ€” removed incorrect port < 32768 ephemeral filter
  • ๐Ÿ› SSH notes display fixed โ€” local-exposure and non-standard-port notes no longer concatenated on one line
  • โœ… 4004/4004 unit tests (+3)

v1.22.1

  • ๐Ÿ”ง recurrence.py float policy unified โ€” update_recurrence now normalizes floats to int (consistent with load_recurrence); import os removed
  • ๐Ÿงช Test suite hardening โ€” test_message_uses_translation_key; fw_policy=None โ†’ alert asserted; test_float_value_in_prev_is_normalized
  • โœ… 4001/4001 unit tests (+5)

v1.22.0

  • ๐Ÿ”— Signal correlation engine โ€” 5 compound-risk rules combining individual findings (root login + no Fail2ban โ†’ ALERT; password auth + brute-force โ†’ ALERT; NOPASSWD sudo + unexpected SUID โ†’ WARN; etc.)
  • ๐Ÿ” Recurring finding tracker โ€” counts consecutive audit appearances per key; persisted at ~/.config/ufw-audit/recurrence.json
  • ๐Ÿ“ก Port exposure analysis โ€” groups exposed listening services by interface scope and risk level; fw_policy allowlist fix
  • ๐Ÿ“‹ Comparative report โ€” finding-key diff โ€” new/resolved ALERT+WARN keys shown between audits; migration guard for pre-v1.22 baselines
  • ๐Ÿ› IPv6 false-positive fix โ€” WARN downgraded to INFO when only link-local/ULA addresses assigned (machine not internet-reachable via IPv6)
  • ๐Ÿ› Kernel message fix โ€” redundant "(running: X, latest: X)" suppressed when both values are identical
  • ๐Ÿ› Snakeoil cert filter โ€” ssl-cert-snakeoil.pem no longer triggers TLS audit on Debian/Ubuntu
  • ๐Ÿ” --explain โ€” 87โ†’112 keys (+25 across 7 new groups: auth logs, umask, firewall logging, TLS/SSL certs, systemd timers, firmware, Docker)
  • โœ… 3996/3996 unit tests (+218)

๐Ÿง  Philosophy

Not just listing ports โ€” understanding the real risk.

ufw-audit prioritises what matters: real exposure, attack surface, potential impact.


๐Ÿ“ Project structure

Automated-UFW-audit/
โ”œโ”€โ”€ README.md / README_FR.md        # project overview (EN/FR)
โ”œโ”€โ”€ LICENSE
โ”œโ”€โ”€ pyproject.toml                  # build config (pip/pipx install)
โ”œโ”€โ”€ DOCUMENTS/
โ”‚   โ”œโ”€โ”€ README_TECH.md / _FR.md     # complete technical reference
โ”‚   โ”œโ”€โ”€ README_DEV.md / _FR.md      # developer documentation
โ”‚   โ”œโ”€โ”€ CHANGELOG_FULL.md / _FR.md  # full version history
โ”‚   โ”œโ”€โ”€ TESTING.md / _FR.md         # test plan & validated scenarios
โ”‚   โ””โ”€โ”€ AUTOMATION.md / _FR.md      # cron & automation guide
โ”œโ”€โ”€ ufw_audit/                      # Python package
โ”‚   โ”œโ”€โ”€ checks/                     # firewall, services, ports, logs, ddns, docker, virt, ssh, ssl_certs, systemd_timers, firmware
โ”‚   โ”œโ”€โ”€ data/
โ”‚   โ”‚   โ”œโ”€โ”€ services.json           # 22 built-in service definitions
โ”‚   โ”‚   โ”œโ”€โ”€ profiles/               # built-in audit profiles (server, desktop, container)
โ”‚   โ”‚   โ””โ”€โ”€ ufw-audit.bash-completion
โ”‚   โ”‚   # ~/.config/ufw-audit/services.d/  โ† user plugin directory (sudo: /root/...)
โ”‚   โ”‚   # ~/.config/ufw-audit/profiles/    โ† user-defined audit profiles
โ”‚   โ””โ”€โ”€ locales/
โ”‚       โ”œโ”€โ”€ en.json
โ”‚       โ””โ”€โ”€ fr.json
โ””โ”€โ”€ tests/                          # 3996 unit tests

๐Ÿ“„ License

MIT โ€” ยฉ 2026 Cรฉdric Clauzel


๐Ÿค Contributing

Bug reports, new detections, UX improvements โ€” contributions welcome.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ufw_audit-1.25.1.tar.gz (543.0 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

ufw_audit-1.25.1-py3-none-any.whl (398.9 kB view details)

Uploaded Python 3

File details

Details for the file ufw_audit-1.25.1.tar.gz.

File metadata

  • Download URL: ufw_audit-1.25.1.tar.gz
  • Upload date:
  • Size: 543.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for ufw_audit-1.25.1.tar.gz
Algorithm Hash digest
SHA256 fad356a4f40ea0a927f62d7e6452416c8ed7006764395b381d3f8f3ac3b352d7
MD5 fcad66dd0458ba6ccbf9b8e603b2b123
BLAKE2b-256 6f682ad0d2ddac90cca50f56338f7a01da65efe59820045a96288c5fe067a168

See more details on using hashes here.

File details

Details for the file ufw_audit-1.25.1-py3-none-any.whl.

File metadata

  • Download URL: ufw_audit-1.25.1-py3-none-any.whl
  • Upload date:
  • Size: 398.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.3

File hashes

Hashes for ufw_audit-1.25.1-py3-none-any.whl
Algorithm Hash digest
SHA256 03f63efa6a492f8ba0baab2afe9afe42b774ceef9fc1dcf69676bb7ed49fb08c
MD5 2d8a2b68a43a71498ed83877d8bcaab8
BLAKE2b-256 8ce7a4229dee46edd18d6acbffe022ca9998156f4b5c9c142921d2293e32dcf5

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page