#37350 [BC-Insight] `null` Is Not Unmarshalled Correctly Into json.RawMessage
Submitted on Dec 2nd 2024 at 17:25:43 UTC by @CertiK for Attackathon | Ethereum Protocol
Report ID: #37350
Report Type: Blockchain/DLT
Report severity: Insight
Target: https://github.com/ledgerwatch/erigon
Impacts:
(Specifications) A bug in specifications with no direct impact on client implementations
Description
Brief/Intro
The response of null in the rpc package of Ethereum client Erigon ( https://github.com/erigontech/erigon ) could not be presented correctly due to the unmarshalling of the null in the CallContext.
Vulnerability Details
Affected Codebase: https://github.com/erigontech/erigon/tree/v2.61.0-beta1
In the rpc package, the CallContext is used to perform a JSON-RPC call and unmarshal the returned result. However, the unmarshalling for the result of null is not correctly performed:
https://github.com/erigontech/erigon/blob/v2.61.0-beta1/rpc/client.go#L321
As mentioned in the geth(go-ethereum) PR: https://github.com/ethereum/go-ethereum/pull/26701
The function already checks that the result is either
nilor a pointer type, so the extra reference operator is unnecessary. This actually causes a bug wherenulls are not unmarshalled correctly into json.RawMessage.
It is worth noted a similar issue has been fixed in geth (go-ethereum) by fixing the result unmarshalling dependent of null:
https://github.com/ethereum/go-ethereum/pull/26723
Impact Details
null result could not be unmarshalled correctly in the json.RawMessage in the CallContext of rpc.
References
https://github.com/erigontech/erigon/blob/v2.61.0-beta1
https://github.com/ethereum/go-ethereum/issues/26700
https://github.com/ethereum/go-ethereum/pull/26701
https://github.com/ethereum/go-ethereum/pull/26723
Proof of Concept
Proof of Concept
For simplicity, we can reuse and modify the test from geth (go-ethereum) (https://github.com/ethereum/go-ethereum/pull/26723) to verify the issue:
The output shows the Expected non-nil result error message when the result is nil.
Was this helpful?