Skip to content

fix(sqlite): harden pragma policy and db caps#1521

Merged
chaliy merged 1 commit intomainfrom
fix/sqlite-exploratory-hardening
May 4, 2026
Merged

fix(sqlite): harden pragma policy and db caps#1521
chaliy merged 1 commit intomainfrom
fix/sqlite-exploratory-hardening

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented May 4, 2026

What

Harden the experimental SQLite builtin after exploratory black-box and white-box testing.

Why

Exploratory probes found two issues:

  • quoted/schema-qualified PRAGMAs like PRAGMA main."cache_size" bypassed the deny list
  • VFS-backed SQLite databases did not consistently honor custom max_db_bytes while growing

SQLite remains opt-in for now.

How

  • Extend PRAGMA policy parsing to handle SQL comments and quoted/bracket/backtick identifiers.
  • Enforce max_db_bytes during VFS writes/truncates and before memory-backend persistence.
  • Drop oversized cached memory engines instead of retaining an over-cap image.
  • Update internal and public threat models plus SQLite spec notes.

Risk

  • Medium
  • SQLite execution and cached file-backed database persistence can break if Turso emits unexpected IO growth patterns or if callers relied on previously uncapped oversized DB writes.

Checklist

  • Tests added or updated
  • Backward compatibility considered

Verification:

  • cargo test --features sqlite -p bashkit --lib sqlite
  • cargo test --features sqlite -p bashkit --test sqlite_security_tests --test sqlite_integration_tests --test sqlite_compat_tests --test sqlite_differential_tests --test sqlite_fuzz_tests
  • just pre-pr
  • CLI smoke: cargo run -q -p bashkit-cli -- -c "sqlite :memory: 'PRAGMA main.\"cache_size\"'"

@cloudflare-workers-and-pages
Copy link
Copy Markdown

Deploying with  Cloudflare Workers  Cloudflare Workers

The latest updates on your project. Learn more about integrating Git with Workers.

Status Name Latest Commit Preview URL Updated (UTC)
✅ Deployment successful!
View logs
bashkit 66f7e7c Commit Preview URL

Branch Preview URL
May 04 2026, 02:44 AM

@chaliy chaliy marked this pull request as ready for review May 4, 2026 02:45
@chaliy chaliy merged commit 2a8ebe4 into main May 4, 2026
34 checks passed
@chaliy chaliy deleted the fix/sqlite-exploratory-hardening branch May 4, 2026 02:56
@codecov
Copy link
Copy Markdown

codecov Bot commented May 4, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

chaliy added a commit that referenced this pull request May 4, 2026
Minor release bumping `0.3.0` → `0.4.0`.

## Highlights

- **Builtin extension abstraction** — New public `Extension` trait
groups related builtins for one-call registration on
`BashBuilder`/`BashToolBuilder`. TypeScript registration now flows
through `TypeScriptExtension`, and `ScriptedTool` reuses a shared
`ToolDefExtension` for its per-call logic shell (#1515, #1518).
- **Clap-backed custom builtins** — Custom builtins can now be defined
declaratively against a `clap` parser, replacing hand-rolled arg parsing
for new integrations (#1514).
- **SQLite session engine cache** — The `sqlite` builtin keeps a
session-scoped engine alive across `exec()` calls, so transactions and
prepared state survive multiple shell invocations within one session
(#1513).
- **SQLite hardening follow-up** — PRAGMA policy parsing now handles SQL
comments and quoted/bracket/backtick identifiers (closing a `PRAGMA
main."cache_size"` bypass), and `max_db_bytes` is enforced consistently
across VFS writes/truncates and memory-backend persistence (#1521).
- **Python + toolchain bumps** — Embedded Python (`monty`) bumped to
`0.0.17` and Rust toolchain bumped to `1.95.0` across
`rust-toolchain.toml` and matching CI workflow refs (#1520).

## Files

- `Cargo.toml`, `crates/bashkit-cli/Cargo.toml`, `Cargo.lock` → `0.4.0`
- `crates/bashkit-js/package.json`,
`crates/bashkit-js/package-lock.json` → `0.4.0`
- `CHANGELOG.md` — new `[0.4.0] - 2026-05-04` section

On merge, `release.yml` will create the GitHub Release and dispatch the
publish workflows for crates.io, PyPI, npm, and Homebrew.

**Full Changelog**:
v0.3.0...v0.4.0

---
_Generated by [Claude
Code](https://claude.ai/code/session_01MTiBUK5YiumTRtqjogv9A5)_
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.

1 participant