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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion receiver/jaegerreceiver/trace_receiver.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ package jaegerreceiver
import (
"context"
"fmt"
"html"
"io/ioutil"
"mime"
"net"
Expand Down Expand Up @@ -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.

obsreport.EndTraceDataReceiveOp(ctx, thriftFormat, 0, hErr)
return
}
Expand Down