Nouns Builder contest - rotcivegaf's results

A permissionless, governed protocol to deploy nouns-style DAOs complete with treasury, generative collections, and governance mechanisms.

General Information

Platform: Code4rena

Start Date: 06/09/2022

Pot Size: $90,000 USDC

Total HM: 33

Participants: 168

Period: 9 days

Judge: GalloDaSballo

Total Solo HM: 10

Id: 157

League: ETH

Nouns Builder

Findings Distribution

Researcher Performance

Rank: 55/168

Findings: 1

Award: $235.61

🌟 Selected for report: 0

🚀 Solo Findings: 0

Findings Information

🌟 Selected for report: saian

Also found by: 0x4non, Ch_301, MEP, Picodes, PwnPatrol, R2, Soosh, davidbrai, izhuer, rotcivegaf, scaraven

Labels

bug
duplicate
3 (High Risk)

Awards

235.614 USDC - $235.61

External Links

Lines of code

https://github.com/code-423n4/2022-09-nouns-builder/blob/7e9fddbbacdd7d7812e912a369cfd862ee67dc03/src/lib/token/ERC721Votes.sol#L216

Vulnerability details

Impact

A malicious actor can overflow his number of votes

Proof of Concept

  1. Alice and Kane each have an NFT token
  2. Alice uses delegate function to delegate the vote to Kane
  3. Kane uses transferFrom to transfer his token to the address Alice
  4. Alice uses delegate function to delegate the vote to Mike(a new empty account)
  5. Finaly consult getVotes and Alice = 2, Kane = 6277101735386680763835789423207666416102355444464034512895 and Mike = 2

Look in: prevTotalVotes - _amount

Tools Used

Review

I don't have more time, I discovered this bug close to the deadline, but I reccomend add this line before _writeCheckpoint if (_amount > prevTotalVotes) _amount = prevTotalVotes; I was only able to do some testing and I think it works, but I'm not entirely sure

#0 - GalloDaSballo

2022-09-19T20:51:32Z

This looks odd as it's unclear how you'd get to a scenario where you get exactly 6277101735386680763835789423207666416102355444464034512895 votes.

Without context, that number looks pretty random

#1 - rotcivegaf

2022-09-19T21:35:57Z

Well, in L216 when use unchecked give the possibility to under/overflow, the prevTotalVotes - _amount in point 3 goes underflow, the _amount it's greater than prevTotalVotes

The magic number of 6277101735386680763835789423207666416102355444464034512895 comes from the cast of the L252, when cast 2256 - 1 to uint192 obtains 2192 - 1 = 6277101735386680763835789423207666416102355444464034512895 Also this cast it's unsafe, but it should be impossible to get this gigantic number of votes

#2 - GalloDaSballo

2022-09-19T21:53:05Z

Well, in L216 when use unchecked give the possibility to under/overflow, the prevTotalVotes - _amount in point 3 goes underflow, the _amount it's greater than prevTotalVotes

The magic number of 6277101735386680763835789423207666416102355444464034512895 comes from the cast of the L252, when cast 2256 - 1 to uint192 obtains 2192 - 1 = 6277101735386680763835789423207666416102355444464034512895 Also this cast it's unsafe, but it should be impossible to get this gigantic number of votes

I think it's unfair against other wardens for you to defend the report as I'm looking at it.

That said other submissions have shown how to achieve the same value, notice that this is an underflow not an overflow

#3 - rotcivegaf

2022-09-19T22:14:32Z

I take the overflow from OpenZeppelin contracts who separate in subtraction overflow and addition overflow

I'm read the +Backstage Warden Guidelines and I don't think I'm breaking any rules but if so, I apologize, I just wanted to say that it is not a simple random number and I know what I was talking about

#4 - GalloDaSballo

2022-09-19T22:32:37Z

I take the overflow from OpenZeppelin contracts who separate in subtraction overflow and addition overflow

I'm read the +Backstage Warden Guidelines and I don't think I'm breaking any rules but if so, I apologize, I just wanted to say that it is not a simple random number and I know what I was talking about

Thank you for the info, I believe other wardens have sent a more detailed submission but after spending more time I was to connect the dots

#5 - GalloDaSballo

2022-09-25T23:07:04Z

Dup of #469

AuditHub

A portfolio for auditors, a security profile for protocols, a hub for web3 security.

Built bymalatrax © 2024

Auditors

Browse

Contests

Browse

Get in touch

ContactTwitter