Skip to content
Business logic Audit finding Intermediate

LockPositionService::increaseLockTime Incorrect Calculation Extends Lock Duration Beyond Intended Period

The increaseLockTime function calculated lock duration from the current block timestamp rather than aligning to weekly cycle boundaries, so a user locking near the end of a cycle could have their tokens locked for an extra week. An attacker could not gain directly, but users could unintentionally extend their lock period and lose access to their assets for longer than intended.

bughuntoor Follow with cergyk, jah and 1 other

Originally disclosed on Sherlock

Source: https://github.com/sherlock-audit/2023-11-convergence-judging/issues/136

Found by

bughuntoor, cergyk, jah, rvierdiiev

Summary

LockPositionService::increaseLockTime uses block.timestamp for locking tokens, resulting in potential over-extension of the lock period. Specifically, if a user locks tokens near the end of a cycle, the lock duration might extend an additional week more than intended. For instance, locking for one cycle at the end of cycle N could result in an unlock time at the end of cycle N+2, instead of at the start of cycle N+2.

This means that all the while specifying that their $CVG should be locked for the next cycle, the $CVG stays locked for two cycles.

Vulnerability Detail

The function increaseLockTime inaccurately calculates the lock duration by using block.timestamp, thus not aligned to the starts of cycles. This discrepancy leads to a longer-than-expected lock period, especially when a lock is initiated near the end of a cycle. This misalignment means that users are unintentionally extending their lock period and affecting their asset management strategies.

Scenario:

  • Alice decides to lock her tokens for one cycle near the end of cycle N.
  • The lock duration calculation extends the lock to the end of cycle N+2, rather than starting the unlock process at the start of cycle N+2.
  • Alice's tokens are locked for an additional week beyond her expectation.

Impact

Code Snippet

https://github.com/sherlock-audit/2023-11-convergence/blob/main/sherlock-cvg/contracts/Locking/LockingPositionService.sol#L421

Tool used

Users may have their $CVG locked for a week more than expected

Recommendation

Align the locking mechanism to multiples of a week and use (block.timestamp % WEEK) + lockDuration for the lock time calculation. This adjustment ensures that the lock duration is consistent with user expectations and cycle durations.

Discussion

walk-on-me

Hello dear judge,

this issue has been solved.

In order to solve it, we decided that when a user comes for locking or increase it's lock, we'll not take anymore the one in the CvgControlTower. If an user decide to performs a lock action between the timestamp where the cycle is updated and the CVG distribution ( by the CvgRewards ). He'll just lock for the next week, having no incidence on protocol.

Remarks : We are keeping the cvgCycle of the CvgControlTower for :

Burning the NFT Claim the rewards of the Ys You can check how by following the comments done here :

https://github.com/Cvg-Finance/sherlock-cvg/pull/4#discussion_r1457499501 https://github.com/Cvg-Finance/sherlock-cvg/pull/4#discussion_r1457504596 https://github.com/Cvg-Finance/sherlock-cvg/pull/4#discussion_r1457504988 https://github.com/Cvg-Finance/sherlock-cvg/pull/4#discussion_r1457505267 https://github.com/Cvg-Finance/sherlock-cvg/pull/4#discussion_r1457508720 https://github.com/Cvg-Finance/sherlock-cvg/pull/4#discussion_r1457510511

IAm0x52

Fix looks good. Cycles are now aligned based on computed week rather than cvgControlTower

The original report as published on Sherlock, by bughuntoor. Images and videos are our own copies; raw HTML is shown as text. View it on Sherlock.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

How it worked

Root cause

Likely the lock duration was calculated from block.timestamp without rounding to the start of the current weekly cycle, so locks initiated late in a cycle extended into an extra cycle.

Impact

Users may have their $CVG locked for a week more than expected, affecting their asset management strategies.

What the attacker needed

User locks tokens near the end of a cycle

The fix

The locking mechanism was fixed by aligning cycles to computed weeks rather than the control tower's cycle, so locks taken between cycle update and reward distribution only lock for the next week.

How it was found

  1. Alice locks her tokens for one cycle near the end of cycle N.
  2. The lock duration calculation extends the lock to the end of cycle N+2 instead of the start of cycle N+2.
  3. Alice's tokens remain locked for an additional week beyond her expectation.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this report has not been written yet. The Original tab links to the source.

A smart contract lets people lock their tokens for a set number of weeks. The code measured the lock from the exact moment you clicked, not from the start of the week, so if you locked late in a week the lock could run one week longer than you expected. This is a logic mistake, not a way for someone to steal funds.

What is Business logic?

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.

More by bughuntoor

View all

16 more disclosed reports, best first.

More from Convergence

View all

The newest disclosed reports for this program.

Similar reports

View all

Same bug class and techniques, clearest first.

Business logic flaws

The lesson behind this report.

The application works as coded but not as intended: a negative price, a skipped payment step, a limit that can be crossed.