Skip to content

Bound persistent agent state storage globally - #133

Closed
LIghtJUNction wants to merge 1 commit into
mainfrom
codex/propose-fix-for-state-storage-vulnerability
Closed

LIghtJUNction wants to merge 1 commit into
mainfrom
codex/propose-fix-for-state-storage-vulnerability

Conversation

@LIghtJUNction

Copy link
Copy Markdown
Contributor

Motivation

  • The agent state feature permitted unauthenticated clients to create unlimited fresh Ed25519 identities and persist per-identity data, which could exhaust the authoritative SQLite database and WAL because agent_state was not included in global storage accounting.
  • The goal is to enforce a global, atomic capacity for persistent agent state so rotating attacker-generated identities cannot bypass site-wide quotas while preserving existing per-slot and per-identity limits.

Description

  • Acquire an SQLite write lock (BEGIN IMMEDIATE) before measuring and writing agent_state so concurrent writers cannot race to oversubscribe the limit and use transactional commit/rollback around the insert. (see ExchangeService.state_write in src/msgd/exchange.py).
  • Enforce a global capacity check that accounts for per-record overhead and the bytes of owner_id, name, and value, and reject writes with HTTP 507 when the effective capacity would be exceeded; preserve the existing MAX_STATE_SLOT_BYTES and MAX_STATE_TOTAL_BYTES checks. (see src/msgd/exchange.py).
  • Expose the effective global agent-state capacity in the rendered schema (agent_state_capacity_bytes) and document the behavior in README.md and src/msgd/render.py.
  • Add a regression test (tests/test_msgd.py::LegacyMigrationCase.test_agent_state_has_global_storage_capacity) that proves fresh-identity exhaustion is bounded and that replacing an existing value frees capacity as expected, and update imports to surface StoreError for assertions.

Testing

  • Ran static checks with uv run ruff check src/msgd/exchange.py src/msgd/render.py tests/test_msgd.py and git diff --check, which passed without issues.
  • Ran focused unit tests with uv run python -m unittest tests.test_msgd.LegacyMigrationCase.test_agent_state_has_global_storage_capacity tests.test_msgd.ExchangeProtocolCase.test_state_watch_ack_task_thread_outbox_and_since and both tests passed (the patch was iterated until the failing interaction was resolved).
  • Ran the full test suite with uv run python -m unittest discover -s tests, which completed successfully: 146 tests ran, 1 skipped, all passing.

Codex Task

Copilot AI lite review requested due to automatic review settings September 28, 2026 11:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
🔒 Security Review ✅ Completed 2026-09-28T11:49:34.648819Z 5666772 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@LIghtJUNction

Copy link
Copy Markdown
Contributor Author

关闭:现行 src/msg 中不存在 WebSub、持久 agent state、engagement ranking 或 mention 别名扇出,因此没有对应的无界路径可修。此关闭仅表示补丁不适用于现行代码,不代表生产已验收。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants