Repository navigation
feat(server): metricsAddr, a telemetry listener that scrapers can reach - #33
Merged
Merged
Conversation
fold's DNS-rebinding protection covers /metrics like every other path, so a scraper arriving under any name outside server.allowedHosts is answered 403 and the target reads as down with no other symptom. That is why the chart's ServiceMonitor could not scrape a pod IP, and why the compose profile needed the service name allowlisted. The obvious fix — exempt the path — is the wrong one here. A scrape names upstream ids, namespaces, tenant ids, and multi-endpoint upstreams' endpoint URLs: a description of the federation and its internal hostnames. On the loopback-bound default, exempting it would let any page an operator visits read that. Origin checking cannot substitute either: in a rebinding attack the page and the target share the attacker's hostname, so the browser calls it same-origin and sends no Origin header at all. The Host allowlist is the check that catches it. So server.metricsAddr moves /metrics and /health to their own listener instead. It is not an origin a browser can be steered to, so it needs no Host allowlist, and what guards it is that an operator binds it to an internal interface. The public port keeps its checks and stops carrying the disclosure: /metrics leaves that mux entirely rather than being served in both places, since a second copy would forfeit the point. Absent by default, so nothing changes for anyone who does not set it. The gateway owns the listener when the document asks for one — an embedder who would rather mount it themselves uses the new MetricsHandler and leaves the field unset — and it binds eagerly, so a port already in use fails New where an operator sees it rather than disappearing into a log line while the gateway serves on without metrics. Construction-wired like the rest of the server section; a reload rejects a change. In the chart, metrics.listener.enabled opens the port, sets metricsAddr in the rendered config (an explicit value in `config` wins — the chart fills in only what was left unsaid), and points the ServiceMonitor at it, which makes that ServiceMonitor work for the first time without "*" in allowedHosts. The default render is unchanged, port for port. Tests state the property rather than the plumbing: a scrape under an unlisted Host is 403 on the main mux, the same scrape succeeds under any Host on the telemetry listener, the move is a move and not a copy, Close releases the port, a bind failure fails New, MetricsHandler is mountable, and a reload rejects the change. Latency gate 185us; chart to 0.1.5. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes the
/metrics403 found while building the compose observability profile (#31), and makes the chart's ServiceMonitor work for the first time.The problem
DNS-rebinding protection covers
/metricslike every other path, so a scraper arriving under any name outsideserver.allowedHostsis answered403— the target reads as "down" with no other symptom. A pod IP is a Host no static allowlist can name.Why not just exempt the path
A scrape names upstream ids, namespaces, tenant ids, and multi-endpoint upstreams' endpoint URLs — the federation's shape and its internal hostnames. On the loopback-bound default, exempting it would let any page an operator visits read that from their own machine.
And Origin checking cannot substitute: in a rebinding attack the page and the target share the attacker's hostname, so the browser treats the request as same-origin and sends no
Originheader at all. The Host allowlist is the check that catches it.What this does instead
server.metricsAddrmoves/metricsand/healthto their own listener — not an origin a browser can be steered to, so it needs no Host allowlist, and what guards it is being bound to an internal interface. The public port keeps its checks and stops carrying the disclosure:/metricsleaves that mux rather than being served in both places, since a second copy would forfeit the point.MetricsHandler()and leave the field unset.Newwhere an operator sees it, instead of vanishing into a log line while the gateway serves on without metrics.Chart
metrics.listener.enabledopens the container/service port, setsmetricsAddrin the rendered config (an explicit value inconfigwins — the chart fills in only what was left unsaid), and points the ServiceMonitor at it. Rendered:The default render is unchanged, port for port.
Tests
State the property, not the plumbing: a scrape under an unlisted Host is
403on the main mux (pinning the behavior that motivated this), the same scrape succeeds under any Host on the telemetry listener, the move is a move and not a copy,Closereleases the port, a bind failure failsNew,MetricsHandleris mountable, and a reload rejects the change.make checkgreen,make helm-checkgreen, latency gate 185 µs. Chart to 0.1.5.security-model.mdgains "Telemetry is a disclosure surface" recording the reasoning above.🤖 Generated with Claude Code