Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions server/cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,9 +136,12 @@ func main() {
// Optional OTLP export sink. Independent of S2; both can run together.
var otlpWriter *events.OTLPStorageWriter
if config.OTLPEndpoint != "" {
// The relay authenticates the VM by its instance name (checked against
// active sessions), mirroring the capmonster/hcaptcha relays. Sent as
// x-api-key, not a bearer token.
headers := map[string]string{}
if config.InstanceJWT != "" {
headers["Authorization"] = "Bearer " + config.InstanceJWT
if config.InstanceName != "" {
headers["x-api-key"] = config.InstanceName

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Stale OTLP auth after fork

High Severity

The new relay auth header is taken from config.InstanceName once at process start. In fork-identity-wait mode, kernel-images-api starts before identity apply and is intentionally not restarted, so x-api-key stays empty or wrong after the instance is bound and relay exports keep failing auth.

Additional Locations (1)
Fix in Cursor Fix in Web

Reviewed by Cursor Bugbot for commit ec5597d. Configure here.

}
slogger.Info("OTLP export enabled", "endpoint", config.OTLPEndpoint, "path", config.OTLPPath)
otlpWriter = events.NewOTLPStorageWriter(eventStream, events.OTLPConfig{
Expand Down
15 changes: 5 additions & 10 deletions server/cmd/config/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,11 @@ type Config struct {
OTLPPath string `envconfig:"BTEL_OTLP_PATH" default:"/v1/logs"`
OTLPInsecure bool `envconfig:"BTEL_OTLP_INSECURE" default:"false"`
OTLPServiceName string `envconfig:"BTEL_OTLP_SERVICE_NAME" default:"kernel-browser"`
// Platform-injected identity, reused to stamp the OTLP Resource. These are
// the same envs the VM already receives.
InstanceJWT string `envconfig:"KERNEL_INSTANCE_JWT" default:""`
InstanceName string `envconfig:"INST_NAME" default:""`
MetroName string `envconfig:"METRO_NAME" default:""`
// Platform-injected identity: InstanceName is sent to the relay as x-api-key
// and, with MetroName, stamps the OTLP Resource. Same envs the VM already
// receives.
InstanceName string `envconfig:"INST_NAME" default:""`
MetroName string `envconfig:"METRO_NAME" default:""`
}

// LogValue implements slog.LogValuer, redacting secret fields.
Expand All @@ -73,10 +73,6 @@ func (c *Config) LogValue() slog.Value {
if c.S2AccessToken != "" {
s2AccessToken = "[redacted]"
}
otlpJWT := ""
if c.InstanceJWT != "" {
otlpJWT = "[redacted]"
}
return slog.GroupValue(
slog.Int("port", c.Port),
slog.Int("metrics_port", c.MetricsPort),
Expand All @@ -99,7 +95,6 @@ func (c *Config) LogValue() slog.Value {
slog.String("otlp_endpoint", c.OTLPEndpoint),
slog.String("otlp_path", c.OTLPPath),
slog.Bool("otlp_insecure", c.OTLPInsecure),
slog.String("otlp_instance_jwt", otlpJWT),
slog.String("otlp_service_name", c.OTLPServiceName),
slog.String("otlp_instance_name", c.InstanceName),
slog.String("otlp_metro", c.MetroName),
Expand Down
Loading