Repository navigation
fix(basedao,daokit): bind the DAO's identity to its own live realm - #69
Merged
Merged
Conversation
Closes both identity blockers as one interface change, since they are the same defect seen from two sides. Propose(req, rlm) / Vote(id, vote, rlm) / Execute(id, rlm) each assert the threaded realm is the DAO realm's own live one before doing anything else. Execute forwards that realm to the action handlers, which cross out under it, so whoever supplies it decides the identity the DAO acts as: a third realm holding the DAO value could pass its own and have the DAO write to that realm's profile, or via MigrateFn reach anywhere it controls. Realm values are unforgeable and cannot be persisted across transactions, so a caller can only pass its own; requiring it to equal the DAO's own closes that path outright. Reached through the DAO handle there is no DAO realm frame on the stack at all, so the old stack-walking identity named the signing account. A member's signature then satisfied the membership check while the caller supplied the realm the DAO acted under. Identity now derives from the threaded realm, which does not depend on where in the chain it is read. The gate requires the realm to be current, not merely to match by pkgpath. Every realm the DAO crosses out into during an action receives the DAO's own realm as its cur.Previous() and can hand that value straight back within the same transaction: same pkgpath, dead frame. Reproduced end to end — before this, a callee re-entered Propose under the DAO's own identity and a pkgpath-only gate accepted it. IsCurrent() is frame identity rather than name; it survives the /p/ hop into basedao and holds during a realm's own init, so neither the ordinary path nor construction is affected. The realm is never a first parameter: the VM reads any function whose first parameter is a realm as crossing, and /p/ packages may not declare crossing functions. Receivers do not count, so assertRealmIsOwn and defaultCallerID take the DAO first. Tests are realm-to-realm, under gno/r/daoidentity. testing.SetRealm fabricates a cur with no frame beneath it — cur.Previous() resolves to p/samcrew/basedao itself — so it cannot express a caller chain in either direction, which is why the original defect and the New() regression in #66 both passed CI. The suite drives a real DAO realm from a relay, a non-member, an attacker holding the DAO value, and a callee re-entering with the DAO's own dead-frame realm. Five properties are mutation-checked, each failing exactly one test: either half of the realm gate, the empty-id guard, the gate running before CallerID ever sees a realm, and Execute requiring membership. The ordering matters because CallerIDFn is a frozen extension point — running membership first would hand a custom implementation an attacker-controlled realm. basedao's unit tests now declare the caller they act as instead of leaning on the harness, and realm_identity_test.gno is dropped: SetRealm-based identity tests claim coverage that cannot exist. The empty-id guard is load-bearing rather than cosmetic. AddMember does not reject "", Members is an exported avl.Tree a MigrateFn can seed directly, and any call the machine cannot attribute to a signer resolves to "" — so one such entry would otherwise authenticate all of them. It is asserted on controlled input, not inferred from the environment: under gno test the harness leaves OriginCaller unset, while on-chain a root-of-chain call resolves to the signing account.
This was referenced Jul 20, 2026
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.
Completes the P0-A / P0-B interface work. This is the last interface-breaking change before the topaz-1 freeze, so it is now-or-never.
The defect
Both blockers are the same defect seen from two sides.
Executeforwards the threaded realm to the action handlers, which cross out under it. Whoever supplies that realm therefore decides the identity the DAO acts as — a third realm holding the DAO value could pass its own and have the DAO write to that realm's profile, or throughMigrateFnreach anywhere it controls.And reached through the DAO handle there is no DAO realm frame on the stack at all, so the old stack-walking identity named the signing account. A member's signature satisfied the membership check while the caller supplied the realm the DAO acted under.
The fix
Propose(req, rlm)/Vote(id, vote, rlm)/Execute(id, rlm)each assert the threaded realm is the DAO realm's own live one before doing anything else. Realm values are unforgeable and cannot be persisted across transactions, so a caller can only ever pass its own; requiring it to equal the DAO's own closes the donation path outright. Given that,rlm.Previous()is by construction the DAO's immediate caller.The gate requires the realm to be current, not merely to match by pkgpath. Every realm the DAO crosses out into during an action receives the DAO's own realm as its
cur.Previous()and can hand it straight back within the same transaction: same pkgpath, dead frame. Reproduced end to end — with a pkgpath-only gate a callee re-enteredProposeunder the DAO's own identity and was accepted.IsCurrent()is frame identity rather than name; verified it survives the/p/hop into basedao and holds during a realm's owninit, so neither the ordinary path nor construction is affected.The realm is never a first parameter — the VM reads that as a crossing function, which
/p/packages may not declare. Receivers do not count, soassertRealmIsOwnanddefaultCallerIDtake the DAO first.Tests
testing.SetRealmfabricates acurwith no frame beneath it:cur.Previous()resolves togno.land/p/samcrew/basedaoitself. It cannot express a caller chain in either direction, which is why the original defect and theNew()regression in #66 both passed CI.Tests are therefore realm-to-realm, under
gno/r/daoidentity/— a DAO realm, a relay, a non-member, an attacker holding the DAO value, and a callee re-entering with the DAO's own dead-frame realm. These are fixtures only; the deployer publishes an explicit 7-directory list that excludes them, andassert_gnodaokit_source_form topaz-1passes against this branch.Five properties are mutation-checked, each failing exactly one test:
!rlm.IsCurrent()TestADAORealmValueFromADeadFrameIsRefusedMayNotDonateItsIdentitytestsTestAnEmptyCallerIdIsNeverAMemberTestTheGateRunsBeforeCallerIDEverSeesTheRealmExecute's membership checkTestExecuteRequiresMembershipNotJustTheRightRealmOrdering is pinned because
CallerIDFnis a frozen extension point: running membership first would hand a custom implementation an attacker-controlled realm.basedao's unit tests now declare the caller they act as rather than leaning on the harness, andrealm_identity_test.gnois dropped — SetRealm-based identity tests claim coverage that cannot exist.Two corrections found in review
unsafe.PreviousRealm()andrlm.Previous()name the same realm — the gate has already established the DAO's frame is live. The walk goes wrong only in the shape the gate now rejects. Comments were corrected to say this; the threaded form is kept because it does not depend on the gate having run first.""on-chain.buildOriginRealmsets{OriginCaller, ""}, soIsUser()holds and a root-of-chain call resolves to the signing account. The empty id is agno testartifact (the harness leavesOriginCallerunset). The empty-id guard is asserted on controlled input instead, and it is load-bearing:AddMemberdoes not reject"",Membersis an exportedavl.TreeaMigrateFncan seed directly, and any unattributable call resolves to"".Verification
gno test ./gno/...green (8 packages) ·gno lintclean ·gno fmt -diffclean · zerogno: downloading· deployerassert_gnodaokit_source_form topaz-1passes.Base is
feat/topaz-v2-rename, notmain:mainis pre-interrealm-v2 and not locally buildable.