Skip to content

fix(sqlite): invalidate cached engine when VFS file changes#1599

Merged
chaliy merged 1 commit intomainfrom
2026-05-08-propose-fix-for-sqlite-cache-vulnerability
May 8, 2026
Merged

fix(sqlite): invalidate cached engine when VFS file changes#1599
chaliy merged 1 commit intomainfrom
2026-05-08-propose-fix-for-sqlite-cache-vulnerability

Conversation

@chaliy
Copy link
Copy Markdown
Contributor

@chaliy chaliy commented May 8, 2026

Motivation

  • The session-scoped SQLite engine cache reused engines keyed only by backend+path, allowing stale in-memory DB state to be read and flushed back after the VFS file was deleted or replaced.
  • This could resurrect deleted data or overwrite a replacement file inside a Bash session, causing confidentiality/integrity issues within the VFS sandbox.

Description

  • Before reusing a cached file-backed engine, compare the engine's snapshot_bytes() with the current ctx.fs.read_file(path) and force a reopen when the bytes differ or the read fails. (change in crates/bashkit/src/builtins/sqlite/mod.rs around the file-target path handling)
  • Preserve existing semantics for :memory: targets (still ephemeral per-invocation). (no behavioural change to memory backend)
  • Add two integration tests that cover deletion and replacement between exec() calls to guard against stale-cache resurrection and overwrite regressions. (added tests in crates/bashkit/tests/sqlite_integration_tests.rs)

Testing

  • Ran the new integration tests filter with cargo test --features sqlite -p bashkit --test sqlite_integration_tests -- cached_engine_respects_, and both tests passed (2 passed, 0 failed).
  • An earlier test run exposed an error which led to tightening the deleted-DB expectation; after the code change and test update the targeted integration tests passed.
  • Build/test compilation completed locally for the modified test target during verification.

Codex Task

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

cloudflare-workers-and-pages Bot commented May 8, 2026

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 d10b2fe Commit Preview URL May 08 2026, 09:09 AM

@chaliy chaliy force-pushed the 2026-05-08-propose-fix-for-sqlite-cache-vulnerability branch from 2ef130a to d10b2fe Compare May 8, 2026 09:08
@chaliy chaliy merged commit 4501b0c into main May 8, 2026
34 checks passed
@chaliy chaliy deleted the 2026-05-08-propose-fix-for-sqlite-cache-vulnerability branch May 8, 2026 09:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant