Skip to content

fix(dnsfw): dead URLhaus hostfile preset (HTTP 410) -> keyless NetAPI domain list - #117

Merged
aixisstudio merged 1 commit into
aixisstudio:mainfrom
slavaolesik:fix-dnsfw-malware-preset
Nov 28, 2026
Merged

aixisstudio merged 1 commit into
aixisstudio:mainfrom
slavaolesik:fix-dnsfw-malware-preset

Conversation

@slavaolesik

Copy link
Copy Markdown
Contributor

Wiretap already uses the NetAPI IP list as the netapi_compromised preset (#101). This PR fixes the malware category of the DNS firewall with the NetAPI domain list.

The malware_abusech category of the DNS firewall loads nothing: on 2026-10-21 URLhaus stopped serving its hostfile (https://urlhaus.abuse.ch/downloads/hostfile/). Through fetch_list() today it gives fetch failed: HTTP Error 410: Gone.

This PR replaces the preset with a list that answers without a key:

"malicious_netapi": {
    "label": "Malicious domains: phishing & scams (NetAPI)",
    "url": "https://netapi.com/api2/netapi-compromised-domains-short.txt",
    "license": "CC BY 4.0",
    "format": "domains",
},

About the list:

  • 128,184 domains today, 2.5 MiB, so it stays under the 4 MiB cap. Bare domains, one per line, read by the existing "domains" format (as the OpenPhish preset). Regenerated hourly, no key, CC BY 4.0. How it is built: https://netapi.com/compromised-urls/
  • 83.7 % of its names (107,228 of 128,184) are covered by neither StevenBlack unified nor the OpenPhish feed, counted with the same suffix match as DomainFilter.
  • With all seven categories enabled the filter holds 280,458 domains, under _MAX_DOMAINS (400,000).

A saved malware_abusech choice is dropped by configure(), as any unknown key already is, and is not moved to the new preset: that choice was consent for abuse.ch, and the ground rule is no new outbound host without an opt-in. The category shows up unchecked in Settings. If you prefer a migration, tell me and I will add the mapping.

Changes:

  • backend/detection/dnsfw.py: the preset and the header comment (EN/FR)
  • backend/tests/test_dnsfw.py: five tests. No preset points at abuse.ch, preset metadata and its entry in status(), the list shape through _parse_hosts(), refresh_lists() with urlopen mocked (the preset URL is fetched once, listed names and their subdomains are blocked, the second refresh is served from the disk cache), and a saved malware_abusech choice contacts no host

No frontend change: the label comes from available_categories.

Tested:

  • the CI steps on Python 3.11 (python:3.11-slim): ruff check backend --select E9,F clean, pytest tests/ 431 passed, 14 skipped. tests/test_dnsfw.py on Windows (Python 3.13): 15 passed
  • live in a container (python:3.11-slim-bookworm, NET_ADMIN + NET_RAW) with the backend started by run_backend.py: POST /dnsfw/config with {"categories": ["malicious_netapi"], "enabled": true}, then POST /dnsfw/refresh reported fetched 128184 domains (2605 KiB). dig @127.0.0.1 -p 5353 returned NXDOMAIN for a listed name and for www. of another listed name, and NOERROR with A records for example.com. /dnsfw/blocked showed both names with the category malicious_netapi, and per_category counted 2

One more thing I saw on the way, not touched here to keep the diff to one concern: refresh_lists() writes the cache as bare domains and reads it back with the preset's format, so for the hosts-format presets (all the StevenBlack ones) the cache parses to nothing and the list is fetched again on every refresh instead of once a day. I can send that as a separate PR with a test.

Thanks!
Slava

Disclosure: I run NetAPI, which publishes this list.

@aixisstudio

Copy link
Copy Markdown
Owner

Merci Slava — this is exactly right. I verified both claims before merging: the URLhaus hostfile indeed answers HTTP 410 since their keyless-download retirement, and the NetAPI list serves fine without a key.

What I especially appreciate: the deliberate new preset key so a saved malware_abusech choice gets dropped rather than silently redirected to a different host without fresh opt-in. That is the kind of security-conscious thinking this project runs on. And the test coverage (+115 lines) with the bilingual comments matching the codebase conventions — exemplary first contribution.

Merging now. Welcome aboard, and feel very free to pick anything else that looks off.

@aixisstudio
aixisstudio merged commit dd09321 into aixisstudio:main Nov 28, 2026
10 checks passed
@slavaolesik

Copy link
Copy Markdown
Contributor Author

Thank you for the careful review and the kind words, @aixisstudio! Glad it fits. I will keep an eye out for anything else that looks off.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants