Skip to content

Releases

v1.1.0

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.

v1.0.1

Choose a tag to compare

@drg-src drg-src released this 12 Nov 09:49
ee2c1d8

v1.0.1

danfoss-shield helps you find Danfoss and Dixell refrigeration controllers (StoreView, AK-SM, XWEB) that are exposed on the internet, and block them at your gateway firewall while you wait for a proper fix. It is a stopgap, not a patch.

Features

  • Scan your own network for exposed controllers and report each one as open, closed or unknown. A scan that could not finish is never reported as clean.
  • Block new connections to them from the internet with nftables or iptables, IPv4 and IPv6.
  • Safety first: it backs up your firewall rules before changing anything, checks every target before it starts, refuses to block your own gateway, and rolls back only the rules it added.
  • Exit codes you can script against: 0 is a complete, clean run, 1 is an error, an incomplete scan or an unknown result, 2 means an open auth endpoint was found, 3 means the command needs root.
  • Each probe has a time limit, so a slow or stalling host cannot hold up a scan. --silent-ok lets a range with unused addresses pass.
  • Optional Shodan lookup limited to your own public range (read-only), Suricata rules, and a scheduled scan.
  • No packages to install. It uses only Python's standard library (Python 3.9+). The blocking step uses your system's nft or iptables.

Use it only on what you own

Scanning machines you do not own can be illegal. The tool refuses public targets unless you pass --authorized to confirm you have permission.

Tested

  • Automated checks run in CI on Python 3.9, 3.12, 3.13 and 3.14 on Linux and on Python 3.13 on Windows.
  • The firewall rules were loaded and rolled back as root on real Linux (nftables and iptables). That is a load-and-remove check, not a test against real forwarded traffic.
  • The Shodan code is tested against a mocked API. The Suricata rules were not validated against a Suricata install.

Good to know

  • It is a stopgap. The real fix is to patch the controllers, replace old ones, or remove the port-forward on your router.
  • Blocking only works when you run it on the gateway that routes the controllers' traffic.
  • Controllers that show no fingerprint on their start page are not found.
  • Rules are not kept after a reboot by default. The tool shows you how to make them stick.
  • Exit 0 does not mean your controllers are safe.

See the README for setup and usage. MIT licensed.

Verify the download

SHA-256 of danfoss_shield.py:
42294cc0a79f3c5d31904f23dbffbd9ecb3df2420c4c368cac780372bd96b63d

sha256sum danfoss_shield.py