Resources

People often ask me "How did you learn how to hack?" The answer: by reading. This page is a collection of the blog posts and other articles that I have accumulated over the years of my journey. Enjoy!

Fuzzing for a Solana Governance Bug- 2233

Kai Parker - Asymmetric ResearchPosted 26 Days Ago
  • In August, Solana started voting on chain with svmgov. For the first six weeks on mainnet, this had a bug: any validator could silently erase its own delegators dissenting votes. This could have been used to skew voting results. This is the story of how the bug was found. Full disclosure this is my co-worker that I do like a lot!
  • A validator votes with cast_vote, using its full weight of the stake delegated to it. Delegators can choose to override their validator with cast_vote_override, and vote their stake directly. Since most people don't run their own validator but may want to vote, this helps support those folks.
  • There are two cases here for cast_vote_override: validator has voted, and hasn't voted (cached). In the first case, if the validator has already voted, then it'll subtract the users votes from the validator to vote for the other side. In the second case, the votes are cached. When the validator votes, the users votes will later be subtracted from their voting power.
  • When are the cached votes handled? Only within cast_vote! So, if a validator has not voted, then can simply choose NOT to vote. This means that they're power doesn't count but their staked users doesn't count either. On the proposal SGP-0002 that only passed with 67%, it would have failed if not for the patch. Pretty neat! To fix this, overridden votes count towards the total immeidately.
  • This vulnerability was discovered with the Solana fuzzer Crucible. They setup a harness for each publicly facing function, and let the fuzzer go ham. To find this bug, they wrote a simple invariant: every vote is counted exactly once. Running create_proposal, cast_vote_override, time travel, and finally finalize_proposal triggers this. Since the validator never called cast_vote, this is a major problem.
  • Why wasn't this found before? Apparently, the code had gone through manual review but no bugs were found in it. Stateful fuzz testing explores complex sequences to find bugs when good invariants are used. I've used this tool in the past, and found a good amount of bugs. Great find by Kai!