Manipulate Allocations from game using flashloans
A user can use flashloans to temporarily inflate their derby token balance and manipulate protocol allocations within a vault. This could direct funds into poorly performing protocols, potentially causing losses or unexpected behaviour.
Source: https://github.com/sherlock-audit/2023-01-derby-judging/issues/172
Found by
oot2k
Summary
A user can use flashloans to leverage the amount of derby token dedicated towards a certain protocol.
Vulnerability Detail
Consider the following scenario: A malicious user wants to manipulate DeltaAllocations to change the weight of some protocol inside vault. This works because the user can call pushAllocationsToController and pushAllocationsToVaults in the same transaction. https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/Game.sol#L424 https://github.com/sherlock-audit/2023-01-derby/blob/main/derby-yield-optimiser/contracts/Game.sol#L465
- They take a flashloan of USDC
- Swap the USDC into derby token on some dex
- Rebalance there basket using these tokens
- Call pushAllocationsToController
- Call pushAllocationsToVaults
- Rebalance there basket to get tokens back
- Swap tokens to USDC
- pay back loan
Impact
A User can use this to stake tokens into bad performing protocols, leading to possible lose of funds or unexpected behavior.
Code Snippet
Tool used
Manual Review
Recommendation
do not allow to call pushAllocationsToController and pushAllocationsToVaults in same transaction.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
How it worked
Root cause
Likely the ability to call pushAllocationsToController and pushAllocationsToVaults within the same transaction allows a temporary token balance to influence allocation weights.
Impact
A user could stake tokens into bad performing protocols, leading to possible loss of funds or unexpected behavior.
What the attacker needed
Access to a flashloan provider; a DEX with derby token liquidity; ability to call the two functions
The fix
The recommendation is to disallow calling pushAllocationsToController and pushAllocationsToVaults in the same transaction.
How it was found
- Take a flashloan of USDC
- Swap the USDC into derby token on some dex
- Rebalance their basket using these tokens
- Call pushAllocationsToController
- Call pushAllocationsToVaults
- Rebalance their basket to get tokens back, swap to USDC, and repay the loan
Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.
Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.
A flashloan is a loan that must be borrowed and repaid within the same transaction. Here, an attacker borrows a large amount of a stablecoin, swaps it for the project's token, uses that to influence how funds are allocated, then reverses the trades and repays the loan, all in one transaction.
What is Business logic?
The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.