-
-
Notifications
You must be signed in to change notification settings - Fork 19
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
Ensure absence of panics on scripts >4GB and other consensus-invalid data #59
Conversation
31b057c
to
d7fe526
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Makes sense. Graceful error handling is better than panics on UB. That way any future nodes might be able to handle attacks just by discarding things that don't parse according to Bitcoin consensus.
d22c215
to
323adba
Compare
Now since we break APIs anyway with v0.11 I think it is time to merge this one as well. @zoedberg what do you think? |
Codecov ReportAttention:
📢 Thoughts on this report? Let us know!. |
3977e51
to
e26835c
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now since we break APIs anyway with v0.11 I think it is time to merge this one as well. @zoedberg what do you think?
I agree
Bitcoin consensus encoding uses this idiotic thing named
VarInt
, which can have any value up to 64 bits and is used to encode length of all array data in consensus: number of transaction inputs, outputs, scripts, witnesses etc, etc. This is bad since none of these things in practice can have more than 2^16 items under the consensus rules - but still, an attacker can create a tx which contains octallions of elements in any of the consensus data...This creates additional problems, since in RGB we'd like to ensure we can run a client-side-validation with clear restrictions on the memory, storage, bandwidth etc known beforehand - thus we have the strict type system and no collection of RGB data can have more than 64k elements or be larger than 16MB. But once we'd like to read Bitcoin tx from AluVM we instantly get into this trouble with octallions of bytes which may come from an attacker with the use of
VarInt
.There are three ways of dealing with this situation:
This PR puts the foundations for such a thing into
bp-consensus
crate. Since it changes APIs (many functions will be returningResult
now), it is an API-breaking change (but not RGB consensus-breaking) and has to go with a newv0.11
version