Submitted by 0xpiken, also found by 0xlemon, MrPotatoMagic, and shaflow2
https://github.com/code-423n4/2024-12-bakerfi/blob/main/contracts/core/VaultRouter.sol#L186-L202
https://github.com/code-423n4/2024-12-bakerfi/blob/main/contracts/core/VaultRouter.sol#L234-L252
Once a user approves VaultRouter to spend their ERC20 tokens, anyone could call VaultRouter#execute() to drain the users ERC20 assets.
The VaultRouter#execute() function allows users to perform multiple commands within a single transaction. One such use case involves depositing ERC20 tokens into VaultRouter using the PULL_TOKEN command. Subsequently, these tokens can be further processed within the same transaction through other commands, such as V3_UNISWAP_SWAP for token swaps or ERC4626_VAULT_DEPOSIT for depositing into an ERC4626 vault.
Before depositing ERC20 tokens into VaultRouter using the PULL_TOKEN command, the user must approve VaultRouter to spend their ERC20 token in advance.  However, a malicious actor can exploit this approval to drain the users ERC20 token through VaultRouter with PULL_TOKEN_FROM or PUSH_TOKEN_FROM commands:
The root cause is that either PULL_TOKEN_FROM or PUSH_TOKEN_FROM command allows anyone to transfer a users ERC20 token as long as VaultRouter is approved to spend their assets:
https://github.com/code-423n4/2024-12-bakerfi/blob/main/contracts/core/hooks/UseTokenActions.sol
Copy below codes to VaultRouter.ts and run npm run test:
As we can see, owners all WETH was drained.
To protect users from potential exploitation, the PULL_TOKEN_FROM and PUSH_TOKEN_FROM commands should be executed only when msg.sender is from.
chefkenji (BakerFi) confirmed
BakerFi mitigated:
Status: Mitigation confirmed. Full details in reports from 0xlemon and shaflow2.
