Skip to content

fix(erpc:PLA-1611): redact grpc and remote cache secrets#95

Open
0x666c6f wants to merge 2 commits into
morpho-mainfrom
feature/pla-1611-fail-closed-and-redact-secrets-in-erpc-auth-tracing-admin
Open

fix(erpc:PLA-1611): redact grpc and remote cache secrets#95
0x666c6f wants to merge 2 commits into
morpho-mainfrom
feature/pla-1611-fail-closed-and-redact-secrets-in-erpc-auth-tracing-admin

Conversation

@0x666c6f

@0x666c6f 0x666c6f commented Jun 24, 2026

Copy link
Copy Markdown
Collaborator

Summary

  • Redact gRPC upstream header values when configs are marshaled to JSON/YAML for admin/startup surfaces.
  • Redact provider-backed remote-cache keys before async refresh warning/panic logs.
  • Add regression coverage for gRPC config redaction and race-safe remote-cache failure logging.

Validation

  • go test ./common ./thirdparty
  • go test -race ./thirdparty
  • Full make agent-gate blocked locally by rootless Docker not found in container-backed tests.

Linear

Copilot AI review requested due to automatic review settings June 24, 2026 11:37

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR tightens secret redaction across two “admin/startup/logging” surfaces: gRPC upstream header configs when marshaled to JSON/YAML, and remote-cache keys in async refresh failure/panic logs.

Changes:

  • Redact GrpcUpstreamConfig.Headers values during JSON/YAML marshaling.
  • Redact RemoteDataCache async refresh cacheKey in warning/panic logs.
  • Add regression tests covering gRPC config redaction and remote-cache refresh-failure logging.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
thirdparty/remote_cache.go Redacts logged cacheKey using util.RedactEndpoint in async refresh error/panic logs.
thirdparty/remote_cache_test.go Adds regression test asserting refresh-failure logs don’t leak raw cache keys/secrets.
common/config.go Adds custom JSON/YAML marshaling for GrpcUpstreamConfig to redact header values.
common/config_redaction_test.go Adds tests asserting gRPC headers + endpoint secrets are redacted across JSON/Sonic/YAML outputs.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +17 to +40
prevLevel := zerolog.GlobalLevel()
zerolog.SetGlobalLevel(zerolog.WarnLevel)
defer zerolog.SetGlobalLevel(prevLevel)

var logs bytes.Buffer
logger := zerolog.New(&logs)
cache := NewRemoteDataCache[string]("quicknode")
cacheKey := "https://example.quiknode.pro/raw-provider-secret/evm?apiKey=provider-api-key"
fetchCalled := make(chan struct{})

cache.TriggerAsyncRefresh(&logger, cacheKey, func(ctx context.Context) (string, error) {
close(fetchCalled)
return "", errors.New("refresh failed")
})

select {
case <-fetchCalled:
case <-time.After(time.Second):
t.Fatal("fetcher was not called")
}

require.Eventually(t, func() bool {
return strings.Contains(logs.String(), "vendor remote-data refresh failed")
}, time.Second, 10*time.Millisecond)
Comment thread common/config.go
Comment on lines +1210 to +1225
func (c *GrpcUpstreamConfig) MarshalJSON() ([]byte, error) {
type grpcUpstreamConfigJSON struct {
Headers map[string]string `json:"headers,omitempty"`
}
return sonic.Marshal(grpcUpstreamConfigJSON{
Headers: redactHeaderValues(c.Headers),
})
}

func (c *GrpcUpstreamConfig) MarshalYAML() (interface{}, error) {
out := make(map[string]interface{})
if len(c.Headers) > 0 {
out["headers"] = redactHeaderValues(c.Headers)
}
return out, nil
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants