Skip to content

Enforce the global storage quota for encrypted keystores - #130

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

LIghtJUNction wants to merge 1 commit into
mainfrom
codex/propose-fix-for-keystore-quota-vulnerability

Conversation

@LIghtJUNction

Copy link
Copy Markdown
Contributor

Motivation

  • The keystore feature stored durable ciphertext in keystore_entries but omitted those bytes from the service-wide max_storage_bytes accounting, allowing many attacker-created identities to consume unbounded storage.

Description

  • Include keystore ciphertext in global storage accounting by adding SUM(length(ciphertext)) from keystore_entries to _storage_bytes() and to the reported stats() payload as keystore_bytes.
  • Atomically reject keystore inserts/replacements that would push the store above cfg.max_storage_bytes by computing the previous entry size and checking self._storage_bytes() - previous + new > cfg.max_storage_bytes, returning HTTP 507 on overflow while preserving the per-identity limits and allowing size-reducing replacements.
  • Add an HTTP-level regression test that verifies an over-capacity keystore upload is rejected and that an accepted upload updates keystore_bytes and total bytes in stats; update the test harness accordingly (tests/test_topics_profiles.py).
  • Update configuration comments and user-facing docs to state that encrypted keystore entries count against the shared max_storage_bytes capacity (src/msgd/config.py, src/msgd/render.py, README.md).

Testing

  • Ran formatting and lint checks with uv run ruff format --check . and uv run ruff check ., which passed.
  • Executed the focused keystore test with uv run python -m unittest tests.test_topics_profiles.TopicsProfilesCase.test_profile_keystore_stores_only_sealed_ciphertext -v, which passed.
  • Ran the full test suite with uv run python -m unittest discover -s tests -v, yielding all tests passing (145 passed, 1 skipped due to optional VALKEY_TEST_URL configuration).
  • The added regression test verified rejection (HTTP 507) when a keystore write would exceed max_storage_bytes and verified accounting after a successful write.

Codex Task

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

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:52:44.348102Z 8fb351a 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

已被 #143 取代,关闭。旧补丁打在已删除的 src/msgd 上;现行 src/msg 的对应容量上限在分支 fix/capacity-recovery-20260928(head e77b53b),该分支已包含合并后的 #142。

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