Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

HTTP Span Attributes: http.url must not contain username / password #2674

Closed
pellared opened this issue Mar 9, 2021 · 12 comments · Fixed by #6417
Closed

HTTP Span Attributes: http.url must not contain username / password #2674

pellared opened this issue Mar 9, 2021 · 12 comments · Fixed by #6417
Assignees
Labels
bug Something isn't working good first issue Good for newcomers

Comments

@pellared
Copy link
Member

pellared commented Mar 9, 2021

As is stated in the recent specification change :

http.url MUST NOT contain credentials passed via URL in form of https://username:[email protected]/. In such case the attribute's value should be https://www.example.com/

@mateuszrzeszutek
Copy link
Member

I don't think that otel-java contains any usage of the http.url attribute -- the javaagent is the correct place for this issue.

@pellared
Copy link
Member Author

pellared commented Mar 9, 2021

@mateuszrzeszutek I think this example could be reviewed just to make sure that others do not copy-paste potentially unsafe code.

@Hangzhi
Copy link
Contributor

Hangzhi commented Mar 31, 2021

@jkwatson @pellared Hello, I'm a student applying for Outreachy 2021 and in the process of contributing to the community. This issue seems like a good start. Could you please assign this issue to me?

@anuraaga anuraaga transferred this issue from open-telemetry/opentelemetry-java Mar 31, 2021
@anuraaga
Copy link
Contributor

Hi @Hangzhi - thanks for the help on this. You can find where we set the attribute, with no scrubbing of credentials I think, here

https://github.com/open-telemetry/opentelemetry-java-instrumentation/blob/main/instrumentation-api/src/main/java/io/opentelemetry/instrumentation/api/tracer/HttpClientTracer.java#L186

@pellared
Copy link
Member Author

pellared commented Apr 6, 2021

@Hangzhi I think you can also look at this: open-telemetry/opentelemetry-java#3118 which should be also simpler😉

@Hangzhi
Copy link
Contributor

Hangzhi commented Apr 6, 2021

@pellared Thanks! I'll work on that.

@mateuszrzeszutek mateuszrzeszutek added bug Something isn't working specification labels Jun 25, 2021
@iNikem
Copy link
Contributor

iNikem commented Oct 12, 2021

There are two ways to solve this: either to force every instrumentation to take care removing user info from the url, or put that responsibility onto HttpClientAttributesExtractor. I think the latter is much better. But then the question arises should HttpClientAttributesExtractor#url return String which we then convert to URL, check userInfo and convert back to String; or should it return URL/URI. I like the latter more. And the majority of libraries can do that, except for ApacheHttpClient instrumentations which has access only to string form of url. Thus they will have to parse it into URL/URI. But all those conversions are 95% of the time redundant, because there is now user info anyway.

@open-telemetry/java-maintainers, your thoughts?

@mateuszrzeszutek
Copy link
Member

Some HTTP clients return their own URI types - I briefly took a look at the instrumentations we have and saw Uri, GenericUrl, URIAuthority + ClassicHttpRequest (one of Apache instrumentations), URL, HttpUrl.

Just a wild idea: maybe we could add a wrapper interface HttpUrl that exposes scheme(), host(), ..., fragment() and is able to bridge all those URL implementations? So that the extractor methods could look like

public HttpUrl url(Request request) {
  java.net.URI uri = request.getUrl();
  return HttpUrl.from(uri);
}

@anuraaga
Copy link
Contributor

Using URI would be nice if we do have good representation in the instrumentations - looks like @mateuszrzeszutek has found that it may not be the case though.

Since we expect to not have to parse in most cases, I suspect we could avoid the parse and do a very simple scan to find userinfo within the String if URI seems impractical.

Not a huge fan in introducing the hundredth Java interface for URL :P

@trask
Copy link
Member

trask commented Oct 13, 2021

I suspect we could avoid the parse and do a very simple scan to find userinfo within the String

👍

@trask trask added the good first issue Good for newcomers label Jun 26, 2022
@MALPI
Copy link
Contributor

MALPI commented Jul 27, 2022

Hey folks,

I would be happy to contribute here.

@mateuszrzeszutek
Copy link
Member

Thanks! I'll assign this issue to you.

mateuszrzeszutek pushed a commit that referenced this issue Oct 7, 2022
Fixes #2674 by replacing basic auth information as part of the URL with
`username:password`.

Co-authored-by: Malte <[email protected]>
Co-authored-by: Mateusz Rzeszutek <[email protected]>
Co-authored-by: Trask Stalnaker <[email protected]>
LironKS pushed a commit to helios/opentelemetry-java-instrumentation that referenced this issue Oct 23, 2022
Fixes open-telemetry#2674 by replacing basic auth information as part of the URL with
`username:password`.

Co-authored-by: Malte <[email protected]>
Co-authored-by: Mateusz Rzeszutek <[email protected]>
Co-authored-by: Trask Stalnaker <[email protected]>
LironKS pushed a commit to helios/opentelemetry-java-instrumentation that referenced this issue Oct 31, 2022
Fixes open-telemetry#2674 by replacing basic auth information as part of the URL with
`username:password`.

Co-authored-by: Malte <[email protected]>
Co-authored-by: Mateusz Rzeszutek <[email protected]>
Co-authored-by: Trask Stalnaker <[email protected]>
LironKS pushed a commit to helios/opentelemetry-java-instrumentation that referenced this issue Dec 4, 2022
Fixes open-telemetry#2674 by replacing basic auth information as part of the URL with
`username:password`.

Co-authored-by: Malte <[email protected]>
Co-authored-by: Mateusz Rzeszutek <[email protected]>
Co-authored-by: Trask Stalnaker <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants