Skip to content

HTTP probe logs full header values on validation failure when the value contains a stray @ #1449

Closed

Description

@huf1

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:

  1. 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" }
      }
    }
    
  2. Point the probe at an endpoint that returns a non-2xx status, so the validator fails.

  3. Look at the cloudprober error log.

  4. 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:

  1. 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.
  2. Honour envSecret on this path, so values explicitly marked as secrets are redacted wherever they
    would otherwise be emitted.

Activity

  1. added
    bug
    on Sep 1, 2026
  2. self-assigned this
    on Sep 2, 2026
  3. added 4 commits that reference this issue on Sep 2, 2026
    3476872
    673357e
    ab31e10
    5047cac
  4. manugarg commented on Sep 2, 2026

    @manugarg
    Contributor

    Thanks for reporting @huf1. That shortcut was really unnecessary. #1453 fixes it.

  5. added this to the v0.14.6 milestone on Sep 2, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

bug

Type

No type

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions