I’ve been plagued by hackers trying to break my Home Assistant by attacking the file structure.
HA typically warns about these with log messages like
2026-04-10 22:51:45.572 WARNING (MainThread) [homeassistant.http.security_filter] Filtered a potential harmful request from 216.167.35.4 to: /cgi-bin/../../../../../../../../../../bin/sh
2026-04-10 22:51:45.783 WARNING (MainThread) [homeassistant.http.security_filter] Filtered a potential harmful request from 216.167.35.4 to: /cgi-bin/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/%2e%2e/bin/sh
2026-04-10 22:51:57.557 WARNING (MainThread) [homeassistant.http.security_filter] Filtered a request from 216.167.35.4 with a potential harmful query string: /index.php
2026-04-10 22:51:57.780 WARNING (MainThread) [homeassistant.http.security_filter] Filtered a request from 216.167.35.4 with a potential harmful query string: /index.php
I added each offender to ip_bans.yaml but they just increment their ip address to get around the ban.
To help with this I’ve forked and modified the http component to be able to ban by subnet (a.b.c.d/n etc) and this has eased the problem considerably as you can exclude whole parts of the internet with one line.
For example 123.0.0.0/8 excludes 123.[0-255].[0-255].[0-255]
Home Assistant handles this with the core http component. I have developed this into a custom component and it can be found here
Would anybody find this useful?
To test my forked http component:
Make sure your HA version is at least 2026.4.1
Copy the whole http folder into the custom_components config folder.
To ban networks, add the following to configuration.yaml in the http section
http:
....
ip_ban_enabled: True # optional as defaults to True
banned_networks: # Make sure the format is right, e.g. /16 must end in 0.0/16
- 111.7.0.0/16
- 45.0.0.0/8
- 179.43.0.0/16
- 123.160.0.0/14
- 195.178.0.0/16
log_banned_networks: True # optional as defaults to True
notify_banned_networks: True # optional as defaults to True
Make sure you never exclude local addresses (10.x, 172.x, 192.x)
If you enable logging it will report as info messages so if the default logger setting is as above this you will need to add a logs: line to the logger: in configuration.yaml like this
logger:
default: critical
logs:
custom_components.http: info
Risks:
I strongly suggest you install the samba app/add-on so you can access the config folder without using the ha file editor app/addon in case something breaks and you are locked out of ha. You should also have ssh access through a client like putty so you can restart if needed.
Views please
[edited 11/4/26 to match current Github location and configuration options]