#37545 [BC-Medium] Deposits with a lock_time of 16 cannot be processed
Description
Brief/Intro
Vulnerability Details
pub fn parse(reclaim_script: &ScriptBuf) -> Result<Self, Error> {
let (lock_time, script) = match reclaim_script.as_bytes() {
// These first two branches check for the case when the script
// is written with as few bytes as possible (called minimal
// CScriptNum format or something like that).
[0, OP_CSV, script @ ..] => (0, script),
// This catches numbers 1-16 and -1. Negative numbers are
// invalid for OP_CHECKSEQUENCEVERIFY, but we filter them out
// later in `ReclaimScriptInputs::try_new`.
[n, OP_CSV, script @ ..]
if OP_PUSHNUM_NEG1 == *n || (OP_PUSHNUM_1..OP_PUSHNUM_16).contains(n) =>
{
(*n as i64 - OP_PUSHNUM_1 as i64 + 1, script)
}
// Numbers in bitcoin script are typically only 4 bytes (with a
// range from -2**31+1 to 2**31-1), unless we are working with
// OP_CSV or OP_CLTV, where 5-byte numbers are acceptable (with
// a range of 0 to 2**39-1). See the following for how the code
// works in bitcoin-core:
// https://github.com/bitcoin/bitcoin/blob/v27.1/src/script/interpreter.cpp#L531-L573
// That said, we only accepts 4-byte unsigned integers, and we
// check that below.
[n, rest @ ..] if *n <= 5 && rest.get(*n as usize) == Some(&OP_CSV) => {
// We know the error and panic paths cannot happen because
// of the above `if` check.
let (script_num, [OP_CSV, script @ ..]) = rest.split_at(*n as usize) else {
return Err(Error::InvalidReclaimScript);
};
(read_scriptint(script_num, 5)?, script)
}
_ => return Err(Error::InvalidReclaimScript),
};
let lock_time =
u32::try_from(lock_time).map_err(|_| Error::InvalidReclaimScriptLockTime(lock_time))?;
let script = ScriptBuf::from_bytes(script.to_vec());
ReclaimScriptInputs::try_new(lock_time, script)
}Impact Details
References
Proof of Concept
Proof of Concept
Previous#38516 [BC-High] Signer can censor transactions and halt the network by providing an invalid nonce oNext#38003 [BC-Medium] A malicious coordinator calling `Emily::update_deposits` can make the entire Sign
Last updated
Was this helpful?