Skip to content

File provider logs the URL password in clear text for http(s) file_path #1529

Open

Description

@igorsilva-dev

Version: v0.14.6

Problem

The file provider (file_targets and the RDS file provider, internal/rds/file/file.go) accepts an http:// or https:// value in file_path.

The provider config has no auth or header field. The only way to send HTTP Basic auth on this fetch is userinfo in the URL: http://user:password@host/path. Go's HTTP client turns the userinfo into an Authorization: Basic header.

The provider then logs file_path as it is, with the password. I hit this when I used a password-protected target-list URL.

Affected lines in internal/rds/file/file.go (same on v0.14.6 and main):

Line Level Message
200 INFO file_provider(%s): Read %d endpoints
176 INFO file(%s): Skipping reloading file as it has not changed ...
165 WARN file(%s): Error getting modified time: ...
135, 141, 155, 182, 197 error returns The error text includes the path. The caller logs it at ERROR via lines 257 (first refresh) and 270 (refresh loop).

Go's net/http already masks the password in its own errors (user:***@). So one log line can show both forms: the raw password from the provider's %s, and *** from the Go error. See the WARN and ERROR lines below.

Minimal reproduction

Serve a target file over local HTTP. Any server works. I used Python's http.server on port 8080.

Config:

probe {
  name: "p"
  type: PING
  targets {
    file_targets {
      file_path: "http://user:fakepass@localhost:8080/targets.textpb"
      re_eval_sec: 3
    }
  }
  interval_msec: 2000
  timeout_msec: 1000
}

targets.textpb holds one resource:

resource { name: "example" }

Run:

./cloudprober --config_file cfg.cfg --logtostderr

The server receives Authorization: Basic dXNlcjpmYWtlcGFzcw==. So the userinfo works as Basic auth.

Log lines, server up (INFO):

level=INFO source=internal/rds/file/file.go:200 msg="file_provider(http://user:fakepass@localhost:8080/targets.textpb): Read 1 endpoints"
level=INFO source=internal/rds/file/file.go:176 msg="file(http://user:fakepass@localhost:8080/targets.textpb): Skipping reloading file as it has not changed since its last refresh at ..."

The Skipping line repeats at every re_eval_sec.

Log lines, server stopped (WARN and ERROR):

level=WARN source=internal/rds/file/file.go:165 msg="file(http://user:fakepass@localhost:8080/targets.textpb): Error getting modified time: Head \"http://user:***@localhost:8080/targets.textpb\": dial tcp [::1]:8080: connect: connection refused; Ignoring modified time check."
level=ERROR source=internal/rds/file/file.go:257 msg="file(http://user:fakepass@localhost:8080/targets.textpb): error while reading file: Get \"http://user:***@localhost:8080/targets.textpb\": dial tcp [::1]:8080: connect: connection refused"

Log line, file served but not valid text proto (ERROR):

level=ERROR source=internal/rds/file/file.go:257 msg="file_provider(http://user:fakepass@localhost:8080/bad.textpb): error unmarshaling as text proto: proto: (line 1:22): unknown field: bogus_field"

Expected behaviour

  • The password in URL userinfo is masked in log and error messages. For example, use url.Redacted(): http://user:xxxxx@localhost:8080/targets.textpb.
  • Masking applies to http and https values only.
  • Other values stay unchanged: gs://, s3:// and local paths.
  • The fetch keeps using the raw URL. Only the text in messages changes.

Related items

I searched issues and PRs for "password", "redact", "mask", "credential", "userinfo", "basic auth" and "file_provider". I found no issue about the file provider.

PR #1478 ("[http] Hide URL passwords in error messages, and use it for proxy_url") looks related. It is closed and not merged. I do not know the reason. Is a different approach preferred?

I did not search Discussions.

Other code paths

Other places also log a user-configured URL or path with %s or %q. This report focuses on the file provider. For reference, in v0.14.6:

  • internal/rds/file/file.go:298 (RDS server path)
  • probes/grpc/grpc.go:307 (body_file)
  • probes/sql/sql.go:131 (query_file)
  • probes/http/http.go:135 (proxy_url)
  • internal/alerting/notifier/http_notifier.go:49 (notifier URL)
  • internal/otel/exporter.go:48-54 (endpoint_url)

I did not test these. They only matter if a user puts userinfo in the value.

Question

Where should the fix live?

  1. In the file provider only (internal/rds/file/file.go), with a masked copy of the path used in messages.
  2. In internal/file.
  3. At logger level.
  4. By reuse of an existing helper.

I can send a small PR with a test in internal/rds/file/file_test.go once you agree on the approach. I will not open one before that.

Activity

  1. manugarg commented on Oct 6, 2026

    @manugarg
    Contributor

    I guess we don't see this issue being reported by anyone because basic authentication is pretty much unheard of now.

  2. igorsilva-dev commented on Oct 6, 2026

    @igorsilva-dev
    Author

    Thanks for replying @manugarg
    Fair point. Basic auth is the only auth the file provider supports for http(s) file_path, so for these users it is the only choice. Would you accept a small PR that masks the userinfo password in these log lines, with the fix in the file provider only? If you prefer a different direction, such as an auth or header option on the provider, I am happy to follow that.

  3. manugarg commented on Nov 11, 2026

    @manugarg
    Contributor

    Thanks, yes, please send the PR. Keep it in the file provider only (option 1): compute a redacted display path once in newLister (url.Redacted() for http/https, unchanged otherwise), use it in log and error messages, and keep using the raw path for fetching. A small table test in file_test.go is enough. Please leave the other code paths out of this PR.

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

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions