Skip to content

[#noissue] Drop sensitive OTel Span attributes at storage#14058

Merged
jaehong-kim merged 1 commit into
pinpoint-apm:masterfrom
jaehong-kim:fix/otlptrace-sensitive-attributes
Jul 23, 2026
Merged

[#noissue] Drop sensitive OTel Span attributes at storage#14058
jaehong-kim merged 1 commit into
pinpoint-apm:masterfrom
jaehong-kim:fix/otlptrace-sensitive-attributes

Conversation

@jaehong-kim

Copy link
Copy Markdown
Contributor

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).

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 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 OtlpSensitiveAttributeFilter to (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 stored AttributeBo entries go through the policy.
  • Harden promoted endPoint extraction 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.

Comment on lines +109 to +112
// 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.
Comment on lines +367 to +371
// 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

codecov Bot commented Jul 23, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.42424% with 5 lines in your changes missing coverage. Please review.
✅ Project coverage is 34.71%. Comparing base (f4b3e88) to head (1f07867).
⚠️ Report is 5 commits behind head on master.

Files with missing lines Patch % Lines
...collector/mapper/OtlpSensitiveAttributeFilter.java 93.87% 1 Missing and 2 partials ⚠️
.../trace/collector/mapper/OtlpAttributeBoMapper.java 83.33% 0 Missing and 2 partials ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

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>
@jaehong-kim
jaehong-kim force-pushed the fix/otlptrace-sensitive-attributes branch from c01533f to 1f07867 Compare July 23, 2026 08:36
@sonarqubecloud

Copy link
Copy Markdown

@jaehong-kim
jaehong-kim merged commit 71ba12e into pinpoint-apm:master Jul 23, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants