fix(security): bound ShadowSentinel hot-path DB reads with an explicit timeout - #6293
Merged
Conversation
bug-ops
enabled auto-merge (squash)
July 14, 2026 18:51
bug-ops
force-pushed
the
fix/6269-shadow-sentinel-db-timeout
branch
2 times, most recently
from
July 14, 2026 19:05
973b671 to
e214434
Compare
…t timeout check_tool_call awaited get_trajectory and get_tool_history with no timeout on the pre-tool-dispatch hot path shared by every high-risk tool call. A stalled DB connection (e.g. a slow Postgres backend) could block dispatch of every Shell/FileWrite/ExfilCapable/ McpUnclassified tool call for the session. Both reads are now wrapped in tokio::time::timeout, bounded by the existing probe_timeout_ms.min(2000) config value. A timeout falls back to the same empty/partial result the pre-existing DB-error branch already produced, matching ShadowSentinel's documented fail-open contract. Closes #6269
bug-ops
force-pushed
the
fix/6269-shadow-sentinel-db-timeout
branch
from
July 14, 2026 19:15
e214434 to
5bf7e9f
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
ShadowSentinel::check_tool_callawaited two DB reads (get_trajectory,get_tool_history) on the pre-tool-dispatch hot path shared by every high-risk tool call (Shell/FileWrite/ExfilCapable/McpUnclassified) with no timeout — a stalled DB connection (e.g. a slow/unresponsive Postgres backend) could block dispatch indefinitely.tokio::time::timeout, bounded by the existingprobe_timeout_ms.min(2000)config value (no new config field). A timeout logs a warning and falls back to the same empty/partial result the pre-existing DB-error branch already produced — fail-open, matchingShadowSentinel's documented defence-in-depth contract.load_probe_contextmethod to stay underclippy::too_many_linesafter adding the timeout wrapping; behavior-preserving, verified line-by-line against the pre-fix code.2 * probe_timeout_ms.min(2000) + probe_timeout_ms, ~6s at defaults) rather than a misleading single shared ~2s bound.Closes #6269
Test plan
check_tool_call_falls_open_when_both_db_reads_stall: forces a genuine timeout via real SQLite pool exhaustion (max_connections(1)on:memory:), verifies both DB reads independently hit their timeout branch (both distinct warn logs fire) andcheck_tool_callstill resolves fail-open with an empty trajectory despite real seeded data existing.cargo +nightly fmt --checkcargo clippy --profile ci --workspace --all-targets --features "desktop,ide,server,chat,pdf,scheduler,testing" -- -D warningscargo nextest run --config-file .github/nextest.toml --workspace --features "desktop,ide,server,chat,pdf,scheduler" --lib --bins— full suite greenRUSTFLAGS="-D warnings" RUSTDOCFLAGS="--deny rustdoc::broken_intra_doc_links") — clean, new intra-doc link resolvesgitleaks protect --staged— no leaks