maxTrainingDeposit can be bypassed
The deposit function checks the sender's current balance against a maximum training deposit limit, but a user can transfer their balance to another account and then deposit from the emptied account, bypassing the limit. An attacker could deposit more than the allowed maximum during the training phase.
c7e7eff Follow with chaduke and csanuragjain
Originally disclosed on Sherlock
Source: https://github.com/sherlock-audit/2023-01-derby-judging/issues/15
Found by
c7e7eff, chaduke, csanuragjain
Summary
It was observed that User can bypass the maxTrainingDeposit by transferring balance from one user to another
Vulnerability Detail
- Observe the
depositfunction
function deposit(
uint256 _amount,
address _receiver
) external nonReentrant onlyWhenVaultIsOn returns (uint256 shares) {
if (training) {
require(whitelist[msg.sender]);
uint256 balanceSender = (balanceOf(msg.sender) * exchangeRate) / (10 ** decimals());
require(_amount + balanceSender <= maxTrainingDeposit);
}
...
- So if User balance exceeds maxTrainingDeposit then request fails (considering training is true)
- Lets say User A has balance of 50 and maxTrainingDeposit is 100
- If User A deposit amount 51 then it fails since 50+51<=100 is false
- So User A transfer amount 50 to his another account
- Now when User A deposit, it does not fail since
0+51<=100
Impact
User can bypass maxTrainingDeposit and deposit more than allowed
Code Snippet
Tool used
Manual Review
Recommendation
If user specific limit is required then transfer should be check below:
require(_amountTransferred + balanceRecepient <= maxTrainingDeposit);
Discussion
sjoerdsommen
yes this is known, there is no solution to this and this is also not a huge problem
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 deposit limit is enforced only on the sender's current balance, not on the total amount deposited or transferred, so moving funds to another account resets the check.
What the attacker needed
Training mode is active; user is whitelisted; user has a second account
The fix
The transfer function should also check the recipient's balance against the limit, as suggested in the recommendation.
How it was found
- User A has a balance of 50 and the maxTrainingDeposit is 100.
- User A tries to deposit 51, which fails because 50+51 is greater than 100.
- User A transfers their 50 balance to another account.
- User A then deposits 51 from the now-empty account, which passes because 0+51 is less than or equal to 100.
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 smart contract has a rule that limits how much a user can deposit during a training period. The rule checks the user's current balance, but a user can move their existing balance to a second account and then deposit from the first account, which now has a zero balance, so the limit check passes. This lets the user put in more money than the rule intended.
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.