Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- `[abci/client]` Add missing `QuerySequence` case to `resMatchesReq` in socket
client, which caused the client to treat a valid `QuerySequence` response as
unexpected and terminate the connection.
Comment thread
devin-ai-integration[bot] marked this conversation as resolved.
2 changes: 2 additions & 0 deletions abci/client/socket_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,8 @@ func resMatchesReq(req *types.Request, res *types.Response) (ok bool) {
_, ok = res.Value.(*types.Response_ProcessProposal)
case *types.Request_FinalizeBlock:
_, ok = res.Value.(*types.Response_FinalizeBlock)
case *types.Request_QuerySequence:
_, ok = res.Value.(*types.Response_QuerySequence)
}
return ok
}
Expand Down
28 changes: 28 additions & 0 deletions abci/client/socket_client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,6 +195,34 @@ func TestCallbackInvokedWhenSetLate(t *testing.T) {
require.True(t, called)
}

// TestQuerySequenceCrashesSocketClient reproduces a vulnerability where calling
// QuerySequence over the socket ABCI transport causes the client to stop with
// an error because resMatchesReq is missing the QuerySequence case. When this
// happens in production, killTMOnClientError terminates the entire node.
// A remote peer can trigger this by sending a SeenTx message with a non-empty
// Signer field, which causes the CAT mempool reactor to call QuerySequence
// before validating the message fields.
func TestQuerySequenceCrashesSocketClient(t *testing.T) {
ctx, cancel := context.WithCancel(context.Background())
defer cancel()

app := types.BaseApplication{}
_, c := setupClientServer(t, app)

// Call QuerySequence over the socket transport. If the bug is present,
// the socket client will stop itself because resMatchesReq returns false
// for Request_QuerySequence <-> Response_QuerySequence.
resp, err := c.QuerySequence(ctx, &types.RequestQuerySequence{
Signer: []byte("test-signer"),
})

// With the bug: err != nil and c.Error() != nil (client stopped itself).
// With the fix: err == nil, resp is valid, client remains running.
require.NoError(t, err, "QuerySequence should not cause socket client error")
require.NotNil(t, resp, "QuerySequence should return a response")
require.NoError(t, c.Error(), "socket client should still be running without error")
}

type blockedABCIApplication struct {
wg *sync.WaitGroup
types.BaseApplication
Expand Down
Loading