Skip to content
Business logic Audit finding Intermediate

`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.

HonorLt Follow with saian, Zarf and 4 others

Originally disclosed on Sherlock

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

https://github.com/sherlock-audit/2022-10-merit-circle/blob/main/merit-liquidity-mining/contracts/TimeLockPool.sol#L197-L222

Tool used

Manual Review

Recommendation

Change L203 to:

Solidity
Deposit memory userDeposit = depositsOf[_receiver][_depositId];

Discussion

federava

Agree on the recommendation, thanks!

federava

PR from this issue

The original report as published on Sherlock, by HonorLt. 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

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.

More by HonorLt

View all

13 more disclosed reports, best first.

More from Merit Circle

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.