Repository navigation
fix(daokit,basedao): proposal lifecycle, the extension gate, and the migration threshold - #72
Merged
zxxma merged 9 commits intoJul 20, 2026
Conversation
…-entrancy it was hiding Any realm holding the DAO handle could permanently brick a proposal that had already met its condition, with one cheap call. Render is on the cross-realm DAO interface and reaches GetProposals, which called UpdateStatus on every proposal it walked — the code's own comment said "costly and probably insecure". Vote never moves the status, so a proposal sat at Open after reaching its threshold; the render flipped it to Passed, and Execute then refused it forever because it demanded exactly Open. Repeatable after every re-vote. GetProposalsJSON and the proposal detail view wrote on read the same way. Reading no longer writes. DisplayStatus computes the status a proposal should be shown as, and every read path uses it. UpdateStatus stays — persisting the passed state is a legitimate thing for a realm to want — but nothing in this package calls it now. Execute is gated on the condition and on nothing else. Executed is the only status that disqualifies a proposal; requiring Open made the status a second, weaker gate that anything able to move it could use to deny execution. The executed marker moves BEFORE the handler runs. That ordering was previously irrelevant, because "must be Open" happened to block re-entry once UpdateStatus had moved the proposal to Passed. Removing that requirement — which is what unbricks rendering — would have opened re-entrancy had the marker stayed put. Verified: with the marker after the handler, a proposal whose action calls back into Execute recurses without bound, and the suite hangs rather than failing. Three properties, each mutation-checked against its own test: restoring the mutating read path fails the brick test, requiring Open fails the persisted-Passed test, and moving the marker back re-opens the recursion.
…not a stack walk Extension asked unsafe.CurrentRealm(), which answers "is a DAO frame the innermost live one" rather than "is my caller the DAO". That is wrong in both directions. Too lax: anything the DAO invoked WITHOUT crossing inherited the DAO's realm and passed the check — including a proposer-authored ExecuteLambda callback, which could read a private extension. Too strict: a DAO-realm helper that is not itself a crossing function has no frame for the walk to find, so the DAO was locked out of its own private extensions through any read-only accessor. It now takes the threaded realm and, for a private extension only, requires the DAO realm's own live one — the same test the entry points use. That closes the lambda case by construction rather than by check: a callback given no realm cannot produce one, and realm values can be neither forged nor persisted. Public extensions ignore the realm entirely, so MembersViewExtension — the documented way for another realm to check membership — keeps working from any caller. Gating those too would have broken it, and the suite catches that mutation as well as the reverse. This changes daokit.DAO, so it is now or never.
A passing migration hands proposer-authored code the DAO's live realm and its full private state. Readonly taint blocks a direct field write but not method dispatch, so the migration can commit under the DAO's authority — it is a takeover in the general case, not an upgrade. It was registered with the same condition as "Add Member", so both cost the same 60% by default. Migration now defaults to 80%, and Config.MigrationCondition makes that explicit for a DAO wanting something else. Nothing is deployed at this path yet, so the stricter default costs nothing and the safe direction is the one that is hard to reverse. And every migration rendered as the same fixed sentence, which told a voter nothing: a routine version bump and a takeover were indistinguishable in the proposal they were approving. A function value cannot be rendered, so the caller now has to supply a label, and the warning says what approving actually grants.
…e the demos bypass the gate InstantExecute threads the caller's realm through Propose, Vote and Execute, and each entry point requires its own — so handing it a DAO belonging to another realm is now refused, and NewInstantExecuteAction inherits that. That refusal is the correct outcome, not a regression to work around. Driving a foreign DAO by passing it your realm IS the donation shape: it makes that DAO act under your identity. It appeared to work only because nothing checked. A parent DAO still drives a child by reaching it through the child REALM's own crossing function, so the child mints its own realm and authorises the parent as an ordinary member. Both are documented and the constraint is pinned by a test. The three demo realms call daoPrivate.CallerID(daoPrivate, cur) directly, which skips the entry-point gate. It is correct there — cur is the realm's own, minted by the crossing function they are in — but it is also the shape a reader is most likely to copy, and copied somewhere that forwards a realm received from elsewhere it becomes the bug the gate exists to refuse. Said so at each site.
The stricter migration default I just added was wrong in the case that matters most, and made the thing it was meant to protect easier. A Condition is opaque, so there is no way to "raise" one. Substituting a members threshold for a role-gated condition does not tighten it — it DROPS the role gate. Measured against And(MembersThreshold(0.4), RoleCount(1,"officer")), which is the shape every demo realm uses: a ballot that FAILED the ordinary action PASSED the bare 0.8 migration. A takeover became cheaper than adding a member. The default is now InitialCondition AND an 80% member majority, so it is harder along every dimension the DAO's own governance measures and along one more. Pinned by a test that votes four of five members with the officer abstaining — refused by both, where before it was refused by one and admitted by the other.
It read "only accessible from the same realm that registered it", which invites being taken for confidentiality. It is not. Realm state on a public chain is world-readable over ABCI, and ExtensionsList hands out every ExtensionInfo — including QueryPath — with no check at all. What Private restricts is who can obtain the extension VALUE through DAO.Extension and therefore call its methods under the DAO's authority. That is a capability. Leaving the listing ungated is correct for the same reason: gating metadata would imply a secrecy the chain cannot provide, while the capability door stays shut.
…nd in the fix itself Three real defects in the previous four commits. Core.Vote still demanded status Open while Execute had been relaxed, and UpdateStatus was exported and blessed. Together those inverted the bug rather than fixing it: persisting Passed used to brick a proposal, and instead began LOCKING IT IN — votes frozen, support unable to be withdrawn, execution guaranteed. Status is now written only by Execute, UpdateStatus is gone, and Vote and Execute share one terminal state. A ballot stays live until the proposal executes, which is the coherent reading and is now pinned by a test that withdraws support after the condition is met and takes it back. The migration default could make migration permanently unreachable. Conjoining an 80% member threshold onto role-based governance demands a member majority a role-governed DAO may never assemble, and migration is the one rule that cannot be repaired afterwards, because repairing it needs a migration. A DAO that chose its own governance now keeps it, with the docs saying plainly to set MigrationCondition; only a DAO on the default 60% gets the raise to 80%, where it is the same dimension and a genuine strengthening. New also wrote that default back into the caller's Config, and the condition closes over the member store — so one Config reused for a second DAO gave it a migration rule evaluating the first DAO's membership. Held locally now. The IsCurrent() half of the private-extension gate had no test at all: replacing it with a pkgpath comparison survived the whole suite, and under that mutation a callee handed the DAO's dead-frame realm reads the private extension. Covered now, and the mutation dies. Also: Execute is not retry-safe, because gno's recover() does not roll back realm state — a host that recovers around a failing Execute keeps the marker and burns the proposal. Documented, since the ordering is worth more than the retry. The read paths that this change set exists to fix had no tests; one now renders an open, a condition-met and an executed proposal and checks the table, the JSON and the active/history split, killing three mutations that had survived. The other two turned out to be equivalent — with Passed never stored, filtering on the raw status is exactly "not yet executed" — so the filters use it directly and stop evaluating every condition a second time. Finally, the migration label is caller-written text, not a safety control; a takeover can ship as "routine security patch". Said so, so the docs do not imply otherwise.
…okit#13) Action.String() is what a member reads before voting, and for an action built with NewAction it is the payload's own rendering — supplied by whoever created the proposal. Issue #13 asks what stops that lying. Two things do, and neither was written down. Type() must be truthful or the wrong handler is looked up and its assertion fails, so an action cannot disguise its KIND; and the proposal view already renders the Resource's registered DisplayName, Description and Condition beside it, keyed by Type() from the DAO's own registry rather than from the proposal. What remains reachable is misrepresenting the payload's DETAIL, and only through a handler that admits a hostile payload. The defence is the concrete type assertion, so that contract is now stated at NewActionHandler and demonstrated both ways: a spoofed payload rendering identically to an honest one is rejected by a concrete assertion, and admitted by an interface assertion — a payload of 1000000 that reads as 1. Nothing in daokit can enforce this, since the handler decides, which is exactly why it is pinned as a fact about the pattern. Every shipped handler already asserts concretely, and the two destructive ones — basedao's ChangeDAOImplementation and daokit's InstantExecute — use unexported payload types a proposer cannot construct at all. So #13 is not reachable in shipped code; it is a footgun for third-party action authors. Moving rendering onto the handler, as #13 suggests, would remove the footgun instead of documenting it. That changes ActionHandler, and swapping a frozen interface on the last day before an immutable publish to close a hole nothing shipped can reach is the wrong trade — recorded for a version boundary.
…es it safe Owner call: keep it on the exported surface. It is an API removal on a package with a live test13 deployment, and the reason it was dangerous is gone. It was removed because it inverted the lifecycle fix — but only in combination with checks that no longer exist. When Vote and Execute demanded status Open, persisting Passed was destructive twice over: the ballot froze, so support could not be withdrawn, and the proposal became permanently unexecutable. Both now key on Executed alone, so persisting the passed state changes nothing about what a proposal can still do. That is an invariant, not a coincidence, so it is pinned: a test persists Passed, then withdraws support and shows Execute refuses on the condition, then restores it and shows Execute succeeds. Re-arming either check fails it — verified for both — and it says in the test what to do if it ever goes red: take UpdateStatus out rather than work around it. The doc comment now states all three hazards plainly: safe only because of those two checks, never call it from a read path, and once persisted the status stops tracking the votes.
zxxma
changed the base branch from
chore/repin-gnoversion-topaz
to
feat/topaz-v2-rename
July 20, 2026 18:51
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.
Stacked on #71. Merge order: #69 → #70 → #71 → this.
Implements the five recommendations left open by the security review of #69, plus the defects two further reviews found in these fixes.
The Render-brick P0
Any realm holding the DAO handle could permanently brick a proposal that had met its condition, with one cheap call.
Renderis cross-realm and reachedGetProposals, which calledUpdateStatuson every proposal it walked — its own comment said "costly and probably insecure".Votenever moves the status, so a condition-met proposal sat atOpen; the render flipped it toPassed;Executethen refused it forever because it demanded exactlyOpen.Reading no longer writes.
DisplayStatus()computes what to show;Statusis written only byExecute.Executeis gated on the condition and nothing else.The executed marker moved before the handler. That ordering was previously irrelevant — "must be
Open" happened to block re-entry — so removing that demand without moving the marker would have opened re-entrancy. Mutating it back does not fail the suite: it hangs, recursing without bound. Worth knowing as a CI failure mode.The extension gate
Extension(path)→Extension(path, rlm). A private extension requires the DAO's own live realm; a public one ignores it, soMembersViewExtension— the documented cross-realm membership check — keeps working. Gating public ones too breaks it, and the suite catches that mutation as well as the reverse.Migration is no longer as cheap as adding a member
It shared
InitialConditionwith "Add Member", for an action that hands proposer-authored code the DAO's live realm and full private state. Now a distinctConfig.MigrationCondition, and a required label — every migration used to render as the same fixed sentence, so a version bump and a takeover looked identical in the proposal you approved.Three defects the reviews found in the above
Each of these was mine, in a fix.
Votewas left demandingOpenwhileExecutewas relaxed. WithUpdateStatusstill exported, that inverted the bug: persistingPassedstopped bricking a proposal and started locking it in — votes frozen, support unwithdrawable, execution guaranteed.UpdateStatusis gone;VoteandExecuteshare one terminal state.The migration default could make migration permanently unreachable. My first attempt replaced a role-gated condition with a members threshold, which dropped the role gate — measured against
And(MembersThreshold(0.4), RoleCount(1,"officer")), a ballot that failed the ordinary action passed the migration. Conjoining instead fixed that but broke the other direction: role-governed DAOs would need a member majority they may never assemble, unrepairably, since changing the rule needs a migration. A DAO that chose its own governance now keeps it; only default governance gets the raise to 80%.The
IsCurrent()half of the extension gate had no test. Replacing it with a pkgpath comparison survived the whole suite — and under that mutation a callee handed the DAO's dead-frame realm reads the private extension. Covered now.Also
InstantExecuteis same-realm-only, documented and tested. The cross-realm form only ever worked because of the vulnerability — it is the donation shape.Executeis not retry-safe: gno'srecover()does not roll back realm state, so a host that recovers around a failingExecuteburns the proposal. Documented; the ordering is worth more than the retry.Newno longer writes derived defaults into the caller'sConfig— the migration condition closes over the member store, so a reusedConfiggave the second DAO the first one's membership.Privatere-documented: on a public chain nothing is confidential andExtensionsListis ungated by design. It restricts capability, not secrecy. Gating the listing would have been theatre.Verification
10 packages ok · lint clean ·
fmt -diffclean · zerogno: downloading· README fixtures match.Every guard mutation-checked. Two mutations survive and are equivalent, not gaps: with
Passednever stored, filtering on the raw status is exactly "not yet executed" — so the filters use it directly, which also stops them evaluating every condition a second time.