Skip to content
Crypto.world

The Ledger

Zealynx maps Aave V3.8’s reentrancy guard for integrators

A technical post by Zealynx details which Aave V3.8 Pool calls are guarded and which remain open during flash-loan callbacks. The post also reports different Pool revision numbers across networks and describes a way to probe whether the lock is active.

Zealynx maps Aave V3.8’s reentrancy guard for integrators

What the guard covers

A technical post by Zealynx on Aave’s governance forum maps which Aave V3.8 Pool operations take a reentrancy lock, which only check it, and what integrators can read during a flash-loan callback. Zealynx says V3.8 went live on Ethereum Core on November 11, citing payload 481 and block 26392162, and that `POOL_REVISION()` returns 12 on all 16 instances listed in the upgrade proposal.

The guarded state-changing calls listed in the post include supply, withdraw, borrow, repayment variants, liquidation, collateral and eMode settings, `mintToTreasury`, and the older `deposit` function. Zealynx also says `finalizeTransfer` is guarded, so an aToken transfer cannot settle during another Pool action; liquidations paying out in aTokens still work through `transferOnLiquidation`.

Flash loans and callbacks

Zealynx says `flashLoan`, `flashLoanSimple` and `rescueTokens` check whether the lock is set but do not set it themselves. That means a flash loan cannot be started from inside another Pool action, while calls made during `executeOperation` remain possible, as in V3.7. In a mainnet-fork test, Zealynx says supplying USDC from a `flashLoanSimple` callback succeeded.

To test a callback-triggering token, the post says Zealynx replaced USDC’s code on a fork with code that calls back during `transferFrom`, then supplied it. In that test, `flashLoanSimple`, `mintToTreasury` and a zero-value aUSDC transfer reverted with `ReentrancyGuardReentrantCall`, while `getUserAccountData` returned normally. Zealynx reports gas use was about 550 higher per guarded call in the snapshots cited.

Reads during a flash loan

The post says the flash-loan callback remains unlocked and describes how Pool readings can change within it. In a test borrowing all but 1 USDC from the Core USDC reserve, Zealynx says `getVirtualUnderlyingBalance` returned 1 USDC during the callback, while `maxWithdraw` for a stataUSDC holder with about 1.19M USDC of shares returned 0.999999 USDC; the values returned after repayment.

Zealynx attributes those readings to the Pool reducing `virtualUnderlyingBalance` before calling the receiver and updating rates after repayment. The post says a vault or router that sizes transfers from such reads could be shown an empty reserve during a transaction, for the flash premium, which it gives as 5 bps on Core “today.” It adds that the same behavior occurred in V3.7.

Checking deployment status

The post says the Pool has no public lock getter and that another contract cannot read its transient storage. Zealynx describes a `staticcall` to `mintToTreasury` with an empty array as a probe: if the lock is set, it reverts with selector `0x3ee5aeb5`; otherwise it reverts with empty data. The post says its fork test returned the selector inside a supply hook and empty data outside, and that the call was capped at 20k gas.

As of November 20, Zealynx listed revision 12 on Ethereum Core and Lido, Arbitrum, Base, Optimism, Polygon, Avalanche, BNB, Gnosis, Linea, Mantle, Celo, Plasma, Monad, X Layer and MegaETH. The post listed Scroll, Sonic and the EtherFi instance at revision 11; zkSync, Metis and Soneium at 10; and Horizon at 7. AaveLabs’ earlier proposal says the rollout covers active instances, while Zealynx advises checking `POOL_REVISION()` on each chain rather than assuming the guard is present everywhere.

Sources

  1. Original source Aave governance forum · Aave v3 for integrators what the reentrancy guard covers an… governance.aave.com

Other pages read

  1. Aave governance forum · Arfc Aave v3 governance.aave.com

Companies in this story

Related stories

Explore

More articles