Skip to content

fix: Reject an SDK key or mobile key that contains a line break - #649

Open
kinyoklion wants to merge 1 commit into
mainfrom
rlamb/sdk-3659/credential-line-break
Open

kinyoklion wants to merge 1 commit into
mainfrom
rlamb/sdk-3659/credential-line-break

Conversation

@kinyoklion

@kinyoklion kinyoklion commented Nov 17, 2026 •

Copy link
Copy Markdown
Member

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 Authorization header or inject extra headers on outbound requests.

Both the shared client ConfigBuilder and the server ConfigBuilder fail Build() with the new kConfig_SDKKey_InvalidCharacters error (with a matching ErrorToString message), alongside existing empty-key handling. Behavior change: a key that previously built but ended with \n or \r will no longer produce a config. New unit tests cover \n, \r, and a crafted \r\n header-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.

@kinyoklion
kinyoklion marked this pull request as ready for review November 17, 2026 23:45
@kinyoklion
kinyoklion requested a review from a team as a code owner November 17, 2026 23:45
@cursor cursor Bot added the risk:medium label Nov 17, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Open in Web View Automation 

Sent by Cursor Approval Agent: Dry-Run PR Approver

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant