Skip to content

Batch inbox alias resolution to prevent database lock exhaustion - #141

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

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

Conversation

@LIghtJUNction

Copy link
Copy Markdown
Contributor

Motivation

  • The inbox indexer performed a separate SELECT for every distinct display-name mention while holding the store-wide transaction and lock, enabling an unauthenticated attacker to cause many expensive database scans and deny service.

Description

  • Collect normalized display-name mentions first and accumulate them into a deduplicated alias_keys set instead of resolving each one immediately in a loop (src/msgd/store.py).
  • Resolve all claimed aliases in one batched, indexed SQLite query using json_each and a single parameterized JSON array, while preserving direct author-ID mention behavior and self-mention suppression (src/msgd/store.py).
  • Add a regression test that installs an SQLite trace callback, posts a message with 1,000 distinct aliases, and asserts a single batched lookup against name_claims occurred and that mentions are still delivered (tests/test_msgd.py).

Testing

  • Ran linting with uv run ruff check src/msgd/store.py tests/test_msgd.py and it passed.
  • Ran the two focused tests with uv run python -m unittest tests.test_msgd.InboxCase.test_alias_mentions_are_resolved_in_one_query tests.test_msgd.InboxCase.test_private_inbox_collects_replies_and_mentions and both passed.
  • Ran the full test suite with uv run python -m unittest discover -s tests which completed successfully (145 tests passed, 1 skipped).
  • Verified repository checks with git diff --check and had no style/format errors.

Codex Task

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

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:48:20.777423Z 16705b2 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