Fix arbitrary dll load via json injection - #2269
Merged
Merged
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
This PR aims to harden src/config.cpp against JSON injection by introducing EscapeJsonString and using it when building a JSON snippet inside SetProviderOption before parsing it with the repo’s JSON parser.
Changes:
- Added
EscapeJsonString(std::string_view)to escape caller-supplied fragments before embedding them into a JSON string literal. - Updated
SetProviderOptionto escapeprovider_name,option_name, andoption_valuebefore concatenating the JSON document. - Added
<cstdio>forstd::snprintf.
The local JSON parser (src/json.cpp) throws on any \uXXXX escape, so emitting \u00XX for C0 control characters would cause SetProviderOption to produce JSON its own parser cannot consume. Reject raw control characters (other than the shortcut-escaped \b \f \n \r \t) with a clear runtime_error instead. Removes the now-unused <cstdio> include.
apsonawane
enabled auto-merge (squash)
July 7, 2026 22:34
kunal-vaishnavi
approved these changes
Jul 8, 2026
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.
This pull request enhances the security of JSON handling in
src/config.cppby introducing a robust JSON string escaping function. This prevents potential JSON injection vulnerabilities when user-supplied values are embedded in JSON documents. The most important changes are:Security Improvements:
EscapeJsonStringfunction to safely escape all necessary characters in strings before embedding them in JSON, handling quotes, backslashes, control characters, and other non-printable characters.SetProviderOptionfunction to useEscapeJsonStringonprovider_name,option_name, andoption_valuebefore inserting them into the JSON document, preventing malicious input from altering the JSON structure.Dependency Updates:
<cstdio>header to support the use ofstd::snprintfin the new escaping function.