Open howlbot-integration[bot] opened 5 months ago
alex-ppg marked the issue as primary issue
alex-ppg marked the issue as selected for report
alex-ppg marked the issue as satisfactory
The submission and its duplicates have demonstrated how a lack of access control in the LockManager::lockOnBehalfOf
function can lead to infinite locks and can sabotage lock duration changes.
This submission has been selected as the best given that it outlines both risks inherent to the lack of access control clearly and concisely while providing recommendations that align with best practices.
Submissions awarded with a 75% reward (i.e. penalized by 25%) either propose a mitigation that is incorrect or outline the lock duration adjustment problem which is of lower severity.
Submissions awarded with a 25% reward (i.e. penalized by 75%) are QA-reported issues that were improperly submitted as low-risk.
Lines of code
https://github.com/code-423n4/2024-05-munchables/blob/main/src/managers/LockManager.sol#L275
Vulnerability details
Impact
The protocol allows users to donate ether and/or tokens to another user via a
lockOnBehalf
function. This function lets the caller specify which address should be the recipient of these funds. However issues araise because thelockOnBehalf
deposit resets the receiverslockedToken.unlockTime
pushing the users unlock time for that token further back.The code in question:
Therefore if a user has already locked tokens in the protocol, a malicious user can repeatedly call
lockOnBehalf
shortly before the currentunlockTime
and keep delaying the users ability to withdraw their tokens. This is compounded by the fact that thelockOnBehalf
function has no minimum_quantity
therefore the attacker doesn't have to give up any of their own tokens to acheive this.Alternatively, this attack vector can also be used to deny a users ability to decrease their minimum lock duration. In this instance, the attacker would have to call
lockOnBehalf
with a non zero amount, meaning the following check insetLockDuration
would cause a revert and stop the user from decreasing their lock duration:Proof Of Concept
The following tests outline both of these attack vectors.
The tests can be copied into the
MunchablesTest
foundry test suite.Testing the
lockDuration
extension grief:This produces the following logs outlining the change in lock time:
Testing the
setLockDuration
grief:Recommended Mitigation
Other users having the power to extend a user's lock duration is inherently dangerous. The protocol should seriously consider whether the lockOnBehalf functionality is necessary outside of being used by the MigrationManager contract.
If it is decided that the team wishes for the project to retain the ability for users to "donate" tokens to other users there are a number approaches they can consider:
Assessed type
Other