query: categorize rules can pin unbounded memory in the regex cache and run past query_timeout
メンテナーはふだん 1 日以内に返信
@TimeToBuildBob がすでに取り組んでいます。
2026年11月24日 から。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 22/100
調査の方向性
Start with aw-transform/src/classify.rs (the global REGEX_CACHE and the backtrack-error handling near line 124) and aw-query/src/interpret.rs (the deadline check near line 31). Reproduce both problems with cargo test -p aw-server --test bughunt_dos from the linked branch. Done means the repro tests pass, with a bounded regex cache and a deadline that stops a long categorize call. Choosing between the proposed fixes needs maintainer input.
索引モデルが issue の本文から書いたものです。
説明
Two resource-exhaustion problems in categorize/tag rules sent through /api/0/query. Both were found in a security-lens bug hunt and reproduced with failing tests on master ea6f09c, on branch TimeToBuildBob:bughunt-2026-11-24-security-dos-repros (aw-server/tests/bughunt_dos.rs, run with cargo test -p aw-server --test bughunt_dos).
Reach: /api/0/query is closed to wildcard moz-extension:// origins by ExtensionCorsScope. That leaves local clients and the user's own webui. So this is mostly about robustness against an unlucky or hostile category rule, not a remote attack.
1. The regex cache keeps compiled regexes of any size
aw-transform/src/classify.rs:11-13,107-111: REGEX_CACHE is a process-global LRU of up to 512 compiled fancy_regex::Regex, with no limit on their size. A counted repetition such as a{200000}z is about 20 bytes of query text and compiles to roughly 10 MB, just under the regex crate's 10 MiB compile limit. The compiled regex stays resident until it is evicted.
1175-byte query body, status 200 OK, retained RSS growth 158 MB
That is 16 rules. Filling all 512 slots leaves several GB resident from a single query of about 37 KB.
Possible fix: build rules with fancy_regex::RegexBuilder and a smaller delegate_size_limit / delegate_dfa_size_limit, or skip caching patterns whose compiled size is large.
2. One backtracking rule runs far past query_timeout_secs
A rule that needs fancy-regex's backtracking VM, such as ^(a|aa|(?=a)a)*$, uses up the 1M backtrack limit on each non-matching value. classify.rs:124 then treats the error as "no match". The deadline is only checked between statements (aw-query/src/interpret.rs:31), so one categorize call over many distinct titles runs until it finishes:
query took 14.1s with a 1s budget, status 503 Service Unavailable
That is 60 events, 1 rule, a debug build, and a 1 s budget. The query handler is synchronous, so each such request holds a Rocket worker for the whole time.
Possible fix: pass the deadline into categorize / tag / filter_keyvals_regex and check it per event, or lower backtrack_limit through RegexBuilder.
Neither duplicates #882 (parser and lexer issues) or #881 (non-finite numbers).
- 主要言語
- Rust
- スター
- 322
- フォーク
- 107
- 平均マージ
- 2日 16時間
- マージ済み PR(30日)
- 25
環境構築
このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ActivityWatch/aw-server-rust のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
ActivityWatch/aw-server-rust#883 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 80/100
ActivityWatch/aw-server-rust#872 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
ActivityWatch/aw-server-rust#798 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
aw-client CLI ignores aw-client.toml host/port対応中かも @TimeToBuildBob が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 35/100
ActivityWatch/aw-server-rust#888 ·
メンテナーはふだん 1 日以内に返信
-
aw-sync status calls the daemon's live staging db orphaned and safe to delete対応中かも @TimeToBuildBob が今日担当しました。 オープン
難易度 3/5 1〜2日 初心者へのやさしさ 30/100
ActivityWatch/aw-server-rust#887 ·
メンテナーはふだん 1 日以内に返信
ActivityWatch/aw-server-rust の issue をすべて見る
似ている issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
kashsuks/Pinel#172 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 69/100
メンテナーはふだん 1 日以内に返信
-
test_a_503_raises_unavailable_error fails on macOS about one run in six対応中かも @naman-modi が今日担当しました。 オープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
bug ui
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
userFRM/egui-charts#4168 ·
メンテナーはふだん 1 日以内に返信
-
難易度 1/5 1時間未満 初心者へのやさしさ 85/100
メンテナーはふだん 1 日以内に返信