Skip to content
This repository has been archived by the owner on Jul 2, 2023. It is now read-only.

HashAlgo receives uninitialized memory from hash #1

Open
ammaraskar opened this issue Feb 5, 2021 · 1 comment
Open

HashAlgo receives uninitialized memory from hash #1

ammaraskar opened this issue Feb 5, 2021 · 1 comment

Comments

@ammaraskar
Copy link

Hi there, we (Rust group @sslab-gatech) are scanning crates on crates.io for potential soundness bugs. We noticed that in Balloon::hash

// Create an uninitialized buffer
let mut buffer = Vec::<H>::with_capacity(len);
unsafe { buffer.set_len(len) };
// Step 1. Expand input into buffer
{
let mut algo = A::create();
algo.update_u64(0)?;
algo.update(&passwd)?;
algo.update(&salt)?;
algo.finalize_into(&mut buffer[0])?;

An uninitialized buffer is used to make space for the final storage of the hash. This uninitialized buffer is passed straight to HashAlgo::finalize_into. We realize that HashAlgos should only write to the hash H, it is possible to implement a HashAlgo that reads and uses this uninitialized memory which invokes undefined behavior in Rust.

Some measures you might consider to fix this:

@yangby-cryptape
Copy link
Owner

Thanks, but this repository will be archived, so I won't fix that.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants