Skip to content

[Bug] FTS5 Syntax Error DoS in database.py Search Endpoint #1006

@sonusharma6-dsa

Description

@sonusharma6-dsa

Summary

The search_entries function in backend/app/services/database.py executes an FTS5 query using MATCH ? and directly substitutes the raw user-supplied query q. SQLite's FTS5 engine implements a custom syntax for queries. If an unescaped special character (like an unclosed quote " or *) is provided, SQLite throws an OperationalError: fts5: syntax error, which bubbles up as a 500 Internal Server Error.

Impact

Users or attackers can intentionally crash the search endpoint simply by searching for a string like "unclosed, causing application errors.

Proposed Fix

Sanitize the search input q by stripping or escaping FTS5 specific special characters (e.g., ", *, ^, OR, AND) before supplying it to the MATCH query.

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