diff --git a/sdk/src/ed25519_instruction.rs b/sdk/src/ed25519_instruction.rs index 45a8f1c2c2d932..a7bae6b4164a32 100644 --- a/sdk/src/ed25519_instruction.rs +++ b/sdk/src/ed25519_instruction.rs @@ -93,6 +93,7 @@ pub fn verify( return Err(PrecompileError::InvalidInstructionDataSize); } let num_signatures = data[0] as usize; + if num_signatures == 0 && data.len() > SIGNATURE_OFFSETS_START { return Err(PrecompileError::InvalidInstructionDataSize); } diff --git a/sdk/src/secp256r1_instruction.rs b/sdk/src/secp256r1_instruction.rs index 545cf52963759c..ca2e6a3e0313c6 100644 --- a/sdk/src/secp256r1_instruction.rs +++ b/sdk/src/secp256r1_instruction.rs @@ -142,7 +142,9 @@ pub fn verify( return Err(PrecompileError::InvalidInstructionDataSize); } let num_signatures = data[0] as usize; - + if num_signatures == 0 { + return Err(PrecompileError::InvalidInstructionDataSize); + } if num_signatures > 8 { return Err(PrecompileError::InvalidInstructionDataSize); }