Platform: Code4rena
Start Date: 22/05/2024
Pot Size: $20,000 USDC
Total HM: 6
Participants: 126
Period: 5 days
Judge: 0xsomeone
Total Solo HM: 1
Id: 379
League: ETH
Rank: 61/126
Findings: 1
Award: $0.01
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: Circolors
Also found by: 0rpse, 0x175, 0xAadi, 0xHash, 0xMax1mus, 0xMosh, 0xblack_bird, 0xdice91, 0xfox, 0xhacksmithh, 0xloscar01, 0xrex, 4rdiii, Audinarey, AvantGard, Bigsam, DPS, Dots, Drynooo, Dudex_2004, Evo, Kaysoft, King_, Limbooo, MrPotatoMagic, PENGUN, Sabit, SovaSlava, SpicyMeatball, TheFabled, Utsav, Varun_05, Walter, adam-idarrha, araj, aslanbek, ayden, bctester, biakia, bigtone, brgltd, carrotsmuggler, cats, crypticdefense, dd0x7e8, dhank, fandonov, fyamf, grearlake, iamandreiski, ilchovski, jasonxiale, joaovwfreire, lanrebayode77, m4ttm, merlinboii, niser93, nnez, octeezy, oxchsyston, pamprikrumplikas, rouhsamad, tedox, trachev, turvy_fuzz, twcctop, yotov721, zhaojohnson
0.0056 USDC - $0.01
https://github.com/code-423n4/2024-05-munchables/blob/57dff486c3cd905f21b330c2157fe23da2a4807d/src/managers/LockManager.sol#L275-L295 https://github.com/code-423n4/2024-05-munchables/blob/main/src/managers/LockManager.sol#L311-L398
A malicious user can use the lockOnBehalf
function to extend the _lockDuration
of other users so that they can not unlock and withdraw their deposits.
The main issue is that lockOnBehalf
function allows a user to pass any address as _onBehalfOf
parameter. The second issue is that _quantity
can be zero.
With this two issues, it will only cost the attacker, the transaction fee to extend any user's lock duration by frontrunning their unlock transaction. And the transaction fee to achieve that on Blast network will not cost up to $1.
Below is the lockOnBehalf
function with calls the _lock(...)
internal function allowing the user to pass _onBehalfOf
address parameter.
File: LockManager.sol function lockOnBehalf( address _tokenContract, uint256 _quantity, address _onBehalfOf ) external payable notPaused onlyActiveToken(_tokenContract) onlyConfiguredToken(_tokenContract) nonReentrant { address tokenOwner = msg.sender; address lockRecipient = msg.sender; if (_onBehalfOf != address(0)) { 289: lockRecipient = _onBehalfOf; } _lock(_tokenContract, _quantity, tokenOwner, lockRecipient); }
Online 289
above, _onBehalfOf
is assigned to the lockRecipient
then the lockRecipient
is passed to the internal _lock
. Since any user can execute transaction to updated the state of lockRecipient
, An attacker can take advantage of this by calling the lockOnBehalf
function with the victim's address as the _onBehalfOf
parameter. The attacker can also pass zero as the _quantity
parameter which will make it even cheaper to exploit since _quantity
is not validated against zero values.
unlock
his 100ETHlockOnBehalf
function passing Bob's address as _onBehalfOf
parameter and zero as _quantity
lockedToken.unlockTime
has been extended to a new timestamp in the future by Alice's transaction in #3 & #4lockOnBehalf
function at any time without even waiting for the user to want to unlock their asset.Here is the _lock
internal function: https://github.com/code-423n4/2024-05-munchables/blob/57dff486c3cd905f21b330c2157fe23da2a4807d/src/managers/LockManager.sol#L311C5-L398C6
Manual review
Consider removing the lockOnBehalf
function since the _onBehalfOf
address parameter of the function can be used to extend lockedToken.unlockTime
of users.
Other
#0 - c4-judge
2024-06-05T12:58:00Z
alex-ppg marked the issue as satisfactory
#1 - c4-judge
2024-06-05T13:00:02Z
alex-ppg changed the severity to 3 (High Risk)