runtimeverification / runtimeverification/evm-semantics

RLP decoding rules accept invalid encoding [129, 1]?

Open
#413 0 comments 0 reactions 0 assignees View on GitHub

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

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. 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

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.