Skip to content

fix(sqlite): fail-close quoted/mutating PRAGMAs and block load_extension() - #564

Open
archidoge0 wants to merge 1 commit into
bytebase:mainfrom
archidoge0:fix/sqlite-pragma-and-load-extension
Open

archidoge0 wants to merge 1 commit into
bytebase:mainfrom
archidoge0:fix/sqlite-pragma-and-load-extension

Conversation

@archidoge0

Copy link
Copy Markdown

Fixes #562.

Changes

  1. Fail-closed SQLite PRAGMA validation (src/utils/allowed-keywords.ts):
    • Any parenthesized PRAGMA now fails closed unless it matches sqlitePragmaParenPattern and is in sqliteReadOnlyArgPragmas (closing quoted/bracketed/backticked setter forms such as PRAGMA [query_only](0), PRAGMA "query_only"(0), PRAGMA query_only(0), PRAGMA main.[user_version](1337)).
    • Any bare PRAGMA must match sqlitePragmaBarePattern and is rejected if it is a state-mutating no-arg pragma (wal_checkpoint, optimize, incremental_vacuum, shrink_memory).
    • Added table_xinfo to sqliteReadOnlyArgPragmas.
  2. Block load_extension() (src/utils/allowed-keywords.ts): Added sqlite: ["load_extension"] to escapeHatchFunctionKeywords.
  3. Tests (src/utils/__tests__/allowed-keywords.test.ts): Added 8 regression tests covering quoted PRAGMA setters, no-arg mutating pragmas, and load_extension() (141/141 unit tests in allowed-keywords.test.ts and postgres-sql.test.ts pass).

@archidoge0
archidoge0 requested a review from tianzhou as a code owner December 4, 2026 12:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug] readonly mode: SQLite PRAGMA quoting bypass (PRAGMA [query_only](0) / "query_only"(0)), no-arg mutating pragmas, and missing load_extension()

1 participant