fix(globe-wallet): add cancel_upgrade and clear pending upgrade on recovery (Closes #87) - #95
Closed
s6pa1rta3n-lab wants to merge 1 commit into
Closed
fix(globe-wallet): add cancel_upgrade and clear pending upgrade on recovery (Closes #87)#95s6pa1rta3n-lab wants to merge 1 commit into
s6pa1rta3n-lab wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #87
Context & Problem
In
GlobeWallet(contracts/globe-wallet/src/lib.rs), while the admin transfer and guardian recovery subsystems had cancellation mechanisms (cancel_admin_transferandcancel_recovery), the upgrade subsystem lacked an equivalentcancel_upgrademethod. Furthermore,execute_recoverydid not clearPendingUpgrade.In a compromised admin scenario where an attacker proposed a malicious upgrade proposal before guardians executed recovery, the
PendingUpgradeproposal remained stuck in instance storage. This caused two critical issues:propose_upgraderejects new proposals whenPendingUpgradeis present withUpgradeAlreadyPending, the new legitimate admin was permanently locked out from proposing upgrades.What Changed
Added
cancel_upgrade:DataKey::PendingUpgradeand emits(Symbol::new(&env, "upgrade_cancelled"),), admin.WalletError::UpgradeNotPendingif called when no upgrade proposal exists.cancel_admin_transferandcancel_recovery.Updated
execute_recovery:DataKey::PendingUpgradeupon successful recovery, ensuring any malicious or unresolved upgrade proposal from the compromised outgoing admin is cleared automatically and documented as an explicit design decision.Added Comprehensive Unit Tests:
test_cancel_upgrade: Verifies proposing, cancelling, verifying removal, rejecting repeat cancellations withUpgradeNotPending, and verifying that proposing a new upgrade succeeds.test_cancel_upgrade_requires_admin: Verifies non-admin authorization rejection (WalletError::Unauthorized).test_cancel_upgrade_not_pending_fails: VerifiesUpgradeNotPendingerror when no proposal is active.test_stale_upgrade_cleared_by_new_admin_via_cancel_upgrade: Verifies a new admin can clear a stale upgrade proposal viacancel_upgradeand propose a new valid upgrade.test_recovery_clears_pending_upgrade_and_unblocks_future_proposals: End-to-end test proving thatexecute_recoveryautomatically clearsPendingUpgradeand unblocks the new admin from proposing legitimate upgrades.Definition of Done Checklist
cancel_upgradefunction added, admin-authorized, symmetric withcancel_admin_transfer/cancel_recoveryexecute_recoveryclears any pendingPendingUpgradeas part of a successful recovery (documented as an explicit design decision, same as its existingPendingAdmincleanup)cancel_upgradeexecute_recoveryclears any in-flightPendingUpgradeautomaticallypropose_upgradeworks again for the new admin afterward (no more permanent lockout)cargo test --workspaceoutput pasted belowTest Output
Payout Routing
0xF46C9F6d70C50BF81ef3588AB523a90a594a2F89GCL6OXAMLD75BMTINA6EMRUDWK5THQUSHMYNLSNBCJAPZJHNYJTUNIBC