From bae03a98e6d91068842ef11c03e69b2dcdf4d69c Mon Sep 17 00:00:00 2001 From: Manik Jain Date: Wed, 28 Aug 2024 20:31:08 +0000 Subject: [PATCH] Add missing feature flag check for 0 signatures in secp256k1 verify --- src/flamenco/runtime/program/fd_precompiles.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/flamenco/runtime/program/fd_precompiles.c b/src/flamenco/runtime/program/fd_precompiles.c index 708ae0810a..360c815482 100644 --- a/src/flamenco/runtime/program/fd_precompiles.c +++ b/src/flamenco/runtime/program/fd_precompiles.c @@ -225,8 +225,12 @@ fd_precompile_secp256k1_verify( fd_exec_txn_ctx_t * txn_ctx, return FD_EXECUTOR_PRECOMPILE_ERR_INSTR_DATA_SIZE; } + /* https://github.com/anza-xyz/agave/blob/574bae8fefc0ed256b55340b9d87b7689bcdf222/sdk/src/secp256k1_instruction.rs#L938-L947 */ ulong sig_cnt = data[0]; - if( FD_UNLIKELY( sig_cnt==0 ) ) { + if( FD_UNLIKELY( ( FD_FEATURE_ACTIVE( txn_ctx->slot_ctx, libsecp256k1_fail_on_bad_count ) || + FD_FEATURE_ACTIVE( txn_ctx->slot_ctx, libsecp256k1_fail_on_bad_count2 ) ) && + sig_cnt==0 && + data_sz>1 ) ) { return FD_EXECUTOR_PRECOMPILE_ERR_INSTR_DATA_SIZE; }