[otel-beatreceiver-isolation] Receiver hostname config leaks via process-wide override across BeatReceivers
Findings
1. Receiver-local hostname config mutates process-global hostname override used by all receivers
Severity: High
Location
x-pack/libbeat/cmd/instance/beat.go:181libbeat/cmd/instance/beat.go:820-826libbeat/beat/info.go:32,36,46libbeat/publisher/processing/default.go:152-153libbeat/processors/add_host_metadata/add_host_metadata.go:222libbeat/processors/add_observer_metadata/add_observer_metadata.go:125- Receiver paths that enable host metadata processing:
x-pack/filebeat/fbreceiver/factory.go:39x-pack/metricbeat/mbreceiver/factory.go:45
Evidence
- Receiver construction applies hostname from config:
b.ApplyHostname(b.Config.Hostname, "config hostname field")(x-pack/libbeat/cmd/instance/beat.go:181)
ApplyHostnameexplicitly writes process-wide state:beat.SetHostnameOverride(h)(libbeat/cmd/instance/beat.go:824)- comment:
updates the process-wide hostname override(libbeat/cmd/instance/beat.go:818)
- Global storage is package-level singleton:
var hostnameOverride atomic.Pointer[string](libbeat/beat/info.go:32)
- Multiple runtime paths for event metadata read the same global override:
if override := beat.GetHostnameOverride(); override != "" { ... }(libbeat/publisher/processing/default.go:152-153,libbeat/processors/add_host_metadata/add_host_metadata.go:222)hostname := beat.GetHostnameOverride()(libbeat/processors/add_observer_metadata/add_observer_metadata.go:125)
What is wrong
hostname appears receiver-local in BeatReceiver config, but constructor writes it into a process-global singleton. In a single OTel Collector process with multiple BeatReceivers, one receiver’s hostname setting can silently affect other receivers.
Why it matters
This causes cross-receiver identity corruption (host.name / observer hostname fields). In multi-receiver deployments or receiver restarts/reloads, unrelated pipelines can emit events with the wrong host identity, breaking attribution and downstream routing/analysis assumptions.
Suggested fix direction
- Stop calling process-wide
beat.SetHostnameOverridefrom BeatReceiver constructor flow. - Carry hostname override in receiver/beat instance state and plumb it into processor/builtin field generation using instance-local values.
- Add regression tests that construct two receivers in one process with conflicting
hostnamevalues and assert independent emittedhost.name/ observer hostname.
Safe / already tracked context
During this sweep, previously reported global-state problems (config resolver overwrite, timestamp precision global mutation, feature flag global mutation, and filebeat initialization map-write races) were re-confirmed as already tracked by open issues and are not duplicated here.
What is this? | From workflow: Sweeper: OTel BeatReceiver Global State Isolation
Give us feedback! React with if perfect, if helpful, if not.
- expires on Oct 1, 2026, 9:39 AM UTC
Source: elastic/beats