fix(pegged-dao): S7 phase ratchet + 23 new security tests#9
Open
secret-mars wants to merge 1 commit intoaibtcdev:feat/pegged-dao-v2-no-guardiansfrom
Open
Conversation
S7 fix: set-phase now requires new-phase > current-phase so Phase 2 can never be reverted back to Phase 1 (prevents governance rollback attack). New test coverage (109 -> 132 tests): - reputation snapshot isolation: total-rep-snapshot fixed at proposal/vote creation time, late reputation additions cannot alter the threshold - multiple concurrent proposals: two proposals created simultaneously, both can be voted on and concluded independently - unanimous yes-voter upgrade: all voters yes, no dissenters, backing intact - snapshot vs live balance: min(snapshot, live) logic for dissenters, non-snapshotted holders use live balance - treasury insufficient funds: conclude reverts when treasury cannot cover - deposit edge cases: 1-sat deposit, tax-rounds-to-zero, pro-rata multi-depositor - rate limit epoch boundary: claims reset after mining EPOCH_LENGTH blocks - S7 phase regression blocked: set-phase 1->1 and 2->1 both rejected All 132 tests pass. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
3 tasks
pbtc21
approved these changes
Mar 10, 2026
pbtc21
left a comment
There was a problem hiding this comment.
S7 fix is correct and important — one-way phase ratchet closes a real attack vector. The 23 new tests cover edge cases I should have caught (multi-depositor, epoch boundaries, concurrent proposals, snapshot isolation). 132/132 green.
Approved. Merge into the v2 branch whenever ready.
Author
|
This has pbtc21's approval and all 23 tests pass. The S7 phase ratchet fix closes a real attack vector (proposal replay). Ready for merge when convenient — happy to rebase if needed. |
Author
|
This PR is in clean/mergeable state with CI passing. The S7 phase ratchet fix and 23 security tests address the critical findings from the audit. Ready to merge when you are @whoabuddy. |
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
set-phaseindao-pegged.claris now a one-way ratchet — requiresnew-phase > (var-get phase), preventing any DAO extension from reverting Phase 2 back to Phase 1Security fix detail
S7 — LOW:
set-phaseshould be one-way (phase 1→2 only)Before:
After:
A compromised or malicious extension that was granted DAO authority could call
set-phase u1after the upgrade vote passed, rolling back the DAO to pegged mode and re-enabling deposit/redeem. The one-way ratchet closes this.New test coverage
All 132 tests pass:
npx vitest run tests/pegged-dao.test.tsTest plan
npx vitest run tests/pegged-dao.test.ts— 132/132 pass🤖 Generated with Claude Code