fix: Verify governance voting power server-side#177
Open
GranusClarvis wants to merge 1 commit intoInverseAltruism:devfrom
Open
fix: Verify governance voting power server-side#177GranusClarvis wants to merge 1 commit intoInverseAltruism:devfrom
GranusClarvis wants to merge 1 commit intoInverseAltruism:devfrom
Conversation
…lient Previously, the governance vote endpoint accepted `votingPower` directly from the client POST body without server-side verification. This allowed any voter to claim arbitrary voting power (e.g., votingPower: 9999) when the system's design is 1 Star Skrumpey = 1 Vote. Changes: - Vote action now calls checkStarOwnershipBatched() to verify actual Star Skrumpey ownership on-chain before recording the vote - Voters with 0 Stars are rejected with a 403 error - Proposal creation now requires Star holder status (was wallet-auth only) - Removed unused client-supplied votingPower from destructuring Co-Authored-By: Claude Opus 4.6 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
votingPowerdirectly from the client POST body without any server-side verification. An attacker could submitvotingPower: 9999to inflate their vote count, completely undermining DAO governance integrity.checkStarOwnershipBatched()to count actual Star Skrumpey NFT ownership before recording votes. This leverages the existing 30-second ownership cache to minimize RPC overhead.What Changed
app/api/governance/route.ts:parseInt(votingPower, 10) || 1(client-supplied) with server-sidecheckStarOwnershipBatched()call. Non-holders are rejected with 403.checkStarOwnershipBatched()gate before proposal creation. Non-holders are rejected with 403.votingPowerandtypedDatafrom request body destructuring.Test plan
npm run type-check— passesnpm run test— 69/69 tests passnpm run build— builds successfully (49 routes)anytype on line 500)🤖 Generated with Claude Code