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

Incorrect oldLocked value passed in VotingEscrow._checkpoint in VotingEscrow.increaseUnlockTime when locked_.delegatee == msg.sender #134

Closed
code423n4 opened this issue Aug 15, 2022 · 1 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 duplicate This issue or pull request already exists

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L513

Vulnerability details

Impact

Detailed description of the impact of this finding.

oldLocked and locked_ are basically same as oldLocked is a copy of locked_ LockedBalance memory oldLocked = _copyLock(locked_); and then oldLocked.end is being assigned the new unlock time unlock_time oldLocked.end = unlock_time;, which results in no change. These are being passed into _checkpoint(msg.sender, oldLocked, locked_); which results in incorrect checkpoint math.

Proof of Concept

Provide direct links to all referenced code in GitHub. Add screenshots, logs, or any other relevant proof that illustrates the concept.

locked_ is being assigned unlock_time here https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L507 and when locked_.delegatee == msg.sender, oldLocked is created as a copy of locked_ here https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L512 but instead of assigning oldUnlockTime, unlock_time which is the new unlock end timestamp is being assigned to oldLocked.end here https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L513 making oldLocked and locked_.

As oldLocked and locked_ being same are passed into _checkpoint(msg.sender, oldLocked, locked_); here https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L514 it results in incorrect calculations of userOldPoint.bias and pointHistory in lines https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L240 , https://github.com/code-423n4/2022-08-fiatdao/blob/fece3bdb79ccacb501099c24b60312cd0b2e4bb2/contracts/VotingEscrow.sol#L372

Tools Used

Manual Review

Recommended Mitigation Steps

set oldLocked to old unlock time

oldLocked.end = oldUnlockTime;
@code423n4 code423n4 added 3 (High Risk) Assets can be stolen/lost/compromised directly bug Something isn't working labels Aug 15, 2022
code423n4 added a commit that referenced this issue Aug 15, 2022
@lacoop6tu lacoop6tu added the duplicate This issue or pull request already exists label Aug 16, 2022
@lacoop6tu
Copy link
Collaborator

Duplicate of #217

@lacoop6tu lacoop6tu marked this as a duplicate of #217 Aug 16, 2022
@gititGoro gititGoro added 2 (Med Risk) Assets not at direct risk, but function/availability of the protocol could be impacted or leak value and removed 3 (High Risk) Assets can be stolen/lost/compromised directly labels Sep 2, 2022
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 duplicate This issue or pull request already exists
Projects
None yet
Development

No branches or pull requests

3 participants