Repository navigation
fix: Reject an SDK key or mobile key that contains a line break - #649
Open
kinyoklion wants to merge 1 commit into
Open
kinyoklion wants to merge 1 commit into
kinyoklion wants to merge 1 commit into
Conversation
Generated-by: termag
There was a problem hiding this comment.
Automated risk review (dry run): Medium
This PR would not be automatically approved. Human approval required.
Why: libs/common/src/config/config_builder.cpp and libs/server-sdk/src/config/config_builder.cpp now reject SDK or mobile keys containing CR/LF, which is an authentication-credential validation change and is never Low.
Sent by Cursor Approval Agent: Dry-Run PR Approver
This branch has not been deployed
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.


A key that contained a carriage return or line feed, for example a key read from a file with a trailing newline, went raw into the Authorization header of every request. That corrupted the request and could add other headers to it. In the server and the client SDK, ConfigBuilder::Build now returns the new error kConfig_SDKKey_InvalidCharacters for such a key. I chose this because it is the existing handling for an invalid key (an empty key returns kConfig_SDKKey_Empty): the application gets the error when it builds the configuration, and the SDK never sends the key.
Behavior change: a configuration with a key that ends in a newline no longer builds.
Testing: Tested on 25cef983, before the rebase onto main. New config builder tests for keys with a carriage return, a line feed or an added header fail before the change and pass after it. The harness test for a credential with an embedded header changes from fail to pass in the server and the client. The full contract suites, with Beast and with CURL, show no other change.
SDK-3659
Opened from termag
Note
Overview
Config build now rejects SDK and mobile keys that contain a carriage return or line feed, closing a path where such keys (e.g. from a file with a trailing newline) could break the
Authorizationheader or inject extra headers on outbound requests.Both the shared client
ConfigBuilderand the serverConfigBuilderfailBuild()with the newkConfig_SDKKey_InvalidCharacterserror (with a matchingErrorToStringmessage), alongside existing empty-key handling. Behavior change: a key that previously built but ended with\nor\rwill no longer produce a config. New unit tests cover\n,\r, and a crafted\r\nheader-injection pattern on client and server builders.Reviewed by Cursor Bugbot for commit c4cd317. Bugbot is set up for automated code reviews on this repo. Configure here.