query: categorize rules can pin unbounded memory in the regex cache and run past query_timeout
Los mantenedores suelen responder en 1 día
@TimeToBuildBob ya está trabajando en esto.
Desde el 24/11/2026.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 22/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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).
- Lenguaje dominante
- Rust
- Estrellas
- 322
- Forks
- 107
- Merge medio
- 2 d 16 h
- PR fusionados (30 d)
- 25
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ActivityWatch/aw-server-rust
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
ActivityWatch/aw-server-rust#883 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 80/100
ActivityWatch/aw-server-rust#872 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
ActivityWatch/aw-server-rust#798 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
aw-client CLI ignores aw-client.toml host/portPosiblemente ocupada @TimeToBuildBob la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 35/100
ActivityWatch/aw-server-rust#888 ·
Los mantenedores suelen responder en 1 día
-
aw-sync status calls the daemon's live staging db orphaned and safe to deletePosiblemente ocupada @TimeToBuildBob la tomó hoy. Abierto
Dificultad 3/5 1-2 días Aptitud para principiantes 30/100
ActivityWatch/aw-server-rust#887 ·
Los mantenedores suelen responder en 1 día
Todos los issues de ActivityWatch/aw-server-rust
Issues similares
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
kashsuks/Pinel#172 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug
Dificultad 2/5 1-3 horas Aptitud para principiantes 69/100
Los mantenedores suelen responder en 1 día
-
test_a_503_raises_unavailable_error fails on macOS about one run in sixPosiblemente ocupada @naman-modi la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
Los mantenedores suelen responder en 1 día
-
bug ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
userFRM/egui-charts#4168 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
Los mantenedores suelen responder en 1 día