open-telemetry / open-telemetry/opentelemetry-java-instrumentation
Some instrumentations set url.full without applying URL sanitization
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 2.6k
- Forks
- 1.2k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 228
Description
Describe the bug
URL redaction lives inside the extractors rather than at the attribute assignment. There are exactly two production call sites:
HttpClientAttributesExtractor.stripSensitiveData— appliesredactUserInfothenUrlQuerySanitizer.redactUrl, forurl.fullInternalUrlAttributesExtractor— appliesredactQueryString, forurl.query
Any instrumentation that computes a URL itself and calls attributes.put(URL_FULL, ...) directly silently opts out of both. There's no compile error, no test failure, and no lint to catch it. Three instrumentations currently do this:
| Instrumentation | Call site |
|---|---|
| aws-lambda-events-common-2.2 | ApiGatewayProxyAttributesExtractor:67, URL assembled at L85-L97 |
| camel-2.20 | HttpSpanDecorator:101 |
| elasticsearch-rest-common-5.0 | ElasticsearchClientAttributeExtractor:56 |
Camel is the most significant of the three because it also bypasses redactUserInfo, which — unlike query parameter redaction — is not gated on any configurable list and applies unconditionally everywhere else. Semantic conventions state that url.full MUST NOT contain credentials passed as https://username:password@host/. HttpSpanDecorator.getHttpUrl returns the HTTP_URL/HTTP_URI header or a slice of endpoint.getEndpointUri(), any of which can carry userinfo.
For aws-lambda and elasticsearch, userinfo is structurally absent — the Lambda URL is built from the x-forwarded-proto/host headers, and Elasticsearch uses HttpHost.toURI() — so only query parameter redaction is missing there.
Steps to reproduce
Camel, credentials:
- Attach the javaagent to an application with a Camel HTTP route whose endpoint URI embeds credentials, e.g.
http://user:pass@backend/api. - Inspect
url.fullon the resulting span.
AWS Lambda, query parameters:
- Deploy a Lambda behind API Gateway with the javaagent.
- Invoke it with a query string containing a parameter in the configured sensitive set, e.g.
?sig=abc123. - Inspect
url.fullon the resulting span.
Expected behavior
The same output the standard extractors produce: REDACTED:REDACTED@backend/api for embedded credentials, and sig=REDACTED for sensitive query parameters.
Actual behavior
Both are emitted verbatim. The behavioral gap versus every other HTTP instrumentation is exactly the contents of the configured sensitive parameter set, plus userinfo in the Camel case.
Javaagent or library instrumentation version
main (a459b7f)
Environment
JDK: any
OS: any
Additional context
Suggested order of work, since the two fixes interact:
- Camel — javaagent-only, so
AgentCommonConfig.get()is directly reachable; it already pullsgetKnownHttpRequestMethods()from there at L49-L50. Apply redaction at the attribute assignment on line 101 only —getHttpUrl()is also consumed bygetPath()andHttpServerRoutefor span naming, which only need the path. - aws-lambda and elasticsearch — library modules with no access to agent config, so the parameter set needs threading through each builder, defaulting to
HttpConstants.SENSITIVE_QUERY_PARAMETERS, with the javaagent side wiring the configured value.
Worth pairing with #19418: the default list is currently stale, and API Gateway is where SigV4 query-string parameters are most likely to appear server-side. Fixing only the list leaves that path unprotected, since it never reaches the sanitizer; fixing only this issue means Lambda inherits a list missing the SigV4 names. Both need to land for that case to be covered.
Longer term, the root cause is that redaction is opt-in at the call site. A shared helper for setting url.full, or an ErrorProne/Checkstyle rule flagging direct put(URL_FULL, ...) outside instrumentation-api, would prevent a fourth instance.
The aws-lambda and camel call sites were reported privately by @lucianjohnhouse; the elasticsearch one and the interaction with #19418 turned up while verifying.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with HttpSpanDecorator.java, ApiGatewayProxyAttributesExtractor.java, and ElasticsearchClientAttributeExtractor.java at the direct URL_FULL assignments. Read the existing HttpClientAttributesExtractor sanitization and the Camel config access, then trace the Lambda and Elasticsearch builders. Done means the three instrumentations emit sanitized url.full values, including credential redaction for Camel and sensitive-query redaction for the other affected paths.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- observability, security
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Active
- Clarity
- Clearly specified
- Newbie friendliness
- 65/100