Skip to content

metrics and health listeners bind all interfaces, and the address is not configurable #211

Closed

Description

@scttfrdmn

What

The metrics and health HTTP listeners bind :port — all interfaces — and the address is not
configurable. An operator who wants them reachable only from the host cannot express that in
configuration; the only options are "all interfaces" or "off".

Verified

internal/metrics/collector.go:155:

c.server = &http.Server{
    Addr: fmt.Sprintf(":%d", c.config.Port),

internal/health/checker.go:482:

ln, err := lc.Listen(ctx, "tcp", fmt.Sprintf(":%d", c.config.HTTPPort))

Confirmed by dialling a live collector from a non-loopback address of the same host:

RESULT: reachable on non-loopback 192.168.6.94:18081 — binds all interfaces

Both are on by default (monitoring.metrics.enabled: true,
monitoring.health_checks.enabled: true in config.NewDefault), so a stock objectfs s3://bucket /mnt opens two unauthenticated ports to the network.

Why it matters

Neither endpoint serves object contents, keys, or credentials, so this is not a data-disclosure
bug. But /debug/operations and /metrics between them give per-operation counts, error rates,
sizes, and timings — enough to characterize what a bucket is being used for and when — and neither
has any authentication. On a shared HPC login node or anything with a public interface, that is
exposed to every host that can route to it.

There is prior art in this repo for the shape of the fix: MonitoringConfig already carries
MetricsAddr: ":9090" and HealthCheckAddr: ":8081" string fields (internal/config/config.go:570,572)
which are read by nothing. Either wire those (and reconcile them with global.metrics_port /
global.health_port, which are the fields actually used — two sources for one setting is its own
defect) or add explicit bind-address fields.

Proposed

  • A bind address per listener, defaulting to 127.0.0.1 rather than all interfaces. Defaulting to
    loopback is the safer default and does not break a Prometheus scrape from the same host; a
    cross-host scrape becomes an explicit opt-in, which is the right way round.
  • Resolve the duplication: MetricsAddr/HealthCheckAddr vs MetricsPort/HealthPort. One of
    each pair should exist. The dead ones should be deleted, not left to be discovered again.
  • A test that asserts the bound address, not just that something is listening — the current
    TestStartMetricsBindsTheEndpoint scrapes 127.0.0.1 and passes either way.

Related: #211 (metrics_port: 0 does not disable the listener).

Activity

  1. added
    type: security
    priority: medium
    area: metrics
    area: config
    effort: small
    on Aug 2, 2026
  2. scttfrdmn commented on Aug 3, 2026

    @scttfrdmn
    OwnerAuthor

    Fixed and shipped in the v0.11.0 Unreleased changelog, under Each listener's address is one setting, beside the enabled flag that governs it.

    Both listeners now bind monitoring.metrics.addr and monitoring.health_checks.addr, defaulting to loopback — 127.0.0.1:8080 and 127.0.0.1:8081 in internal/config.DefaultMetricsAddr/DefaultHealthAddr. Same ports as before, so a same-host Prometheus scrape keeps working; the host is what changed.

    The address is configurable because it is now the only setting: global.metrics_port, global.health_port, monitoring.metrics_addr and monitoring.health_check_addr are all removed. That set is the whole defect — monitoring declared the two addresses, defaulted them, documented them, and read neither, while the ports two sections away were what the listeners used and could not express a host at all, since the bind was fmt.Sprintf(":%d", port).

    The test gap was the more interesting half: TestStartMetricsBindsTheEndpoint scraped 127.0.0.1 and passed against a wildcard bind, because a wildcard bind answers on loopback too. It now asserts on the address the listener reports, which is the one thing that differs.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    area: configarea: metricseffort: smallpriority: mediumtype: security

    Type

    No type

    Projects

    No projects

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions