Skip to content

fix(http): redact credentials in request logs (CodeQL clear-text logging) - #328

Merged
adityathebe merged 2 commits into
masterfrom
claude/codeql-security-reports-0hcmb9
Jul 17, 2026
Merged

fix(http): redact credentials in request logs (CodeQL clear-text logging)#328
adityathebe merged 2 commits into
masterfrom
claude/codeql-security-reports-0hcmb9

Conversation

@adityathebe

Copy link
Copy Markdown
Member

Summary

Addresses the two open CodeQL code-scanning alerts on master:

Alert Location Resolution
#41 — Clear-text logging of sensitive information http/middlewares/logger.go Fixed in code
#43 — Use of a broken or weak cryptographic hashing algorithm http/digest.go Documented — protocol-mandated, dismiss as Won't fix

#41 — Clear-text logging (fixed)

The HTTP logging middleware wrote request URLs and transport errors verbatim. When a URL carries userinfo (https://user:pass@host) — or a transport error wraps such a URL — the embedded password was written to the logs in clear text.

  • Log req.URL via URL.Redacted(), which masks the userinfo password, at every log sink in jsonLogger.
  • accessURL() now returns URL.Redacted() too (it previously only stripped the query/fragment, leaving userinfo intact).
  • Transport error strings are passed through logger.StripSecrets(...) before logging, so credentials embedded in a wrapped url.Error are redacted.

The header/body/query/form values reaching these log calls were already sanitized (SanitizeHeaders, StripSecretsFromMap, IsSensitiveKey); the URL and error paths were the remaining gap.

#43 — MD5 in Digest auth (won't fix)

The flagged md5.New() is HTTP Digest Authentication (RFC 7616), where MD5 is the protocol-mandated default and the algorithm is chosen by the server, not the client. Many servers only offer MD5, so removing it would break authentication against them. SHA-256 is already used whenever the server advertises it.

This is a known false positive for digest auth. Rather than change behavior, this PR adds a doc comment on hashStr explaining why MD5 is retained. The alert should be dismissed in the Security tab as Won't fix / used as required by protocol.

Testing

  • go build ./... and go vet ./http/... pass.
  • Offline digest tests (TestDigestTransport, TestParseWWWAuthenticate, TestDigestAuthString, …) and the full logger package tests pass. The remaining TestHTTP failures are unrelated — they require outbound network access to external hosts, which is blocked in the CI sandbox.

Note (out of scope)

http/middlewares/trace.go:254 also sets req.URL.String() as an OpenTelemetry span attribute, which has the same userinfo-leak shape but was not flagged by CodeQL. Happy to redact it in a follow-up if desired.

🤖 Generated with Claude Code

https://claude.ai/code/session_013n3Z8YwzdNdmCPCVHhiwgo


Generated by Claude Code

@CLAassistant

CLAassistant commented Jul 17, 2026

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you all sign our Contributor License Agreement before we can accept your contribution.
1 out of 2 committers have signed the CLA.

✅ adityathebe
❌ claude
You have signed the CLA already but the status is still pending? Let us recheck it.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@adityathebe, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 42 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: e4aa964a-e677-4384-bcf9-b8ddc6c407ff

📥 Commits

Reviewing files that changed from the base of the PR and between bda2a73 and ee69198.

📒 Files selected for processing (3)
  • files/files.go
  • http/digest.go
  • http/middlewares/logger.go
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch claude/codeql-security-reports-0hcmb9
✨ Simplify code
  • Create PR with simplified code
  • Commit simplified code in branch claude/codeql-security-reports-0hcmb9

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Jul 17, 2026

Copy link
Copy Markdown

Gavel summary

Source Pass Fail Skip Duration
collections 49 0 0 3.0s
files 41 0 0 78ms
github.com/flanksource/commons/certs 4 0 0 1.4s
github.com/flanksource/commons/cmd/hx 8 0 0 -
github.com/flanksource/commons/cmd/hx/parse 26 0 0 -
github.com/flanksource/commons/collections/syncmap 10 0 0 -
github.com/flanksource/commons/context 1 0 0 -
github.com/flanksource/commons/duration 2 0 0 -
github.com/flanksource/commons/files 16 0 0 -
github.com/flanksource/commons/har 30 0 0 20ms
github.com/flanksource/commons/hash 13 0 0 -
github.com/flanksource/commons/http 95 0 2 11.7s
github.com/flanksource/commons/logger 49 0 0 10ms
github.com/flanksource/commons/logger/httpretty/internal/color 15 0 0 -
github.com/flanksource/commons/logger/httpretty/internal/header 1 0 0 -
github.com/flanksource/commons/lookup 7 0 0 -
github.com/flanksource/commons/test 5 0 1 20ms
github.com/flanksource/commons/text 1 0 0 -
github.com/flanksource/commons/tokenizer 3 0 0 -
logger 41 0 0 1ms
set 7 0 0 465.658µs

Totals: 424 passed · 0 failed · 3 skipped · 16.2s

View full results

…ing)

The HTTP logging middleware wrote request URLs and transport errors to
logs verbatim. When a URL carries userinfo (https://user:pass@host) or a
transport error wraps such a URL, the embedded password was logged in
clear text — the "Clear-text logging of sensitive information" alert at
http/middlewares/logger.go.

- Log req.URL via URL.Redacted(), which masks the userinfo password.
- accessURL() now returns URL.Redacted() as well.
- Run transport error strings through logger.StripSecrets before logging.

Also document why MD5 is retained in http/digest.go: HTTP Digest auth
(RFC 7616) mandates MD5 as the default algorithm and the server selects
it, so it cannot be removed without breaking interoperability. SHA-256 is
already used whenever the server offers it. The weak-hash alert there is a
known false positive for digest authentication.
@adityathebe
adityathebe force-pushed the claude/codeql-security-reports-0hcmb9 branch from 62859de to 24f1f3b Compare July 17, 2026 05:52
@adityathebe
adityathebe enabled auto-merge (squash) July 17, 2026 05:59
Go 1.25.12 changed os.Root.MkdirAll to reject paths with a trailing
slash, returning "mkdirat <path>: no such file or directory". Unarchive
passed raw tar/zip entry names (e.g. "subdir/", "./subdir3/") straight to
root.MkdirAll, so directory extraction failed on that toolchain — while
1.25.1 through 1.25.11 accepted the same paths.

Normalize the entry name with filepath.Clean before creating the
directory. The value recorded in Archive.Directories is left unchanged so
the reported path format is preserved. Verified against go1.25.1 and
go1.25.12 (all files specs pass on both).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_013n3Z8YwzdNdmCPCVHhiwgo
@adityathebe
adityathebe merged commit 2bd9574 into master Jul 17, 2026
10 of 11 checks passed
@adityathebe
adityathebe deleted the claude/codeql-security-reports-0hcmb9 branch July 17, 2026 06:34
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