This repository has been archived by the owner on Dec 5, 2024. It is now read-only.
Added verifying of encoded RLP length to be not greater than available data size #1073
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Verifying of decoded RLP object length to be not greater than data size
While primary decode method,
RLP.decode2(byte[])
is protected to verify whether decoded length lies in the boundaries of remaining data length, we have several other public methods which doesn't include such inspection. One of them,RLP.decode(byte[], int)
is used, for example, inValue
constructor and could be attacked using incorrect RLP data. Length is int, so maximum possible size is 2+B or more than 2Gb occupied by each RLPItem from attacker's RLP. So this kind of attack could occupy all available memory.What's done: