-
Notifications
You must be signed in to change notification settings - Fork 998
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ill-formed calldata to deposit contract can add invalid deposit data #1357
Comments
For a future reference, other ideas of fixing this issue are shared below. 1. Incorporate the
|
Thanks @daejunpark for the very in-depth explanation here and discussion we had over the past few days.
An alternative suggestion is to ask the Vyper team to build out "VIP: msg.data" which would allow for the explicit check of the parameters. I question whether there is sufficient time to implement this though. |
So this boils down to "how can we better prevent potential validators from shooting themselves in the foot". We've been a bit dismissive of additional checks in the past but primarily just wrt bls verification on chain, but this checksum seems to be a reasonable addition with minimal overhead. The most important thing is that any deposit that comes through can be validly de-serialized and parsed into an SSZ Secondly, we want to have a good user experience -- the top item on that list being not losing all your money. The checksum is a solid path and should prevent most buggy data from being committed. I just checked on the Vyper |
I like the checksum. Definitely feels the most non-intrusive of all the fixes. |
Closing in favour of #1362—we're going ahead with the suggestion |
Problem
The calldata decoding process in the deposit contract bytecode does not have a sufficient well-formedness check, which fails to detect certain ill-formed calldata, leading to adding invalid deposit data in the deposit Merkle tree.
This is problematic when clients make mistakes and send deposit transactions with incorrectly encoded calldata, which may result in losing their deposited Ether.
For example, the following ill-formed calldata does not trigger the deposit function to revert:
and the deposit function will simply result in adding the following (garbage) deposit data in the Merkle tree:
Since
bls_verify
will fail on this, the deposited Ether associated to this will be lost.A fix suggestion
[After discussion with @CarlBeek]
Add a new parameter to the deposit function, say
expected_leaf_value
, as a checksum for the deposit data to be added in the tree.That is, after the following code that computes the leaf value:
add the following assertion:
Here, clients need to compute
expected_leaf_value
off-chain and provide it along with the original deposit data, to ensure that the leaf value is correctly computed on-chain, which implies that any ill-formed calldata will be rejected. Furthermore, clients can even runbls_verify
onexpected_leaf_value
off-chain, to ensure that the deposit data to be added in the tree will be eventually claimable in Eth2.The text was updated successfully, but these errors were encountered: