Validate account/ident type in gateway_balances#7655
Open
luisfernandomendozav wants to merge 1 commit into
Open
Validate account/ident type in gateway_balances#7655luisfernandomendozav wants to merge 1 commit into
luisfernandomendozav wants to merge 1 commit into
Conversation
|
If only the most recent commit is unsigned, you can run:
If multiple commits are unsigned, you can run:
If you're new to commit signing, there are different ways to set it up: Sign commits with
|
The gateway_balances handler called asString() on the account and ident parameters without first checking they are strings. A non-string value (number, object, array) made JsonCpp throw a Json::LogicError, which surfaced to the client as a confusing rpcINTERNAL error. Reject non-string account/ident up front with rpcINVALID_PARAMS, matching the existing hotwallet handling, and add a unit test covering both fields. Fixes XRPLF#6758
2594507 to
57cafe2
Compare
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.
High Level Overview of Change
The
gateway_balanceshandler read theaccount/identparameters withasString()without first checking that they are strings. Passing anon-string value (number, object, array) caused JsonCpp to throw a
Json::LogicError, which the RPC framework caught and reported to the clientas a generic
rpcINTERNAL("Internal error"). This change validates the fieldtype up front and returns a clean
rpcINVALID_PARAMSinstead.Fixes #6758.
Context of Change
This is a defense-in-depth input-validation gap (severity: low). The bug has
existed since the handler used unchecked
asString()on these fields. Beforethis change,
{"account": 123}or{"account": []}returnedrpcINTERNAL,which is confusing and hides the real problem (a malformed request).
The fix mirrors the existing
hotwallethandling in the same file, whichalready checks
isString()before callingasString(), and follows the samepattern used for other RPC handlers in the input-validation cleanup (e.g. the
peerparameter inaccount_lines). Non-stringaccount/identnow returnrpcINVALID_PARAMSviaRPC::invalidFieldError.API Impact
libxrplchange (any change that may affectlibxrplor dependents oflibxrpl)No public methods or fields change. Only the error code for malformed
(non-string)
account/identinput changes, fromrpcINTERNALto the moreaccurate
rpcINVALID_PARAMS.Test Plan
Added a
testGWBInvalidAccountcase toGatewayBalances_test.cpp(modeled onthe existing
testGWBApiVersions) that submits a non-stringaccountand anon-string
identand asserts the response is aninvalidParamserror acrossall API versions. Run with: