paritytech / paritytech/parity-common

rlp: list length and contents are not validated

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

Nobody has claimed this yet.

Dominant language
Rust
Stars
311
Forks
245
PR merge metrics
No merged PRs in 30d

Description

Three examples that should be rejected


    let invalid_rlp = [193, 4, 4];
    let rlp = rlp::Rlp::new(&invalid_rlp);
    let item_count = rlp.item_count().unwrap(); // this should fail
    assert_eq!(item_count, 2); // wrong. invalid rlp with a list of one element followed by extra
                               // data that ends up being assumed as part of the list

    let invalid_rlp = [195, 2, 247, 247];
    let rlp = rlp::Rlp::new(&invalid_rlp);
    let item_count = rlp.item_count().unwrap(); // should fail
    assert_eq!(item_count, 1); // wrong. invalid rlp with a list of 3 bytes where only the first
                               // one is valid rlp

    let invalid_rlp = [194, 1];
    let rlp = rlp::Rlp::new(&invalid_rlp);
    let item_count = rlp.item_count().unwrap(); // should fail
    assert_eq!(item_count, 0); // wrong. list should occupy two bytes, occupies just one and it's
                               // still accepted

Contributor guide

Open the contributing guide

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 at the Rlp::item_count entry point and trace how list lengths and nested item boundaries are validated. Add regression coverage for the three byte sequences in the issue, with completion meaning each malformed list is rejected rather than returning an item count.

Written by the indexing model from the issue text.

Assessment

Tech stack
rust
Domain
backend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Clearly specified
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.