New Code, Old Vaults: Reviewing an Aptos Security Fix
New vaults follow the new rules. Old vaults may still have the old permissions.
A user deposits 100 USDC into a vault. A card purchase reserves 40. The app should let the user withdraw only the remaining 60.
During a private audit of an Aptos Move payment protocol, we found an ownership bug that let the owner move all 100 outside the app’s withdrawal checks. The app could still show 40 reserved for a payment even after the money was gone.
The fix changed how new vaults were created. Our fix review checked whether that change stopped the bug. It also raised a second question: what happens to vaults that already exist? The examples below are general explanations of the issue and fix.
Why the withdrawal check was not enough
The app tracked free funds that users could spend or withdraw, and reserved funds for pending payments. The tokens themselves lived in an Aptos Fungible Asset store: an on-chain container for the asset. The vault needed enough tokens to cover both amounts:
Vault tokens >= free + reserved
The app’s withdrawal function checked the free balance. But Aptos also recognized the user as the owner of the vault object, which owned the token store:
User account
└─ owns the vault object
└─ owns the token store
Aptos’s built-in asset code accepted that ownership as permission to move the tokens. This gave the user a route around the app’s checks. Preventing transfer of the vault object did not remove the user’s permission to withdraw its tokens. The Aptos framework documents these rules in its object ownership APIs and Fungible Asset withdrawal checks.
The result could be 60 free and 40 reserved in the app’s records, backed by zero USDC. The later attempt to settle the payment would fail. Our card-payment protocol audit notes explain the original finding in more detail.
The fix changed the ownership boundary
The fix separated two things: the user’s right to manage their vault through the app, and the permission to move its tokens directly through Aptos.
New vaults were set up so the app still recognized the user as their owner, but the user’s account no longer owned the token store through the framework. The module kept the authority needed to process withdrawals and payments.
This is a general view of the change, without the private contract code:
Before
User → direct token access
After
User → app checks → tokens
The user could still withdraw free funds through the app. They could no longer use framework ownership to skip its checks. Local tests confirmed that the framework’s standard and dispatchable transfer paths both rejected direct transfers by the user for these new vaults.
Existing vaults kept their old state
The new ownership setup runs when a vault is created. Updating the module does not automatically create old vaults again or change their stored owner.
Aptos compatible package upgrades allow code changes while keeping existing stored data readable. Passing that compatibility check does not mean old permissions have been fixed. The release needs to change the affected state or safely stop using the old vaults.
| Property | Existing vault | New vault |
|---|---|---|
| Code in use | Updated | Updated |
| Framework owner | User | Outside the user’s ownership tree |
| Direct token access | Still allowed | Blocked for the user |
Our first question was whether any old vaults would stay in use. We had verified the fix for new vaults and identified what would remain unchanged in old ones. We had not found a live loss.
The team later confirmed that mainnet would launch fresh at a new address. They said the old internal deployment held no user funds and would be retired, with no pre-fix vaults carried over. That resolves the migration concern for their planned mainnet launch.
For a live protocol that keeps old vaults active, the fix still needs to cover those vaults and their pending payments. Publishing another package alone does not move their funds or remove their old permissions. Testnet versus mainnet is a separate question: either network can receive a fresh deployment or an upgrade.
Test old vaults as well as new ones
Creating a vault with the fixed code tests the new setup. To check an upgrade, start with a vault created under the old code too.
A useful upgrade test would:
- Create and fund a vault using the original package.
- Reserve some funds for a payment.
- Apply the upgrade and migration to that same vault and its stored data.
- Check who can move tokens from both the old vault and a newly created one.
- Confirm the pending payment can still settle or be cancelled correctly, without releasing reserved funds early or counting them twice.
Our local tests checked the restrictions on new vaults. For old vaults, we traced ownership and built a test example with the same ownership structure. We did not run a full upgrade simulation. A review should state exactly what its tests prove and what still needs checking.
Plan how the fix reaches existing users
For protocol founders, the release plan needs to cover old vaults, their balances and pending payments. Moving free funds alone does not protect money already reserved for a purchase.
- Find affected vaults: record their actual tokens, free funds and reserved funds.
- Choose a migration plan: decide how old vaults will be moved or retired and how pending payments will finish.
- Keep the records consistent: payment IDs, spending limits and token balances must still agree after the move.
- Check every withdrawal route: an app pause cannot stop a framework transfer that never checks that pause.
- Verify the release: record the reviewed code version, deployed package, migration transactions and final checks.
For Move security researchers, this applies to any fix that changes how data or permissions are first set up. Check which old values survive the upgrade and whether the new code handles them safely.
A complete smart contract fix review checks the code change, the existing state, and the migration plan.