Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lock duration can be manipulated #608

Open
c4-bot-3 opened this issue May 27, 2024 · 0 comments
Open

Lock duration can be manipulated #608

c4-bot-3 opened this issue May 27, 2024 · 0 comments
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working edited-by-warden 🤖_03_group AI based duplicate group recommendation

Comments

@c4-bot-3
Copy link
Contributor

c4-bot-3 commented May 27, 2024

Lines of code

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

Vulnerability details

Impact

The lock duration can be set to a time before the existing unlock time

Proof of Concept

The lock duration check in setLockDuration only checks if the duration is below the current time + _duration, it however sets unlock time to lastLockTime + _duration

This can allow an user to set an unlock time before the existing unlock time.

~ Alice sets unlock time to time 2000.
Last time is now 1000, and _duration is 1000,

Time is now - 1500
Alice calls setLockDuration again with _duration as 501
The check 1500 + 501 > 2000 passes

However the unlock time would be mistakenly set as 1000 + 501 ~ 1501
allowing Alice to break the invariant and prepone the unlock time

Tools Used

Manual analysis

Recommended Mitigation Steps

use correct check that is
lastLockTime + uint32(_duration) < lockedTokens[msg.sender][tokenContract].unlockTime
instead of
uint32(block.timestamp) + uint32(_duration) < lockedTokens[msg.sender][tokenContract].unlockTime

Assessed type

Other

@c4-bot-3 c4-bot-3 added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working labels May 27, 2024
c4-bot-6 added a commit that referenced this issue May 27, 2024
@c4-bot-12 c4-bot-12 added the 🤖_03_group AI based duplicate group recommendation label May 27, 2024
howlbot-integration bot added a commit that referenced this issue May 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value bug Something isn't working edited-by-warden 🤖_03_group AI based duplicate group recommendation
Projects
None yet
Development

No branches or pull requests

3 participants