Repository navigation
fix(security): redact caller query params and escape control chars in logs [SEC-2535] - #135
Merged
oliverlaz merged 4 commits intoNov 27, 2026
Conversation
…-2535-sec-21-logging-redactioncrlf-ruby
oliverlaz
marked this pull request as ready for review
November 25, 2026 12:39
mogita
approved these changes
Nov 27, 2026
oliverlaz
enabled auto-merge (squash)
November 27, 2026 15:23
oliverlaz
deleted the
oliverlazoroski/sec-2535-sec-21-logging-redactioncrlf-ruby
branch
November 27, 2026 15:24
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes the Ruby part of SEC-2535 (audit finding SEC-21, severity Low).
Problem
make_requestbaked caller query params into thepathstring, sohttp.request.sentlogged them insideurl.path, whereLogRedaction.redact_querynever ran. Only the SDK's ownapi_key(inurl.query) was redacted.log_bodies) were interpolated verbatim, so a value containing CR/LF could forge extra log lines (log injection). Path params are interpolated unencoded by the generated clients, and thehttp.request.sentline is emitted before Faraday rejects such a URL.Fix
make_requestkeeps query params as a Hash (values serialized but not URL-encoded) and hands them torequest, which merges inapi_key(the SDK's key still wins) and passes them to Faraday, which encodes them. Wire format is unchanged: Faraday already re-parsed and re-encoded the old path query string. Logging now sees the merged hash, soredact_querycovers caller params (token,api_key,api_secret).LogRedaction.sanitizeescapes every control character (C0, DEL, C1, U+2028/2029) to its escaped form (\r,\n,\e, ...) and scrubs invalid UTF-8. Every request log line (sent / received / failed / retry) and the pool fallback warning go through it.url.pathalso goes throughredact_message, so a caller-built path likepost('/x?token=...')is scrubbed too.Authorizationheader and the JWT were never logged; a spec now pins that.Tests
make test(341 examples, 0 failures) andmake lint(rubocop: no offenses) pass locally on Ruby 4.0. New specs inspec/logging_spec.rbcover caller-param redaction, a caller-built path, no Authorization/JWT in logs, CR/LF in path/query/body/error message, and thesanitizehelper. The CR/LF specs fail whensanitizeis stubbed out.