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.
Chain
Other
Category
dependency
Date
Sep 2024
Source
AuditVault
EVM Playground
Source-level debugger — step opcodes and Solidity in sync
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.
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-registrymirror.
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#
| Impact | HIGH — a depositor cannot withdraw 1,000 assets; they stay in the vault |
| Protocol | Aegis vault _transferRewardsToFarmingContract with BGT as REWARD_TOKEN |
| Vulnerable code | bgt.transfer(farming, rewardBalance) from a sender BGT has not approved |
| Bug class | Reward forward ignores BGT's approved-sender rule and bricks _preAction |
| Finding | Pashov H-01 — Aegis, September 2024 · id 41320 |
| Report | Aegis security review |
| Source | AuditVault finding |
| Compiler | solc 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#
uint256 rewardBalance = bgt.balanceOf(address(this));
if (rewardBalance > 0) {
bgt.transfer(farming, rewardBalance); // @> VULN: vault is not an approved BGT sender
}
-if (rewardBalance > 0) {
+if (rewardBalance > 0 && bgt.isWhitelistedSender(address(this))) {
bgt.transfer(farming, rewardBalance);
}
Attack walkthrough#
- 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.
- The depositor calls
withdraw(1000). The share check passes. _preActionclaims the BGT into the vault, thentransferto the farming contract reverts with "Not approved sender".- 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#
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#
- AuditVault 41320
- Pashov Aegis review
- aegis-vault @ b88e991 —
_transferRewardsToFarmingContract
Sources & further analysis#
Reproductions & code
- Standalone PoC + full trace: 41320-h-01-potential-issues-that-can-arise-from-bgt-being-reward-t_exp (evm-hack-registry mirror).
- AuditVault finding: 41320-h-01-potential-issues-that-can-arise-from-bgt-being-reward-t.
Alerts & third-party analyses
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.