{"id":"XE-1479","kind":"bounty","visibility":"public","source":"web","source_repo":"","source_ref":"","source_url":"","reporter_id":242,"title":"dao/config.py & dao/services/portal.py: Config.excluded_accounts() Forces Agent Seat Voting Weight to Zero and Omits Signer-Backed dao/fee Accounts","area":"dao-harness","claimed_tier":"high","assessed_tier":"minor","verdict":"valid","duplicate_of":null,"tracked":true,"internal_ref":"dao@55ee9d4","internal_url":"","status":"awarded","closed_reason":null,"github_state":"","disclosed_at":null,"award_xe":100000000,"award_approved":true,"paid_ref":"","created_at":"2026-11-08T10:32:06.519670+00:00","updated_at":"2026-11-08T21:38:22.766320+00:00","source_created_at":null,"told_at":"2026-11-08T20:18:42.118682+00:00","status_changed_at":"2026-11-08T21:38:22.774337+00:00","url":"https://bounty.xe.network/XE-1479","body":"## Summary\n\nIn `xeprotocol/dao` (commit `704238b`), `Config.excluded_accounts()` in `dao/config.py` conflates quorum-participation exclusion (`participating_wallet.exclude_agent_accounts`) with zero-weight account exclusion (`excluded_accounts`). By merging `self.agent_accounts` into `pinned_rules()[\"excluded_accounts\"]`, `portal.vote()` treats every designated agent seat as an excluded protocol account and forces its voting weight to `0`, making the `100 XE` agent stipend and `1%` `max_weight_share` cap in `portal.tally()` unreachable under production rules. Conversely, `Config.excluded_accounts()` reads `dao` and `fee` addresses only from `config/schedule_c.yaml` (where both are empty strings because the signer keyfile is authoritative) and never consults `ctx.signer`, leaving the live `fee` escrow account and `dao` account out of `excluded_accounts`.\n\n## Vulnerable Code\n\n1. **`dao/config.py`, lines 175-200 (`Config.excluded_accounts` and `Config.pinned_rules`)**:\n```python\n    def excluded_accounts(self) -> set[str]:\n        ex = {a.lower() for a in self.open_vote.get(\"excluded_accounts\", []) if a}\n        for name in (\"treasury\", \"fee\", \"dao\"):\n            a = self.accounts.get(name)\n            if a:\n                ex.add(a)\n        if self.open_vote.get(\"participating_wallet\", {}).get(\"exclude_agent_accounts\", True):\n            ex |= self.agent_accounts\n        return ex\n\n    def pinned_rules(self) -> dict:\n        \"\"\"The rules snapshot pinned to a proposal when it opens.\"\"\"\n        ov = self.open_vote\n        return {\n            ...\n            \"agents\": ov.get(\"agents\", {}),\n            \"excluded_accounts\": sorted(self.excluded_accounts()),\n            \"schedule_b_hash\": self.hashes.get(\"schedule_b.yaml\", \"\"),\n        }\n```\n\n2. **`dao/services/portal.py`, lines 162-175 (`vote`) and lines 205-221 (`tally`)**:\n```python\n    is_agent = v.account in ctx.config.agent_accounts\n    excluded = v.account in set(rules.get(\"excluded_accounts\", []))\n    reasons = []\n    if excluded:\n        reasons.append(\"excluded account\")\n    ...\n    if is_agent and not rules.get(\"agents\", {}).get(\"count_toward_quorum\", False):\n        reasons.append(\"agent accounts do not count toward quorum\")\n    participating = not reasons\n    weight = 0 if excluded else int(snap[\"balance\"])\n```\n\n3. **`config/schedule_b.yaml`, lines 52-62, and `config/schedule_c.yaml`, lines 142-145**:\n```yaml\n  participating_wallet:\n    min_balance_micro_xe: 1000000   # 1 XE at the snapshot (an hour before open)\n    must_exist_before_open: true    # first block published before the proposal opened\n    exclude_agent_accounts: true\n  ...\n  agents:\n    stipend_micro_xe: 100000000     # 100 XE per seat, funded by the designating resolution\n    max_weight_share: 0.01          # agent weight counts up to 1% of total weight cast\n    count_toward_quorum: false\n  excluded_accounts: []             # treasury, claim pool, fee account are added at deploy\n```\n```yaml\naccounts:                         # per deployment: fill on the server from `dao keys init`; the signer is authoritative\n  dao: \"\"                         # the DAO's public account: directory-registered, receives chat\n  fee: \"\"                         # receives proposal fees; refunds or burns them\n  treasury: \"\"                    # hash-derived multisig; human keyholders only\n```\n\n## Root Cause and Impact\n\n1. **All designated agent seats receive zero voting weight (`weight = 0`)**:\n   - In `config/schedule_b.yaml`, `participating_wallet.exclude_agent_accounts: true` means agent accounts do not count toward the 20-wallet quorum (`quorum_wallets: 20`), while `agents.stipend_micro_xe` (`100 XE`) and `agents.max_weight_share` (`0.01`) specify that agent seats vote with bounded XE weight (up to 1% of total weight cast).\n   - Because `Config.excluded_accounts()` unions `self.agent_accounts` into `excluded_accounts` whenever `participating_wallet.exclude_agent_accounts` is `True` (the default in both `schedule_b.yaml` and `dao/config.py:181`), every agent account in `ctx.config.agent_accounts` is placed into `rules[\"excluded_accounts\"]`.\n   - When an agent seat votes in `portal.vote()`, `excluded` is `True`, so `weight = 0 if excluded else int(snap[\"balance\"])` zeros out its balance (`weight = 0`) and records `\"excluded account\"` alongside `\"agent accounts do not count toward quorum\"`. In `portal.tally()`, `agent[v.choice] += v.weight` adds `0`, so `agent_total` is always `0` and agent seats can never contribute weight to any open vote.\n   - Existing unit tests in `tests/test_dao_core.py:250` bypassed `portal.vote()` and `Config.pinned_rules()` by passing synthetic `_vote(100_000_000, \"for\", participating=False, is_agent=True)` objects directly to `portal.tally()`.\n\n2. **Signer-backed `dao` and `fee` escrow accounts are omitted from `excluded_accounts`**:\n   - `portal.fee_account(ctx)` (`dao/services/portal.py:35-38`), `inbox.dao_account(ctx)` (`dao/services/inbox.py:38-41`), and `records._treasury(ctx)` (`dao/services/records.py:140-144`) resolve `dao` and `fee` from `ctx.signer.address(\"dao\")` and `ctx.signer.address(\"fee\")` first and fall back to `ctx.config.accounts`.\n   - `Config.excluded_accounts()` only reads `self.accounts.get(name)` from `schedule_c.yaml` and never checks `ctx.signer`. When `schedule_c.yaml` leaves `accounts.dao` and `accounts.fee` empty as documented, the `fee` escrow account (holding active proposals' 10 XE fees) and the `dao` account are absent from `pinned_rules()[\"excluded_accounts\"]` and are reported as eligible participating voters by `GET /v1/snapshot/{account}` (`dao/api/public.py:185-190`) and `portal.vote()`.\n\n## Reproduction\n\nRun against `/home/ubuntu/Cybermes/recon/test_network/dao`:\n```python\nfrom pathlib import Path\nfrom dao.config import load_config\n\ncfg = load_config(Path(\"config\"))\nagent_addr = \"a\" * 64\ncfg.schedule_c[\"agent_seats\"][0][\"account\"] = agent_addr\nrules = cfg.pinned_rules()\n\nassert agent_addr in cfg.agent_accounts\nassert agent_addr in rules[\"excluded_accounts\"]  # forces weight = 0 in portal.vote()\nassert [x for x in rules[\"excluded_accounts\"] if x != agent_addr] == []  # signer dao/fee omitted\n```\n\n## Remediation\n\n1. Remove `if self.open_vote.get(\"participating_wallet\", {}).get(\"exclude_agent_accounts\", True): ex |= self.agent_accounts` from `Config.excluded_accounts()`. Instead, check `exclude_agent_accounts` only when computing `participating` in `portal.vote()` (`if is_agent and (pw.get(\"exclude_agent_accounts\", True) or not rules.get(\"agents\", {}).get(\"count_toward_quorum\", False)): reasons.append(...)`) and in `GET /v1/snapshot/{account}`, so `excluded_accounts` applies only to non-voting protocol/treasury accounts.\n2. Include `ctx.signer.address(\"dao\")` (when `ctx.signer.has(\"dao\")`) and `ctx.signer.address(\"fee\")` (when `ctx.signer.has(\"fee\")`) in the `excluded_accounts` list pinned by `pinned_rules()`.","patch_refs":[{"id":431,"repo":"xeprotocol/dao","kind":"commit","ref":"55ee9d4","title":"","url":"https://github.com/xeprotocol/dao/commit/55ee9d4","note":"","state":"","author":"","added_by":"token:5","created_at":"2026-11-08T21:15:43.024785+00:00"}],"thread":[{"id":1005,"source":"desk","source_ref":"reply:550","author":"Joseph Denne","team":true,"body":"Thanks for the report. We have read it against the DAO harness code and confirmed the behaviour you describe in how agent seats and protocol accounts are treated in open votes; it is being handled. We will update you here when there is more to say.","created_at":"2026-11-08T20:17:41.885067+00:00"}]}