Skip to content

v1.1.0

Latest

Choose a tag to compare

@drg-src drg-src released this 04 Dec 22:01
cfab378

danfoss-shield v1.1.0

Adds a check that each controller found has an active drop rule (scan exits 4 when it does not), a fix that reads the firewall before and after it writes, a versioned JSON report, release files you can verify, plain console output with help for every option, and a hardening pass over targets, results, root use and output files.

Breaking changes

  • scan and check now exit 4 when a controller is found and its drop rule is not verified present. A closed auth endpoint used to exit 0; it now exits 4 until the rule check finds our drop rule present and active. That includes every run without root, off Linux, and wherever the firewall cannot be read. 2 outranks 4, and 4 outranks 1. --no-rule-check brings back exit 0 with a warning on every run, and exit 0 then says nothing about a rule. Cron jobs and monitoring that alarm on any non-zero exit will alarm whenever a controller has no verified rule.
  • --install-timer runs only as root on Linux (elsewhere exit 1, no unit written). Its scan checks the rule, so it fails (exit 4) when a controller has no verified drop rule, for example after a reboot or firewall reload.
  • -o x.json and the timer's scan-latest.json are now the JSON report, schema 1, with new keys and the status values unverified (exit 4) and rule_check_off (exit 0).
  • -o refuses a name that exists as a link, a device such as /dev/null, or another special file (exit 1, before the scan). A regular file is still replaced.
  • The label "Dixell XWEB Pro" is now "Dixell/Copeland XWEB" everywhere.
  • On an XWEB page, a 404 from the auth endpoint is now unknown (exit 1) instead of closed. A Danfoss 404 is still closed.
  • Console output changed: no banner; a table with one row per controller, a key, counts, next: lines and one exit line such as [EXIT 4] a controller's drop rule is not verified present. Warnings and errors are plain warning: and error: lines; colour only on a terminal (--no-color, NO_COLOR). Scripts that match the old text need updating; --json is the stable interface.
  • fix can now exit 4: a rule is in place and read back but fails the rule check (for example forwarding off or a notrack rule). A refusal is always 1, and a dry run never exits 4.
  • fix --force rebuilds our rules as one set and allows a default-gateway target. It does not pass a public target (use --routed with --authorized) or lift any other refusal.

Upgrade

A timer that an earlier release installed as a normal user keeps running, and its scan exits 4 whenever it finds a controller. Remove it as that user:

systemctl --user disable --now danfoss-shield.timer
rm ~/.config/systemd/user/danfoss-shield.service ~/.config/systemd/user/danfoss-shield.timer

Then put the script in a folder only root can write (for example /usr/local/lib/danfoss-shield) and run --install-timer again as root, on the gateway.

Added

  • Rule check in scan and check: each controller's drop rule is reported as present, not present or not checked, with a reason. It needs root on the Linux gateway.
  • fix reads the firewall before it writes, refuses rather than guess, repairs our rules as a whole when needed, and reads every rule back (what fix does and refuses).
  • JSON report: -o x.json on scan, check and shodan; --json on scan and check.
  • fix --routed for a controller on a routed public address of yours (needs --authorized).
  • Help text for every option; SHA256SUMS and an SBOM next to the script.

Changed

  • The docs carry Copeland and CISA facts on XWEB and say where to find the firmware version (details).
  • A host that refuses every probed port is printed instead of dropped silently; this machine's own address no longer counts toward "nothing answered".
  • TLS probes accept TLS 1.0 and newer with the widest default cipher set. Nothing is verified.

Security hardening

  • Targets: hostname answers are printed and capped, unusual IPv4 spellings are refused, and Teredo, 6to4 and NAT64 count as public.
  • As root: child tools run with a fixed PATH and only LC_ALL=C; --output must be in a root-owned folder with no link in its path; --install-timer needs the script and its Python in root-only folders.
  • Reports are written to a new file and renamed into place. A failed write after an open endpoint still exits 2.

Tested

  • The test suite passes on Windows 11 (660+ checks) and on Linux in WSL 2 (690+ checks; 680+ as root), with the firewall layer mocked.
  • In throwaway network namespaces on WSL 2 as root, with real packets: connections from the WAN side, direct and through a port-forward, were dropped by the rules fix wrote and passed again after rollback; the scan exited 4 before fix and 0 after; each broken state tried was found and repaired or refused. 80+ checks passed, 0 failed.
  • As real root on WSL 2: rules loaded and rolled back on both backends, the timer and output-folder rules. systemd-analyze verify passed on the timer units.
  • CI runs the suite on Python 3.9 to 3.14; the results are on the repository's Actions page.

What it does not do

It does not put rules back after a reboot or a firewall reload, find a controller's other addresses, read a firmware version, or say a controller is protected, safe or fixed. It checks that a drop rule is present and active; the block is a stopgap until the controllers are patched.

Not tested

Real Danfoss or XWEB devices (the tool has never run against a real controller), a real gateway, iptables-legacy, conntrack helpers, a bridging gateway, the Suricata rules in Suricata, and macOS. Full list: What was tested.

Verify the download

With the three files in one folder, run sha256sum -c SHA256SUMS. Expected SHA-256:

49723b66ed9b1debcbbfb8d0a73f8ef60e9000f0a883e53f796d0b7eaa33a2e8  danfoss_shield.py
d49d6fb373dd198e312ed25e4b08ecbb0c6ef8bd5b3d2c34498a35f41f802b42  danfoss-shield-1.1.0.cdx.json

Windows steps: Verify a release. Setup and usage: README. MIT licensed. danfoss-shield is an independent project, not affiliated with or endorsed by Danfoss or Copeland.