-
Notifications
You must be signed in to change notification settings - Fork 1k
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
[bug/fuzzing] Incorrect validation of pre-state attestation & malformed block signature during state transition (in pcli) #5658
Comments
This seems like an issue where prysm is regarding an invalid ssz object as valid whereas lcli,zcli regard it as invalid an error accordingly. zcli: lcli: Whereas in both mainnet/minimal there were no ssz errors. That doesn't seem correct, we should fail when unmarshalling invalid ssz objects. |
I've modify Some new output from @protolambda:
|
It's not the SSZ that is invalid, it's the bitlength of some attestation in the state that is incorrect (not matching committee size), and some malformed signature in the block. It just happens that lighthouse does the signature check earlier, while zrnt deserializes it right before verification, at which point it already hit the state format problem first. That said, if the block actually were valid, Lighthouse should still check that their state is not invalid, unlike Prysm, which seemed to catch neither of the problems. We do have invalid-signature tests though, and the invalid pre-state is not something within reach to begin with, so I don't see this as a critical bug. Still, hardening committee retrieval from prysm/lighthouse state wouldn't hurt. |
Just updated the issue name, hope it is more clear. |
nim-beacon-chain also validate the state and block. I just opened an issue for them as well: status-im/nimbus-eth2#944 |
@protolambda If it was an invalid ssz object this should have failed for us first. |
Block is an invalid ssz for
|
We enforce valid BLS points at the SSZ decoding level (except for deposits). Not technically part of the SSZ spec but it saves us from processing things that will never pass signature verification. |
teku also have the same issue. Reported here: Consensys/teku#1686 |
Gotcha, thanks for confirming this. So its a sig verification issue then. So trying to think of action items for this:
On 1) I think we are moving towards decoupling signature verification from block processing, so we could take this under that. This should prevent us from processing any bad blocks. On 2) , not too sure about how to approach this. |
Quick recap: lighthouse:
zcli:
prysm/teku/nim:
Some extra tests using states from the spec ( |
@pventuzelo to echo what @protolambda said:
Given this is strictly a client implementation detail, it may be better to start harden it from spec's point of view (ie add this check to the beacon chain spec) then us the client implementations can follow along. What do you think? |
How long did this take to run? The input data here would run almost 2 quadrillion empty state transitions before running validation. This isn't the normal beacon block pipeline for Prysm. This method has assumed the following:
I don't think your findings are correct. There is no way prysm processed 2 quadrillion empty state transitions in 15 seconds. |
We have implemented the spec A quick recap of what pcli is doing:
def state_transition(state: BeaconState, signed_block: SignedBeaconBlock, validate_result: bool=True) -> BeaconState:
block = signed_block.message
# Process slots (including those with no blocks) since block
process_slots(state, block.slot)
# Verify signature
if validate_result:
assert verify_block_signature(state, signed_block)
# Process block
process_block(state, block)
# Verify state root
if validate_result:
assert block.state_root == hash_tree_root(state)
# Return post-state
return state With your input data, |
I think the main issue here is that we've used utilities such as Feel free to close this issue, we'll investigate a better/more effective way of testing these edge cases :) |
I've update the issue name to make it clear that it is related to pcli. |
🐞 Bug Report
Description
During fuzzing with beacon-fuzz, I provided a set of invalid SSZ state and block to prysm using
pcli
tool.Prysm consider both pre-state and block as valid and try to process the state transition anyway.
Other client/tool like
lighthouse
andzcli
reject either the state or the block.NOTES:
mainnet
preset (work also withminimal
)zcli
, process panic but @protolambda told us it should because this case should never happened.Additional info
lighthouse (mainnet and minimal):
zcli (mainnet):
🔬 Minimal Reproduction
Download: incorrect_ssz_validation_prysm.zip
pcli result
Notes: Don't know if it is related yet, but
blockSlot
value is particularly hight.🌍 Your Environment
branch:
master
commit: e30349d
The text was updated successfully, but these errors were encountered: