-
Notifications
You must be signed in to change notification settings - Fork 62
Closed
Description
rust-multihash/src/multihash.rs
Line 368 in 8e14b19
| return Ok(decode::u64(&b[..=i]).unwrap().0); |
The unwrap() here might cause some crash using the library if an error occurred. For chains using Substrate, this could cause critical severity issues if an attacker is able to craft a malicious payload in order to trigger the unwrap.
You can find an image of a malicious payload that will cause a panic below.

Below is an example of a fix that could be used :
if decode::is_last(b[i]) {
match decode::u64(&b[..=i]) {
Ok(val) => return Ok(val.0),
Err(_) => return Err(Error::VarIntDecodeError),
}
}schneiderfelipe
Metadata
Metadata
Assignees
Labels
No labels