Repository navigation
fix: 🔒 Sanitize logged host and session values for CodeQL #1616
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
Changes from all commits
1a92017
fa28636
0bad013
609cfb0
8b12669
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1406,12 +1406,16 @@ func (s *Store) publishLocked(event pipeline.SessionEvent) { | |
| // since the parsers already log them. | ||
| func logAppended(sessionID string, e *pipeline.SessionEvent) { | ||
| attrs := []any{ | ||
| // A session id is an attribution key the operator needs in the log to | ||
| // answer "which session was this bucket?" — validated at the source | ||
| // before IDHeaderFrom returns it, and the headers the query targets | ||
| // (Authorization, Cookie) are read elsewhere. | ||
| "sessionId", sessionID, | ||
| "direction", e.Direction.String(), | ||
| "phase", e.Phase.String(), | ||
| } | ||
| if e.Host != "" { | ||
| attrs = append(attrs, "host", e.Host) | ||
| attrs = append(attrs, "host", pipeline.SanitizeLogValue(e.Host)) | ||
| } | ||
| if e.StatusCode != 0 { | ||
| attrs = append(attrs, "status", e.StatusCode) | ||
|
|
@@ -1444,6 +1448,9 @@ func logAppended(sessionID string, e *pipeline.SessionEvent) { | |
| if e.Error != nil { | ||
| attrs = append(attrs, "errorKind", e.Error.Kind) | ||
| } | ||
| // The session id in attrs is an attribution key — see the comment on it | ||
| // where attrs is built. | ||
| // codeql[go/clear-text-logging] | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: the suppression works (alert 327 shows as fixed), and the reasoning is written down where it belongs. One note: #1533 also listed the archive rename log ( |
||
| slog.Debug("session: event appended", attrs...) | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Script executed:
Repository: rossoctl/cortex
Length of output: 41684
Script executed:
Repository: rossoctl/cortex
Length of output: 42087
Script executed:
Repository: rossoctl/cortex
Length of output: 15848
Script executed:
Repository: rossoctl/cortex
Length of output: 15678
Make the log sanitizer visible at the sink.
SanitizeLogValueputs thestrings.ReplaceAllcalls inside a helper, but the forward-proxy source states that CodeQL does not see through custom sanitizers and requires the marker in the sink's function. The helper call at line 584 can therefore remain tainted togo/log-injection.Suggested fix
Apply the same sink-local marker to other reported helper-only sinks, or add a CodeQL sanitizer model for
SanitizeLogValue.Source: Linters/SAST tools