Repository navigation
Description
Describe the bug
On a failed validation, the HTTP probe attaches "dynamic" headers — name and fully resolved value — to an
ERROR log line. A header is classified as dynamic by initDynamicHeaders using
strings.Contains(val, "@"), which is a single-character search rather than the @name@ token grammar
that substitution actually uses.
The result is that a header whose value merely contains an @ is treated as dynamic even though no
substitution takes place, and its value is written to the log verbatim. Header values are where credentials
live (Authorization, Cookie, API keys), so this writes secrets into the log pipeline.
In our case an API key passed as a custom header was logged in cleartext once per failed probe, purely
because the randomly generated key happened to contain one @. A second header configured identically,
whose value contained no @, was never logged. Both values were supplied via envSecret, which did not
prevent the disclosure on this path.
Cloudprober Version
Image cloudprober/cloudprober (latest, pulled 2026-09-01), running on Kubernetes.
To Reproduce
Steps to reproduce the behavior:
-
Configure an HTTP probe with a header whose value contains a single
@and no complete@name@token:probe { name: "example" type: HTTP targets { host_names: "example-service" } http_probe { protocol: HTTP relative_url: "/health" header { key: "X-Example-Api-Key" value: "{{ envSecret "EXAMPLE_API_KEY" }}" # resolves to e.g. aB3@dE7fG1hJ } } validator { name: "status_code_2xx" http_validator { success_status_codes: "200-299" } } } -
Point the probe at an endpoint that returns a non-2xx status, so the validator fails.
-
Look at the cloudprober error log.
-
See the header value in cleartext:
level=ERROR source=probes/http/http.go:381 msg="failed validations: status_code_2xx" \ system=cloudprober probe=example target=example-service url=http://example-service/health \ X-Example-Api-Key=aB3@dE7fG1hJ
Expected: the failed-validation line should not contain the header value. No substitution occurred, so the
attribute carries no diagnostic information in this case.
Additional context
Root cause — detection and substitution use different grammars.
probes/http/request.go, initDynamicHeaders:
if !strings.Contains(val, "@") {
return
}Substitution is performed by strtemplate.SubstituteLabels(), which only matches complete @name@ pairs.
So a value with one stray @ is classified as dynamic, substituted to itself, and then logged.
The same file already acknowledges this gap for the Host header:
Host header value %q contains '@' but Host substitution is not supported; value will be sent verbatim
probes/http/http.go, failed-validation path:
if len(failedValidations) > 0 {
msg := fmt.Sprintf("failed validations: %s", strings.Join(failedValidations, ","))
l.WithAttributes(p.dynamicHeaderAttrs(req)...).Error(msg)
return errors.New(msg)
}Impact: logs are usually shipped to an aggregation system with broader read access than the secret store the
credential came from, so this effectively republishes a secret at a lower trust level.
Possible fixes — any one resolves the disclosure; the first two seem closest to the original intent:
- Match the token grammar in detection. Require a complete
@name@for a known token before marking a
header dynamic. A value with no resolvable token is not dynamic and needs no attribute. - Honour
envSecreton this path, so values explicitly marked as secrets are redacted wherever they
would otherwise be emitted.
Activity
[probes.http] Only treat a header as dynamic if it carries a real token
[probes.http] Only treat a header as dynamic if it carries a real token
[probes.http] Only treat a header as dynamic if it carries a real token
[probes.http] Only treat a header as dynamic if substitution changes …
manugarg commentedon Sep 2, 2026
Thanks for reporting @huf1. That shortcut was really unnecessary. #1453 fixes it.