runtimeverification / runtimeverification/evm-semantics
RLP decoding rules accept invalid encoding [129, 1]?
Nobody has claimed this yet.
- Dominant language
- KCL
- Stars
- 591
- Forks
- 156
- Avg merge
- 2h 19m
- Merged PRs (30d)
- 1
Description
If I'm reading the rules under 'Decoding' at the end of data.md correctly, it looks like invalid encodings like [129,1] (where I'm informally writing strings as lists of codes for simplicity) are accepted by the rules:
rlpDecode([129,1])
==>
rlpDecode([129,1], decodeLengthPrefix([129,1], 0)
==>
rlpDecode([129,1], decodeLengthPrefix([129,1], 0, ordChar(substrString([129,1], 0, 1)))
==>
rlpDecode([129,1], decodeLengthPrefix([129,1], 0, 129)
==>
rlpDecode([129,1], str(1, 1))
==>
substrString([129,1], 1, 2)
==>
[1]
Please correct me if I'm misreading/misinterpreting the rules somehow.
Note that [129,1] is invalid because the singleton string [1] should be encoded as itself. For instance, see the test "byteShouldBeSingleByte01" at https://github.com/ethereum/tests/blob/5d85b07e460e38a991801087f967d308346b32ab/RLPTests/invalidRLPTest.json#L37.
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Decoding rules at the end of data.md and compare their behavior with the byteShouldBeSingleByte01 case in the linked invalidRLPTest.json. Confirm whether [129,1] is accepted, then update the rules so the invalid encoding is rejected while the canonical singleton encoding remains valid.
Written by the indexing model from the issue text.
Assessment
- Domain
- compilers
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100