Skip to main content

UFW firewall audit tool — cross-checks rules against listening services

Project description

Lire en français · Technical documentation

🔒 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 (22+)

  • 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

🤖 Automation

  • 🕒 Built-in cron (--install-cron)
  • 📧 Email notifications (HTML + plain text)
  • 📁 Report management (--manage-logs)
  • 🔁 Multi-job scheduling (--manage-cron)

🧪 Quality & reliability

  • ✅ 639 unit tests
  • 🧱 Modular architecture (snapshot / check separated)
  • 🧪 Tested on Debian, Ubuntu, Kali, Mint

🆕 v1.2.0

  • 🔒 Code quality pass: 12 defensive fixes across 8 modules (no behaviour changes)
  • 🐛 Private IPv4 172.x range corrected to RFC 1918 only (172.16–31) in sysinfo.py
  • 🐛 i18n.current_lang() now returns the actually loaded locale (not the requested one)
  • 🐛 send_html_email() now checks for sendmail (was checking mail)
  • 🛡 Deduction.context validated; cap reason now visible in score breakdown
  • 🛡 Registry validates config_key format and port strings (number/tcp|udp)
  • ✅ 639/639 unit tests

🧠 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)
├── install.sh                      # shell installer [DEPRECATED]
├── 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
│   ├── data/
│   │   ├── services.json           # 22 service definitions
│   │   └── ufw-audit.bash-completion
│   └── locales/
│       ├── en.json
│       └── fr.json
└── tests/                          # 639 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.3.0.tar.gz (124.9 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.3.0-py3-none-any.whl (104.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: ufw_audit-1.3.0.tar.gz
  • Upload date:
  • Size: 124.9 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.3.0.tar.gz
Algorithm Hash digest
SHA256 cca36adb4cbb276160d2fad1fd6f22a831911a6027b4e4cfe458e3b571f90af8
MD5 61b83780567c72440d9610595d97a65f
BLAKE2b-256 31abe78dc70a9d1f94a5dfd775824e16f96b460faa1c7cf792ea93f4ed7dd0f6

See more details on using hashes here.

File details

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

File metadata

  • Download URL: ufw_audit-1.3.0-py3-none-any.whl
  • Upload date:
  • Size: 104.0 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.3.0-py3-none-any.whl
Algorithm Hash digest
SHA256 3b11de5096eabcecabc3e059ae3ee1947051a23b6fe526314d754bf84ef6e6cb
MD5 2f2d0f6ac7e211a8812fac1eaa2b7344
BLAKE2b-256 1be6919b4b7c41fb04924cd7388e9d16f7f6a2bdf54d7a754365db28876ec2db

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