Munchables - bctester'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: 83/126

Findings: 1

Award: $0.01

🌟 Selected for report: 0

🚀 Solo Findings: 0

Lines of code

https://github.com/code-423n4/2024-05-munchables/blob/57dff486c3cd905f21b330c2157fe23da2a4807d/src/managers/LockManager.sol#L275

Vulnerability details

Impact

An attacker can use the lockOnBehalf function to continuously extend the lock time of any player, resulting in the player's tokens being permanently locked. Additionally, since there is no minimum token amount restriction for calling the lockOnBehalf function, the attack cost is very low.

Proof of Concept

The code for the lockOnBehalf function is as follows:

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); }

The code for extending the lock time in the _lock function is as follows:

function _lock( address _tokenContract, uint256 _quantity, address _tokenOwner, address _lockRecipient ) private { ... lockedToken.unlockTime = uint32(block.timestamp) + uint32(_lockDuration); }

The code for checking the unlockTime when unlocking is as follows:

function unlock( address _tokenContract, uint256 _quantity ) external notPaused nonReentrant { ... if (lockedToken.unlockTime > uint32(block.timestamp)) revert TokenStillLockedError(); ... }

By analyzing the above code, it can be seen that an attacker can extend the lock time of any player.

Tools Used

Add restrictions when extending the lock time for other players, such as only allowing addresses authorized by the player to extend the lock time, or limiting the minimum token amount.

Assessed type

Other

#0 - c4-judge

2024-06-05T12:57:59Z

alex-ppg marked the issue as satisfactory

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