-
-
Notifications
You must be signed in to change notification settings - Fork 33.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve http component to ban IP addresses by subnet #140661
base: dev
Are you sure you want to change the base?
Conversation
Added the option to ban by subnet using a standard subnet descriptor (e.g. 123.4.0.0/16). Existing ip_bans.yaml left as is
Option to ban by subnet and optionally notify front end and system logs
Subnet bans added and prevent banning supervisor subnet
Added source ip of offending call to log entry and added front end notification
Added ban by subnet and improved logging/notification
Now checks for banned ip/network before checking the requested path etc
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please take a look at the requested changes, and use the Ready for review button when you are done, thanks 👍 |
Hey there @home-assistant/core, mind taking a look at this pull request as it has been labeled with an integration ( Code owner commandsCode owners of
|
Amazing, it's really matching the security improvement needed on the IPBan feature. Since beginning of this year every port openned on the Internet is massively scanned & tried by bots. |
Breaking change
Not a breaking change. All extra functionality is optional
Proposed change
Security enhancement.
To add the option to block incoming requests by IP subnet not just IP address.
Any valid subnet range can be used like 1.2.3.0/24 (small range) or 1.2.0.0/16 (large range)
The existing http component only allows for individual IP addresses.
Change the order of security filtering to check for banned IP addresses (individual or range) before checking for anomalous strings in the requested path.
This is on the logic that if an IP has been flagged as suspicious there's no point checking for details in the requested path.
Added the source path to security notifications and log entries (so the user can see the origin IP address and potentially block it or its subnet)
Type of change
Additional information
Every incoming request is checked against a list of banned IP subnets and if the IP address is in any of the banned subnets a forbidden response is generated.
If the IP is not in any of the banned subnets, normal checking for security issues carries on as before.
__init.py__
has been changed to load the new configuration options which are a list of banned subnets and whether or not the user wants to log and/or be notified of breaches.The banned subnets are defined in configuration.yaml in the format:
Checklist
ruff format homeassistant tests
)If user exposed functionality or configuration variables are added/changed:
If the code communicates with devices, web services, or third-party tools: Does not communicate
Updated and included derived files by running:
python3 -m script.hassfest
.requirements_all.txt
.Updated by running
python3 -m script.gen_requirements_all
.To help with the load of incoming pull requests: