Reproduced Exploit

Aegis — withdrawing reverts because the vault cannot forward BGT

BGT transfers only succeed for whitelisted senders. The Berachain rewards vault is whitelisted, so it can pay BGT into the Aegis vault. The Aegis vault is not whitelisted, so it cannot forward that balance to the farming contract.

Sep 2024•Other•dependency•3 min read

Chain

Other

Category

dependency

Date

Sep 2024

Source

AuditVault

EVM Playground

Source-level debugger — step opcodes and Solidity in sync

evm-hack-analyzer

The attack is replayed in an in-browser EVM preloaded with the exact dumped fork state. The execution tree shows every call; step by Solidity line or by opcode across all depths — source, Stack, Memory, Storage, Balances (native / ERC-20 / NFT), Transient storage and Return value stay in sync. Click a tree node, opcode, or source line to jump. Query opens a search over the trace: previous and next writes, balance changes and calls, breakpoints, and a diff of everything that changed between two steps. No backend, no live RPC.

Loading fork state…

Source & credit. Reproduction of a public audit finding curated by AuditVault — the original finding: 41320-h-01-potential-issues-that-can-arise-from-bgt-being-reward-t. Standalone Foundry PoC and full write-up: 41320-h-01-potential-issues-that-can-arise-from-bgt-being-reward-t_exp in the evm-hack-registry mirror.


Vulnerability classes: vuln/dependency/unsafe-external-call · vuln/dos/frozen-funds

Reproduction: a self-contained Foundry PoC that compiles and runs offline with only forge-std — no fork and no RPC. Trace: output.txt. PoC: test/41320-h-01-potential-issues-that-can-arise-from-bgt-being-reward-t_exp.sol.


Key info#

ImpactHIGH — a depositor cannot withdraw 1,000 assets; they stay in the vault
ProtocolAegis vault _transferRewardsToFarmingContract with BGT as REWARD_TOKEN
Vulnerable codebgt.transfer(farming, rewardBalance) from a sender BGT has not approved
Bug classReward forward ignores BGT's approved-sender rule and bricks _preAction
FindingPashov H-01 — Aegis, September 2024 · id 41320
ReportAegis security review
SourceAuditVault finding
Compilersolc 0.8.27, cancun, via IR

TL;DR#

BGT transfers only succeed for whitelisted senders. The Berachain rewards vault is whitelisted, so it can pay BGT into the Aegis vault. The Aegis vault is not whitelisted, so it cannot forward that balance to the farming contract.

withdraw always runs _preAction, which claims and then calls transfer. The transfer reverts, the whole withdrawal reverts, and the depositor's 1,000 assets stay in the vault. Shares are not burned.

The fixed withdraw claims the reward and skips the forward when isWhitelistedSender(vault) is false. The depositor then receives the 1,000 assets, and the BGT stays in the vault instead of reverting the exit.

The vulnerable code#

SOLIDITY
uint256 rewardBalance = bgt.balanceOf(address(this));
if (rewardBalance > 0) {
    bgt.transfer(farming, rewardBalance); // @> VULN: vault is not an approved BGT sender
}
DIFF
-if (rewardBalance > 0) {
+if (rewardBalance > 0 && bgt.isWhitelistedSender(address(this))) {
     bgt.transfer(farming, rewardBalance);
 }

Attack walkthrough#

  1. Staking is on. The rewards vault holds 50 BGT and is an approved sender. The Aegis vault is not. A depositor has 1,000 shares backed by 1,000 assets.
  2. The depositor calls withdraw(1000). The share check passes.
  3. _preAction claims the BGT into the vault, then transfer to the farming contract reverts with "Not approved sender".
  4. The catch path observes the revert. Shares are still 1,000. The depositor's asset balance is still 0. The vault still holds 1,000.

Diagrams#

flowchart TD A["Depositor calls withdraw"] --> B["preAction claims BGT from the rewards vault"] B --> C["Vault calls BGT.transfer to the farming contract"] C --> D["BGT rejects the unapproved sender"] D --> E["Withdraw reverts and 1000 assets stay in the vault"]

Impact#

While staking is enabled and the reward token is BGT, depositors cannot exit. The 1,000 assets in this position are frozen. The same _preAction path is what the review says also breaks deposits, collectRewards, and setStakingStatus.

Sources#


Sources & further analysis#

Reproductions & code

Alerts & third-party analyses

  • Web3Sec X hacked database: search.
  • Rekt leaderboard: search.
  • Solodit incident search: search.

These dashboards index community alerts tweets, post-mortems, and independent write-ups. Reach them through the protocol name above to cross-check this reproduction against other analyses.