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

Snapshot of user's balance can be manipulated #117

Closed
code423n4 opened this issue Aug 26, 2022 · 1 comment
Closed

Snapshot of user's balance can be manipulated #117

code423n4 opened this issue Aug 26, 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 invalid This doesn't seem right

Comments

@code423n4
Copy link
Contributor

Lines of code

https://github.com/code-423n4/2022-08-nounsdao/blob/main/contracts/base/ERC721Checkpointable.sol#L163-L194

Vulnerability details

Impact

A malicious user is able to vote with more vote than he actually has thus having more say in proposals where his manipulated balance is valid.

Description

This attack vector is possible because ERC721Checkpointable.getPriorVotes() looks at a snapshot of a user's balance at a particular block. A malicious user can borrow Nouns from a lending platform (e.g. NFTx, NFTfi) to inflate their Nouns balance before a proposal is created. Once the proposal is created, they will return the borrowed asset.

When the proposal is becomes active and castVote() is called, ERC721Checkpointable.getPriorVotes() will look at the user's inflated Nouns balance before the proposal was created thereby giving them more influence over the voting.

Proof of Concept

  • Discussion takes place on the forum
  • A user with vested interest to pass the proposal will borrow Nouns before this proposal is created
  • The Proposal is created
  • The user then returns borrowed assets
  • When the proposal becomes active, the user will have inflated voting rights because of the snapshot.

Tools Used

Manual analysis

Recommended Mitigation Steps

  • Since checkpoints are already used in beforeTokenTransfer, it should be possible to also introduce a time weighted average balance (similar to that of Uniswap's TWAP) to be used specifically for voting. This lag will make it harder / more expensive to perform this snapshot attack and because this "weighted balanceOf", it does not have an impact on the standard functionality of an ERC721 token.
@code423n4 code423n4 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 Aug 26, 2022
code423n4 added a commit that referenced this issue Aug 26, 2022
@eladmallel
Copy link
Collaborator

Duplicate of #140

@eladmallel eladmallel marked this as a duplicate of #140 Aug 29, 2022
@eladmallel eladmallel added the duplicate This issue or pull request already exists label Aug 29, 2022
@gzeoneth gzeoneth added the invalid This doesn't seem right label Sep 18, 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 invalid This doesn't seem right
Projects
None yet
Development

No branches or pull requests

3 participants