Skip to content

[surfacers.otel] Panic when exporter is configured with tls_config #1493

Closed

Description

@manugarg

What happened

The OTEL surfacer panics at startup if its exporter is configured with a tls_config block that sets any field.

Both exporter branches pass nil to tlsconfig.UpdateTLSConfig instead of the tls.Config they just allocated:

https://github.com/cloudprober/cloudprober/blob/main/internal/surfacers/otel/otel.go#L90-L96 (HTTP, line 92)
https://github.com/cloudprober/cloudprober/blob/main/internal/surfacers/otel/otel.go#L127-L133 (gRPC, line 129)

if expConf.GetTlsConfig() != nil {
    tlsConfig := &tls.Config{}
    err := tlsconfig.UpdateTLSConfig(nil, expConf.GetTlsConfig())  // should be tlsConfig
    ...
    opts = append(opts, otlpmetricgrpc.WithTLSCredentials(credentials.NewTLS(tlsConfig)))
}

UpdateTLSConfig writes to its first argument as soon as any config field is set (common/tlsconfig/tlsconfig.go:67), so this is a nil dereference.

There are two failure modes:

  1. Panic — if tls_config sets disable_cert_validation, ca_cert_file, tls_cert_file, server_name, or min_tls_version.
  2. Silently ignored TLS config — if tls_config {} is present but empty, nothing is dereferenced, and the exporter is built from an empty tls.Config. The configured settings never take effect.

Config to reproduce

surfacer {
  type: OTEL
  otel_surfacer {
    otlp_grpc_exporter {
      endpoint: "localhost:4317"
      tls_config { disable_cert_validation: true }
    }
  }
}

Stack trace

panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0xa0]

github.com/cloudprober/cloudprober/common/tlsconfig.UpdateTLSConfig(...)
	common/tlsconfig/tlsconfig.go:67
github.com/cloudprober/cloudprober/internal/surfacers/otel.getExporter(...)
	internal/surfacers/otel/otel.go:129

(Reproduced against main at b40d714 by calling getExporter directly with the config above; the HTTP branch at line 92 fails the same way.)

Fix

Pass tlsConfig in both places. Worth a small test covering each exporter branch with a non-empty tls_config, since an empty one doesn't fail.

Noticed while reviewing #1358 — internal/tracing/tracing.go in that PR does the equivalent thing correctly, so the tracing path is not affected.

Activity

  1. self-assigned this
    on Sep 22, 2026
  2. added a commit that references this issue on Sep 23, 2026
    4e73121
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

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