`increaseLock()` should read `userDeposit[_receiver]` instead of `depositsOf[_msgSender()]`
The increaseLock function reads the caller's deposit instead of the receiver's deposit when calculating the remaining lock duration, which is used to determine the multiplier for minted shares. An attacker could cause the receiver to get more or fewer shares than intended by exploiting the difference in remaining durations.
Source: https://github.com/sherlock-audit/2022-10-merit-circle-judging/issues/102
Found by
HonorLt, saian, Zarf, WATCHPUG, hyh, CodingNameKiki, rvierdiiev
Summary
TimeLockPool.sol#L203 should read depositsOf[_receiver][_depositId] as userDeposit.
Vulnerability Detail
TimeLockPool.sol#L230 in increaseLock() is loading depositsOf[_msgSender()][_depositId] as userDeposit, which will later be used to check if the deposit has expired (L206-208) and calculating the remainingDuration (L213).
This remainingDuration will be used to calculate the multiplier for the mintAmount at L215.
Impact
As a result, the _receiver can receive a much larger shares.
For example, if the receiver only has 10 mins left in depositsOf[_receiver][_depositId], but depositsOf[_msgSender()][_depositId] have 4 years left. The mintAmount will be 5x than expected.
Or fewer shares than expected when the caller's deposit's remainingDuration is shorter than the receiver's.
Code Snippet
Tool used
Manual Review
Recommendation
Change L203 to:
Deposit memory userDeposit = depositsOf[_receiver][_depositId];
Discussion
federava
Agree on the recommendation, thanks!
federava
PR from this issue
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
The code uses the caller's deposit (depositsOf[_msgSender()]) instead of the receiver's deposit (depositsOf[_receiver]) when computing the remaining lock duration.
Impact
The receiver could receive a much larger or smaller number of shares than expected, depending on the difference in remaining lock durations between the caller and the receiver.
What the attacker needed
Caller and receiver have different remaining lock durations
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.
In a smart contract, a function called increaseLock is supposed to add more tokens to a specific deposit. But it mistakenly looks at the wrong person's deposit when calculating how much time is left. This can make the reward calculation wrong, giving too many or too few shares to the receiver.
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.