-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Panic “len out of range” while Unmarshaling Scale leading to a denial of service (DoS) #3476
Comments
Hi, do you have any update regarding the fix of this bug? |
Hey @pventuzelo unfortunately we have not looked at this yet, but will prioritise this and will return with some updates asap. |
I think the right way to solve this is to pick a max memory size which we are comfortable to decode and through an error on any request asking to decode bytes more than that memory. @timwu20 wdyt? |
I think we should check the parity codec and see what the maximum size is. I believe they instituted a maximum size. |
In parity scale codec, a trait called MaxEncodedLen gets used. Using which different types could have different maximum encoded length. We could check against this length while decoding. We could get idea of those max encoded len values from this test file. |
I have been searching through parity-scale-codec and to figure out this maximum size. Tried to go through the macros as well amongst other things to figure this out. But couldn't find this max value. I then tried to decode these same bytes using parity-scale-codec to see if it fails gracefully or panics. It panicked. So, that makes me believe there is not max value. I basically added these lines inside the test
which resulted in below panic
|
@timwu20 @P1sar Should I create an issue to have max encoded length for each types? We could add them to each decode funcs of each types and make them safer. |
Well it's panicking cause you called |
🎉 This issue has been resolved in version 0.9.0 🎉 The release is available on GitHub release Your semantic-release bot 📦🚀 |
Panic “len out of range” while Unmarshaling Scale leading to a denial of service (DoS)
We (@FuzzingLabs) found a “len out of range” Panic issue while Unmarshaling Scale.
Expected behavior
The function should check the length of the slice.
Environment
Steps to reproduce
This test crashes.
Root cause
The
decodeBytes
function tries to callmake
on the length read from the given bytes. By doing so it reads a very big value and fails to create a slice.gossamer/pkg/scale/decode.go
Line 610 in d5c2c7f
Detailed behavior
The text was updated successfully, but these errors were encountered: