Skip to content

bug: CBC mode test fails randomly on out of bounds #218

Open

Description

@Autoparallel

Describe the bug
Apparently we can, due to rng, get an out of bounds error in the CBC encryption mode. See: https://github.com/pluto/ronkathon/actions/runs/13179737670/attempts/1

To Reproduce
N/A?

Activity

  1. mahmudsudo commented on Feb 10, 2025

    @mahmudsudo
    Contributor

    I would suggest restricting the values/length of the generated numbers

  2. Autoparallel commented on Feb 17, 2025

    @Autoparallel
    ContributorAuthor

    Do you know that these numbers being hit are sometimes too big/small?

  3. mahmudsudo commented on Feb 18, 2025

    @mahmudsudo
    Contributor
    // remove PKCS#7 padding by checking the last byte and removing all intermediate bytes
        let last_byte = plaintext[plaintext.len() - 1];
        if plaintext[plaintext.len() - last_byte as usize] == last_byte {
          plaintext.truncate(plaintext.len() - last_byte as usize);
        }
    
    

    this is where the failure stems from, it seems last_byte is zero

  4. Autoparallel commented on Feb 18, 2025

    @Autoparallel
    ContributorAuthor

    Ah 1/256 chance then. No wonder we haven't seen this but still likely enough to fail.

  5. Autoparallel commented on Feb 18, 2025

    @Autoparallel
    ContributorAuthor

    @mahmudsudo good find there by the way. Marked this as "good first issue" since this shouldn't be too hard to fix.

  6. mahmudsudo commented on Feb 19, 2025

    @mahmudsudo
    Contributor

    On second thought , a little check on the value of last_byte might help

  7. mahmudsudo commented on Nov 16, 2025

    @mahmudsudo
    Contributor

    can i take the issue now ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions