Add allowed_targets whitelist support#404
Add allowed_targets whitelist support#404dadbravo wants to merge 3 commits intoprometheus-pve:mainfrom
Conversation
|
Thank you for filing this PR. From a user perspective, I do think this could be an interesting feature. With my maintainer hat on, I don't think I'd like to have this in the code base. This is the kind of stuff which absolutely needs unit tests and many eyes to carefully review all the implications. Otherwise this will backfire on users relying on it - and consequently on the project as well. I'm tempted to close this PR as a won't fix. |
|
That said, I might be accepting a PR which implements this feature using simple pattern matching (without attempting to deal with IP (v4/v6) addresses explicitly). E.g., something based on fnmatch |
|
I will redo it as you advise. I will do it later and send you a review. I will also do the synthetic test |
|
I do fully understand the attack vector. I'm sorry that there is no big warning at the top of the README to never expose the port to the internet. Its obvious for people used to work with prometheus, but it seems it isn't for everybody else. |
|
@znerol I checked everything, and it works as it should. I created many connections, everything holds up. I don’t see any issues that could have affected production. Here is my config and a couple of requests. |
This PR adds
allowed_targetssupport to restrict which ?target= values can be used when querying Proxmox metrics.This adds an optional layer of security directly in the exporter logic. If
allowed_targetsis not set, only localhost is accepted. Subnets, hostnames, and IPs with optional ports are supported.See README section
Whitelist: allowed_targetsfor full details and configuration examples.This security measure ensures that even if the exporter port is exposed, an attacker cannot use it to connect to arbitrary Proxmox hosts and steal API credentials. Only explicitly allowed targets will be contacted by the exporter.