Skip to content

[Bug] Unbounded q parameter in /history/search allows resource exhaustion #1030

@Pcmhacker-piro

Description

@Pcmhacker-piro

Description

The GET /history/search endpoint defines q as:

q: str = Query(..., min_length=1)

There is no max_length, so callers can pass arbitrarily large strings. Since q is passed directly to an FTS5 MATCH expression in database.py:search_entries(), a very large or complex FTS5 expression can cause excessive CPU and memory usage on the server (especially with FTS5's wildcard and prefix matching features).

Affected Files

  • backend/app/routers/history.py:52 — missing max_length on q Query param
  • backend/app/services/database.py:96 — FTS5 MATCH expression accepts unbounded input

Expected Behavior

q should have max_length=200 (or similar) to prevent abuse:

q: str = Query(..., min_length=1, max_length=200)

Labels

type:bug, level:intermediate, gssoc2026

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions