Skip to content
Business logic Audit finding Intermediate

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.

oot2k Follow

Originally disclosed on Sherlock

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

  1. They take a flashloan of USDC
  2. Swap the USDC into derby token on some dex
  3. Rebalance there basket using these tokens
  4. Call pushAllocationsToController
  5. Call pushAllocationsToVaults
  6. Rebalance there basket to get tokens back
  7. Swap tokens to USDC
  8. 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.

The original report as published on Sherlock, by oot2k. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

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

  1. Take a flashloan of USDC
  2. Swap the USDC into derby token on some dex
  3. Rebalance their basket using these tokens
  4. Call pushAllocationsToController
  5. Call pushAllocationsToVaults
  6. 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.

More from Derby

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.