Munchables - turvy_fuzz's results

A web3 point farming game in which Keepers nurture creatures to help them evolve, deploying strategies to earn them rewards in competition with other players.

General Information

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

Munchables

Findings Distribution

Researcher Performance

Rank: 39/126

Findings: 2

Award: $0.02

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2024-05-munchables/blob/main/src/managers/LockManager.sol#L383 https://github.com/code-423n4/2024-05-munchables/blob/main/src/managers/LockManager.sol#L290

Vulnerability details

Impact

Attacker can constantly keep increasing the unlocktime of any user without needing permission, prevent any user they wish from unlocking

Proof of Concept

The lockOnBehalf() function allows anyone to lock on behalf of any user:

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)) {
  @>        lockRecipient = _onBehalfOf;
        }

        _lock(_tokenContract, _quantity, tokenOwner, lockRecipient);
    }

note that there is no minimum amount required to call this function, meaning it can be calling with 1wei. Also note that there is no permission required to call the function for any user. The issue here is that on end of the _lock() function it updated the recipients unlockTime:

        lockedToken.unlockTime =
            uint32(block.timestamp) +
            uint32(_lockDuration);

This allows attackers the ability to keep increasing the unlocktime of any user without needing permission, prevent any user they wish from unlocking.

Tools Used

Manual Review

Allow users to grant permission on who can lock onbehalf of them

Assessed type

Access Control

#0 - c4-judge

2024-06-05T12:58:21Z

alex-ppg marked the issue as satisfactory

Lines of code

https://github.com/code-423n4/2024-05-munchables/blob/main/src/managers/LockManager.sol#L257 https://github.com/code-423n4/2024-05-munchables/blob/main/src/managers/LockManager.sol#L266

Vulnerability details

Impact

People can reduce lockup times that were previously set. Breaking the core invariant of the protocol as mentioned in the doc:

The most important thing is that funds cannot get locked forever, people cannot take other people's funds, and that people cannot reduce lockup times that are previously set.

Proof of Concept

The setLockDuration() allows users to update their lockDuration however must not be able set the new lock time before current unlocktime, this check is done here:

// check they are not setting lock time before current unlocktime
                if (
@>                  uint32(block.timestamp) + uint32(_duration) <
                    lockedTokens[msg.sender][tokenContract].unlockTime
                ) {
                    revert LockDurationReducedError();
                }

Notice it uses block.timestamp in comparing the new time in the if() condition. However, upon making the actual update it uses lastLockTime:

lockedTokens[msg.sender][tokenContract].unlockTime =
                    lastLockTime +
                    uint32(_duration);

This allows user to reduce their unlockTime after some time has passed.

Tools Used

Manual Review

Consider making this changes:

lockedTokens[msg.sender][tokenContract].unlockTime =
+                   uint32(block.timestamp) +
-                   lastLockTime +
                    uint32(_duration);

Assessed type

Other

#0 - c4-judge

2024-06-04T12:40:53Z

alex-ppg marked the issue as duplicate of #89

#1 - c4-judge

2024-06-05T12:53:47Z

alex-ppg marked the issue as partial-75

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter