fix(retrieve): clear retrieve relation after perform to prevent replay in ForkRetriveAsset branch - #1313
Open
33cn wants to merge 2 commits into
Open
fix(retrieve): clear retrieve relation after perform to prevent replay in ForkRetriveAsset branch#131333cn wants to merge 2 commits into
33cn wants to merge 2 commits into
Conversation
added 2 commits
August 31, 2026 11:41
…set branch After ForkRetriveAsset, RetrievePerform returns directly from the RetrievePerformAssets branch without removing the backup<->default relation, so the backup address can replay perform at any time and drain assets deposited to the default address later. Gate the fix behind the new ForkRetrivePerformRelay dapp fork: on successful perform, remove the relation and save it to state, aligned with the pre-asset-fork path. Pre-fork behavior is unchanged.
After ForkRetrivePerformRelay, a successful perform clears the backup<->default relation, so the token perform must establish a new relation and wait the delay period instead of replaying on the old one.
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.
Vulnerability
In
plugin/dapp/retrieve/executor/retrievedb.go:292-294, onceForkRetriveAssetis active,RetrievePerformreturns directly from theRetrievePerformAssets(...)branch and skips theUnRelateDB+Savecleanup done by the legacy path (lines 310-311).Consequences after a successful retrieve:
retrievePreparestatus.blocktime - PrepareTime >= DelayPeriod) stays satisfied forever.performat any time — without a newprepareand without waiting the delay period — and drain any assets deposited to the default address later. The default address owner has lost the key by definition and cannotcancelto defend themselves.Fix
When the new
ForkRetrivePerformRelaydapp fork is active, a successful perform in theForkRetriveAssetbranch now also executesUnRelateDB+Save, removing the retrieve relation and aligning with the semantics of the pre-asset-fork path. A second perform is then rejected withErrRetrieveRelation.Fork gating
ForkRetrivePerformRelayregistered inplugin/dapp/retrieve/types(default height 0), following the existingForkRetrive/ForkRetriveAssetnaming style.chain33.fork.tomlandchain33.para.tomlupdated with the correspondingForkRetrivePerformRelayentry, following theForkEVMFixOverflowpattern.Tests
New regression tests in
plugin/dapp/retrieve/executor/retrieve_perform_replay_test.go:TestRetrievePerformClearRelationPostFork: after a successful perform the relation is cleared; a second perform is rejected; assets deposited to the default address afterwards stay untouched.TestRetrievePerformReplayPreFork: pre-fork behavior is unchanged (relation kept after perform).TestRetrieveNormalFlowPostFork: normal backup/prepare/perform/cancel flow is unaffected post-fork.Verified with:
All existing and new tests pass.