Skip to content

SQLite performance environment values should be capped #2889

Description

@Widthdom

Finding

SQLite performance pragmas accept environment-provided cache and mmap sizes with no explicit upper bound. Accidental or hostile environment values can request very large SQLite cache or mmap windows for every DbContext connection.

Evidence

  • src/CodeIndex/Database/DbContext.cs:486 applies PRAGMA cache_size=-{ReadPositiveIntEnvironment(...)}.
  • src/CodeIndex/Database/DbContext.cs:489 applies PRAGMA mmap_size={ReadNonNegativeLongEnvironment(...)} on 64-bit processes.
  • src/CodeIndex/Database/DbContext.cs:492 accepts any positive int for CDIDX_SQLITE_CACHE_KB.
  • src/CodeIndex/Database/DbContext.cs:498 accepts any non-negative long for CDIDX_SQLITE_MMAP_BYTES.

Suggested fix

Define documented maximums, clamp or reject larger values with a warning, and add tests for overflow and excessive values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions