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 ensurepathto 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
🔌 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. Undersudo,~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
.debrelease, 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
- ✅ 3259 unit tests
- 🧱 Modular architecture (snapshot / check separated)
- 🧪 Tested on Debian, Ubuntu, Kali, Mint
🆕 v1.19.0
- 🔑 SSH
PermitRootLoginOK cases —no→ OK (full disable);prohibit-password/forced-commands-only→ OK restricted; previously only the ALERT path was covered - ⚡ SUID scan performance —
find /replaced with a targeted_SCAN_ROOTSlist; scan time reduced from >10 s to <1 s; SGID whitelist extended - 🐛 IoT dominance display fix —
logs.local_dominanceINFO finding now correctly shown in log results section - 🌍 Domain score labels i18n — all 7 domain labels translated via
t()when--frenchis active - 🛡 Hardening — 6 new sysctl checks —
tcp_syncookies(SYN flood protection);accept_source_route(IP source routing);accept_redirects_v6(IPv6 ICMP redirects);send_redirects(ICMP redirect sending);protected_hardlinks(hardlink attacks);protected_symlinks(symlink /tmp race conditions) — all read via/proc/sys/, WARN −1 pt each - ✅ 3259/3259 unit tests (+530)
🧠 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
│ ├── 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/ # 3259 unit tests
📄 License
MIT — © 2026 Cédric Clauzel
🤝 Contributing
Bug reports, new detections, UX improvements — contributions welcome.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ufw_audit-1.19.0.tar.gz.
File metadata
- Download URL: ufw_audit-1.19.0.tar.gz
- Upload date:
- Size: 433.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8eddc431ee4319a7a8826c7a45bca60de7fddfe86206403c10de11aa1beee6fd
|
|
| MD5 |
97be026428484e5d978b52e9182c9cfa
|
|
| BLAKE2b-256 |
68bf5369b4d3584f22d00c8852d2eb54aeaa0bc301251a034b9a68f9b78e3f46
|
Provenance
The following attestation bundles were made for ufw_audit-1.19.0.tar.gz:
Publisher:
publish.yml on Masbateno/Automated-UFW-audit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ufw_audit-1.19.0.tar.gz -
Subject digest:
8eddc431ee4319a7a8826c7a45bca60de7fddfe86206403c10de11aa1beee6fd - Sigstore transparency entry: 1328350100
- Sigstore integration time:
-
Permalink:
Masbateno/Automated-UFW-audit@73c46981a348d33e722a2f837455d8c2ecd04fe0 -
Branch / Tag:
refs/tags/v1.19.0 - Owner: https://github.com/Masbateno
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@73c46981a348d33e722a2f837455d8c2ecd04fe0 -
Trigger Event:
push
-
Statement type:
File details
Details for the file ufw_audit-1.19.0-py3-none-any.whl.
File metadata
- Download URL: ufw_audit-1.19.0-py3-none-any.whl
- Upload date:
- Size: 326.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
035307fe05f252d2691f07356bbc86bfae420b453e76e3a11329c8596d374c65
|
|
| MD5 |
1b0adce1e389ef2f74570cb8d9a20c72
|
|
| BLAKE2b-256 |
5b369141e28183f6b37345f1fe43ee21e95cabdd719cb85cb21603ae8f5a8c59
|
Provenance
The following attestation bundles were made for ufw_audit-1.19.0-py3-none-any.whl:
Publisher:
publish.yml on Masbateno/Automated-UFW-audit
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
ufw_audit-1.19.0-py3-none-any.whl -
Subject digest:
035307fe05f252d2691f07356bbc86bfae420b453e76e3a11329c8596d374c65 - Sigstore transparency entry: 1328350112
- Sigstore integration time:
-
Permalink:
Masbateno/Automated-UFW-audit@73c46981a348d33e722a2f837455d8c2ecd04fe0 -
Branch / Tag:
refs/tags/v1.19.0 - Owner: https://github.com/Masbateno
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@73c46981a348d33e722a2f837455d8c2ecd04fe0 -
Trigger Event:
push
-
Statement type: