The proposal expiration logic is incorrect
The is_proposal_expired function in the multisig module uses a reversed comparison operator, causing proposals to be marked as expired when they are still within the voting period. This prevents legitimate voting and effectively creates a denial of service for multisig wallets.
Submitted by Rhaydden
The is_proposal_expired function uses incorrect comparison logic that causes proposals to be marked as expired when they should still be active, and vice versa. This is as a result of the reversed comparison operator in the expiration check.
The impact of this bug is high because valid proposals are incorrectly marked as expired which prevents legitimate voting. Also the voting period enforcement is effectively reversed. This effectively creates a DoS because any multisig wallet created would be unable to execute proposals.
N/B: This issue is present in
multisig.movefiles in bothinitia_stdlibandminitia_stdlib
Proof of Concept
In the is_proposal_expired function:
File: multisig.move
483: fun is_proposal_expired(
484: max_period: &Period, proposal_height: u64, proposal_timestamp: u64
485: ): bool {
486: let (height, timestamp) = get_block_info();
487: let expired_height =
488: if (option::is_some(&max_period.height)) {
489: let max_voting_period_height = *option::borrow(&max_period.height);
490: >>>> (max_voting_period_height + proposal_height) >= height
491: } else { false };
492:
493: let expired_timestamp =
494: if (option::is_some(&max_period.timestamp)) {
495: let max_voting_period_timestamp = *option::borrow(&max_period.timestamp);
496: >>>> (max_voting_period_timestamp + proposal_timestamp) >= timestamp
497: } else { false };
498:
499: expired_height || expired_timestamp
500: }
Consider a scenario:
-
Proposal created at height 1000.
-
Voting period is 100 blocks.
-
At height 1050 (which should be valid for voting):
- Expiration height =
1000 + 100 = 1100. - Current comparison:
(1100 >= 1050)= true. - This incorrectly marks the proposal as expired.
- Expiration height =
-
The proposal is marked as expired 50 blocks too early.
This can be verified by attaching the test below to precompile/modules/minitia_stdlib/sources/multisig.move and run test with initiad move test --path ./precompile/modules/minitia_stdlib --filter test_proposal_expiration_bug --statistics.
#[test(
account1 = @0x101, account2 = @0x102, account3 = @0x103
)]
#[expected_failure(abort_code = 0x30005)] // Add this line to expect the EPROPOSAL_EXPIRED error
fun test_proposal_expiration_bug(
account1: signer,
account2: signer,
account3: signer
) acquires MultisigWallet {
// create multisig wallet
let addr1 = signer::address_of(&account1);
let addr2 = signer::address_of(&account2);
let addr3 = signer::address_of(&account3);
// Create multisig with 100 block voting period
create_multisig_account(
&account1,
string::utf8(b"multisig wallet"),
vector[addr1, addr2, addr3],
2,
option::some(100), // max voting period of 100 blocks
option::none()
);
let multisig_addr = object::create_object_address(&addr1, b"multisig wallet");
// Set initial block height to 1000
set_block_info(1000, 0);
// Create proposal at height 1000
create_proposal(
&account1,
multisig_addr,
@minitia_std,
string::utf8(b"multisig"),
string::utf8(b"update_config"),
vector[],
vector[
std::bcs::to_bytes(&vector[addr1, addr2]),
std::bcs::to_bytes(&2u64),
std::bcs::to_bytes(&option::none<u64>()),
std::bcs::to_bytes(&option::none<u64>())
]
);
// Move to height 1101 (proposal should be expired)
// Since 1101 > (1000 + 100)
set_block_info(1101, 0);
// This should fail with EPROPOSAL_EXPIRED
vote_proposal(&account1, multisig_addr, 1, true);
}
Console logs:
INCLUDING DEPENDENCY MoveNursery
INCLUDING DEPENDENCY MoveStdlib
BUILDING MinitiaStdlib
Running Move unit tests
[ FAIL ] 0x1::multisig::test_proposal_expiration_bug
Test Statistics:
┌─────────────────────────────────────────────┬────────────┬───────────────────────────┐
│ Test Name │ Time │ Gas Used │
├─────────────────────────────────────────────┼────────────┼───────────────────────────┤
│ 0x1::multisig::test_proposal_expiration_bug │ 0.047 │ 61103 │
└─────────────────────────────────────────────┴────────────┴───────────────────────────┘
Test failures:
Failures in 0x1::multisig:
┌── test_proposal_expiration_bug ──────
│ Test did not error as expected
└──────────────────
Test result: FAILED. Total tests: 1; passed: 0; failed: 1
After implementing the fix below:
INCLUDING DEPENDENCY MoveNursery
INCLUDING DEPENDENCY MoveStdlib
BUILDING MinitiaStdlib
Running Move unit tests
[ PASS ] 0x1::multisig::test_proposal_expiration_bug
Test Statistics:
┌─────────────────────────────────────────────┬────────────┬───────────────────────────┐
│ Test Name │ Time │ Gas Used │
├─────────────────────────────────────────────┼────────────┼───────────────────────────┤
│ 0x1::multisig::test_proposal_expiration_bug │ 0.054 │ 59229 │
└─────────────────────────────────────────────┴────────────┴───────────────────────────┘
Test result: OK. Total tests: 1; passed: 1; failed: 0
Recommended mitigation steps
Fix the comparison logic in is_proposal_expired:
fun is_proposal_expired(
max_period: &Period, proposal_height: u64, proposal_timestamp: u64
): bool {
let (height, timestamp) = get_block_info();
let expired_height =
if (option::is_some(&max_period.height)) {
let max_voting_period_height = *option::borrow(&max_period.height);
- (max_voting_period_height + proposal_height) >= height
+ height >= (max_voting_period_height + proposal_height)
} else { false };
let expired_timestamp =
if (option::is_some(&max_period.timestamp)) {
let max_voting_period_timestamp = *option::borrow(&max_period.timestamp);
- (max_voting_period_timestamp + proposal_timestamp) >= timestamp
+ timestamp >= (max_voting_period_timestamp + proposal_timestamp)
} else { false };
expired_height || expired_timestamp
}
beer-1 (Initia) confirmed, but disagreed with severity and commented:
Good finding; but want to lower the severity to low. Expiration does not affect a lot on the logics and only affect to specific multis account.
LSDan (judge) decreased severity to Medium and commented:
I disagree. This is guaranteed to happen and does impact the desired functionality of the protocol. As such, it fits as a medium. Please let me know if I’m misunderstanding anything.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
The comparison operator in the expiration check is reversed: it checks if the expiration height is greater than or equal to the current height, instead of the other way around.
Impact
Valid proposals are incorrectly marked as expired, preventing legitimate voting and effectively creating a denial of service for multisig wallets.
What the attacker needed
A multisig wallet with a voting period
The fix
The comparison logic should be reversed so that the current height or timestamp is compared to the expiration value, not the other way around.
How it was found
- Create a multisig wallet with a voting period of 100 blocks.
- Set the block height to 1000 and create a proposal.
- Advance the block height to 1050, which should still be within the voting period.
- Attempt to vote on the proposal; it fails because the proposal is incorrectly marked as expired.
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A multisig wallet is a shared account that requires multiple people to approve actions. Proposals are suggestions for actions, and they have a voting period. The code that checks if a proposal has expired had the comparison backwards, so it thought proposals were expired too early, stopping people from voting.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.