[#noissue] Drop sensitive OTel Span attributes at storage#14058
Conversation
There was a problem hiding this comment.
Pull request overview
This PR introduces a fixed, non-configurable security policy to prevent sensitive OpenTelemetry span/span-event attribute data (headers/metadata, bodies, credentials, URL components, end-user/tenant identifiers, etc.) from ever reaching Pinpoint storage by filtering/sanitizing at the attribute serialization point.
Changes:
- Add
OtlpSensitiveAttributeFilterto (a) drop sensitive attribute keys and (b) sanitize URL-valued attributes by stripping query/fragment/userinfo. - Apply the filter/sanitization in
OtlpAttributeBoMapper.toAttributeBoList()so all storedAttributeBoentries go through the policy. - Harden promoted
endPointextraction by stripping userinfo from URLs and update/add tests to assert sanitization behavior.
Reviewed changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| otlptrace/otlptrace-collector/src/main/java/com/navercorp/pinpoint/otlp/trace/collector/mapper/OtlpSensitiveAttributeFilter.java | New fixed sensitive-key filter + URL value sanitization logic. |
| otlptrace/otlptrace-collector/src/main/java/com/navercorp/pinpoint/otlp/trace/collector/mapper/OtlpAttributeBoMapper.java | Enforces sensitive-key drop + URL sanitization during AttributeBo list creation. |
| otlptrace/otlptrace-collector/src/main/java/com/navercorp/pinpoint/otlp/trace/collector/mapper/OtlpTraceSpanMapper.java | Strips userinfo from host extraction so credentials don’t get promoted into endPoint. |
| otlptrace/otlptrace-collector/src/test/java/com/navercorp/pinpoint/otlp/trace/collector/mapper/OtlpSensitiveAttributeFilterTest.java | New unit tests for sensitive key detection and URL sanitization behavior. |
| otlptrace/otlptrace-collector/src/test/java/com/navercorp/pinpoint/otlp/trace/collector/mapper/OtlpTraceSpanMapperTest.java | Updates existing mapping test to assert URL attribute sanitization + userinfo stripping. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // Every attribute under these prefixes is dropped — headers/metadata are never stored. | ||
| // gRPC metadata is captured under rpc.grpc.request/response.metadata.<name> | ||
| // (CapturedGrpcMetadataUtil); the generic rpc.request/response.metadata.* variants are kept for | ||
| // any other RPC system that follows the semconv naming. |
| // Strip userinfo ("user:pass@") so credentials never leak into the promoted endPoint. | ||
| int userInfoEnd = url.lastIndexOf('@', end - 1); | ||
| if (userInfoEnd >= start) { | ||
| start = userInfoEnd + 1; | ||
| } |
Codecov Report❌ Patch coverage is Additional details and impacted files@@ Coverage Diff @@
## master #14058 +/- ##
============================================
+ Coverage 34.67% 34.71% +0.04%
- Complexity 12320 12353 +33
============================================
Files 4204 4205 +1
Lines 99910 99973 +63
Branches 10701 10720 +19
============================================
+ Hits 34644 34707 +63
+ Misses 62323 62318 -5
- Partials 2943 2948 +5 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Filter security-sensitive information out of OTel Span / SpanEvent attributes at the point they are stored, so it never reaches Pinpoint storage. A collector exposes no per-attribute redaction settings, so the policy is fixed. - OtlpSensitiveAttributeFilter (new): isSensitive(key) drops HTTP headers, gRPC/RPC metadata and messaging headers, request/response bodies, credentials (incl. db.connection_string and db.user), DB bind parameters, URL query/fragment/userinfo component keys, and end-user/ tenant identifiers (enduser.id/role/scope, user, tenant); sanitizeUrl strips query/fragment/userinfo from url.full / http.url / http.target values. - Applied in OtlpAttributeBoMapper.toAttributeBoList, the single Span / SpanEvent attribute serializer. Span Event and Span Link attributes use a separate JSON serializer and are intentionally out of scope. - OtlpTraceSpanMapper.extractHostAndPort strips userinfo so credentials cannot leak into the promoted endPoint. The gRPC metadata prefix (rpc.grpc.request/response.metadata.), enduser role/scope and db.user were identified by reviewing the opentelemetry-java-instrumentation attribute emitters. db.statement/SQL and exception message/stacktrace are out of scope (handled elsewhere). Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
c01533f to
1f07867
Compare
|



Filter security-sensitive information out of OTel Span / SpanEvent attributes at the point they are stored, so it never reaches Pinpoint storage. A collector exposes no per-attribute redaction settings, so the policy is fixed.
The gRPC metadata prefix (rpc.grpc.request/response.metadata.), enduser role/scope and db.user were identified by reviewing the opentelemetry-java-instrumentation attribute emitters. db.statement/SQL and exception message/stacktrace are out of scope (handled elsewhere).