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

Escape user input used in output #2815

Merged

Conversation

jpkrohling
Copy link
Member

Description:
Escape the error message sent to clients, containing user-provided input.

Theoretically, this could allow an attacker to perform a reflected cross-site scripting attack. In my view, this would be hardly exploitable, as the Jaeger Receiver has Jaeger Client as the only clients, and browsers would have to be tricked into making requests directly to it with the bad payload. On the way out, the browser would interpret the Jaeger Receiver as a single domain, as each protocol is on its own port. No session data, or any other type of senstive information, would be available for the attacker to extract.

In any case, this here fixes the theoretical case, especially to prevent this from being used in a composite attack in a scenario that I can't think of...

Signed-off-by: Juraci Paixão Kröhling <[email protected]>
@jpkrohling jpkrohling requested a review from a team March 26, 2021 09:31
@codecov
Copy link

codecov bot commented Mar 26, 2021

Codecov Report

Merging #2815 (439b353) into main (e3c5965) will not change coverage.
The diff coverage is 0.00%.

Impacted file tree graph

@@           Coverage Diff           @@
##             main    #2815   +/-   ##
=======================================
  Coverage   91.67%   91.67%           
=======================================
  Files         293      293           
  Lines       15635    15635           
=======================================
  Hits        14333    14333           
  Misses        891      891           
  Partials      411      411           
Impacted Files Coverage Δ
receiver/jaegerreceiver/trace_receiver.go 75.49% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3c5965...439b353. Read the comment docs.

@@ -441,7 +442,7 @@ func (jr *jReceiver) HandleThriftHTTPBatch(w http.ResponseWriter, r *http.Reques

batch, hErr := jr.decodeThriftHTTPBody(r)
if hErr != nil {
http.Error(w, hErr.msg, hErr.statusCode)
http.Error(w, html.EscapeString(hErr.msg), hErr.statusCode)
Copy link
Member

Choose a reason for hiding this comment

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

nit: (Morally) shouldn't this be also done below on the consumeTraces error too? I don't think it poses a security risk now but it's better to be safe than sorry

Copy link
Member Author

Choose a reason for hiding this comment

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

We are doing this here because this error message might include user-provided input, namely, the content-type header which is returned embedded into the errors from lines 411 and 417 from decodeThriftHTTPBody. The one you mentioned doesn't seem to embed any user-provided input.

Copy link
Member

Choose a reason for hiding this comment

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

The one you mentioned doesn't seem to embed any user-provided input.

Sure, not saying it does, just that it's easier/safer to escape things everywhere rather than doing it on a per-case basis. Just being nitpicky, feel free to dismiss this :)

Copy link
Member Author

Choose a reason for hiding this comment

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

There was a warning about this specific instance in an automated security checking tool, so I would like to fast-track it. But in general, I'd agree that everything that goes back to clients should be properly escaped. Perhaps we could have a broader discussion/guideline for this, as I suspect other components might be affected too.

@jpkrohling
Copy link
Member Author

The check failures don't seem to be related to this change.

@bogdandrutu bogdandrutu merged commit 4daf2a1 into open-telemetry:main Mar 26, 2021
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.

3 participants