Auditing a Non-Custodial Card-Payment Protocol on Aptos
The ledger reserved the money. The ownership model still let it leave.
A card-payment protocol makes a simple promise: once money is reserved for a purchase, it will remain available for settlement until the reservation is captured, released, or expires. In a recent private Aptos audit, that promise led us beyond the payment functions and into the framework's object ownership model.
These anonymized field notes explain how we mapped the system, combined manual review with AI, and verified an ownership issue that I assessed as Medium severity. The lesson is useful beyond card payments: application rules protect funds only if every route for moving those funds respects them.
Model the payment before reading the code
Users deposited stablecoins into individual vaults. An authorized operator submitted payment actions; an admin configured operators, settlement destinations, limits, and pause controls. The operator was a privileged backend role, so its permissions and limits were part of the threat model.
We tracked three quantities: available, the amount a user could spend or withdraw; held, the amount reserved for pending payments; and the actual tokens backing both. Those tokens lived in an Aptos Fungible Asset store, the framework resource that holds an asset balance. Available and held were entries in the application’s ledger, not separate token balances.
| Action | Ledger effect | Token movement |
|---|---|---|
| Deposit | Available increases | Tokens enter the vault |
| Authorize | Available becomes held | None |
| Capture | Held decreases | Tokens leave for settlement |
| Void or expire | Uncaptured hold becomes available | None |
| Withdraw | Available decreases | Tokens return to the user |
In card-payment terms, authorization reserves money, capture collects it for settlement, and voiding releases an unused reservation. An expiry flow releases the remaining hold according to the protocol’s rules.
For each vault, the key backing rule, or invariant, was:
actual vault USDC balance >= available + held
All three amounts must refer to the same asset and use the same units. The inequality allows extra tokens, such as a direct transfer that the ledger has not credited. It does not allow recorded balances to exceed their backing. Other approved assets needed separate accounting: depositing another token did not automatically create a USDC credit.
Review functions as connected state transitions
We read the vault, payment, request-deduplication (idempotency), configuration, and swap math modules line by line, then followed their calls across module boundaries. A payment action could update an authorization record, vault balances, spending counters, settlement limits, and events in one transaction.
For each flow, we recorded who signed the transaction, which permissions were checked, how balances and spending counters changed, and the payment’s final status. We checked partial captures, repeated request identifiers, expired authorizations, and the boundaries of daily and 30-day spending windows. For example, releasing an old reservation must not reduce spending counted in a new window and accidentally restore that window’s allowance.
Swaps added a second accounting boundary: input and output assets, decimal scaling, rounding, fees, minimum received amounts, and the final USDC credit had to agree. A mock swap adapter could test that bookkeeping, but validating a production integration required checking the real adapter and its execution behavior.
This gave each function a concrete obligation. Authorization moves an amount from available to held without changing their sum or moving tokens. Capture reduces held funds and actual assets by the captured amount. Release moves only the uncaptured remainder back to available.
The Medium finding: reserved did not mean locked
The vault’s withdrawal function checked the available balance. The vault object also had ungated object transfers disabled. Those controls looked reassuring until we drew the ownership tree:
User account
└─ owns the vault object
└─ owns the USDC store
The important distinction is between changing who owns an object and withdrawing tokens from an asset store. Disabling ungated transfers restricts ordinary ownership transfers of the object; it does not remove the owner’s identity or all permissions associated with ownership. The Aptos object module defines those transfer and ownership rules.
In the reviewed dependency, Fungible Asset withdrawal authorization recognized indirect ownership through object::owns. The user remained the root owner of the asset store. Framework-authorized asset movement could therefore happen outside the vault’s withdrawal checks. The Fungible Asset module documents this ownership check alongside separate store-freeze and withdrawal-hook checks. These links describe the published framework; the audit’s behavior was tested against its pinned dependency version.
Keeping an ExtendRef private did not solve this. An ExtendRef is a capability that lets a module generate a signer for its object. Protecting it controlled access to that signer, but did not remove the user’s separate permissions as an indirect owner of the store.
| State | Actual balance | Available | Held |
|---|---|---|---|
| After a 100 deposit and 40 reservation | 100 | 60 | 40 |
| After assets leave outside the vault ledger | 0 | 60 | 40 |
The second row breaks the invariant: zero tokens back a recorded obligation of 100. A later capture fails because its reserved funds are gone. That failure does not undo an earlier, committed asset movement. The application’s own freeze and pause flags could not block a route that did not consult them. Those flags are distinct from a framework-level frozen asset store, which has its own withdrawal checks.
The concrete impact was a broken settlement guarantee. The owner could remove funds reserved for their own pending payment. Merchant loss would depend on goods or credit being released against the authorization; we did not establish live merchant losses.
Local regression tests used a synthetic Fungible Asset against the pinned framework. They demonstrated the balance mismatch, failed capture, and persistence of the framework route during application freeze and pause. They did not validate the deployed USDC configuration, asset-specific withdrawal hooks, or a live card processor. The example therefore demonstrates the accounting failure under the tested configuration, not a confirmed failure of every USDC deployment.
The recommended design change was to keep the asset-holding object outside the user’s ownership tree, while recording the user’s entitlement in application state. That change also needs a review of every capability that can move assets. Every exit must enforce the reservation policy. A design described as non-custodial must explain which withdrawals users can make independently and which commitments temporarily restrict them.
How manual review and AI worked together
We used AI for focused explanations, review hypotheses, cross-module tracing, and candidate regression tests. Manual review established the money model and challenged each claim against the specification and pinned dependencies.
The useful review unit was a specific claim with evidence requirements:
Trace this payment transition across its callers and dependencies. Identify who can invoke it, which balances and permissions change, and what evidence would confirm or disprove a mismatch. Check known issues and scope before proposing a finding.
For every candidate, we required a reachable path, the authority needed, an observable state change, and concrete impact. We also asked what existing check would defeat the claim. Passing a test established behavior; severity still required judgment.
We maintained a known-issues record as findings were submitted. This kept later AI reviews focused on different root causes instead of rediscovering the same ownership issue under new titles. My AI audit workflow notes cover the broader process.
What we did not escalate
A read-only spending view returned counters from expired windows, while payment execution reset them correctly before enforcing limits. The display could mislead a user or an integration, but the behavior we verified did not bypass the spending limit.
A final payment status could suggest a full void after a partial capture. Captured amounts remained recorded and balances stayed correct. We treated it as a reconciliation inconsistency; financial loss from a downstream interpretation was unproven.
We also checked pause behavior against the specification. A card pause intentionally left some other operations available. A control with a narrow documented purpose should not be reported as broken merely because its name suggests a broader one.
These distinctions mattered. In Move, an abort rolls back the transaction’s application-state changes; transaction fees can still apply. A suspicious intermediate state, an admin configuration mistake, and a committed accounting failure need different evidence and different severity assessments.
A checklist for card-payment protocol audits
- Draw both the fund flow and the framework ownership tree.
- Keep actual token backing separate from available and reserved balances.
- Trace every asset exit, including framework permissions outside application entry points.
- Test payment sequences, retries, partial settlement, expiry, and independent time windows.
- Match pause controls to their documented scope and incident response purpose.
- Require evidence of reachability and impact before promoting an AI hypothesis into a finding.
Auditing a non-custodial card-payment protocol means proving that user control and payment commitments coexist. Here, the ledger enforced a reservation that the underlying ownership model did not. That boundary deserves explicit review in Aptos Move security audits.
Follow-up: New Code, Old Vaults explains the ownership fix and why a creation change also needs a plan for existing vaults and their payment holds.