security(scheduler): add RTW-A temporal re-entry defense#4548
Merged
Conversation
973f8da to
acbade6
Compare
Implements four RTW-A mechanisms from arXiv:2605.02812 to prevent attacker-influenced persistent state from re-entering the LLM decision context on scheduled tick boundaries: 1. Write-Before-Exposed-Read Blocking — tick_epoch fence tracks intra-tick writes; tasks written during the current tick are quarantined until the next tick before entering the prompt channel. 2. Sealed Configuration Protection — DB provenance column distinguishes Static (startup-registered) tasks from External (runtime-inserted) ones; migration 094_scheduler_provenance.sql (SQLite + Postgres). 3. Typed Memory Promotion — sanitize_task_prompt_checked() rejects External-provenance prompts matching 22 known injection markers (case-insensitive); returns SchedulerError::InjectionDetected. 4. Capability Attenuation — after an external read within a tick, high-risk tool categories are disabled for the remainder of that tick. New [scheduler.security] config section controls all four mechanisms individually. Defenses are enabled by default and wired in both the agent-loop and scheduler-daemon bootstrap paths. Closes #4026
…ks in RTW-A doc comments
aa926b4 to
56dab39
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
[scheduler.security]config section controls all mechanisms individually; enabled by defaultChanges
New types and modules
TaskProvenanceenum (Static/UserAdded/External) intask.rsSchedulerSecurityConfiginzeph-config/features.rssanitize_task_prompt_checked()in newsanitize.rs— 22-pattern injection detectionSchedulerError::InjectionDetectedvariantRTW-A mechanisms
tick_epochfence; tasks written during the current tick are quarantined for one tick094_scheduler_provenance.sqladdsprovenancecolumn; startup tasks taggedStatic, runtime-inserted taggedExternalsanitize_task_prompt_checked()blocksExternalprompts matching injection markers; returnsSchedulerError::InjectionDetectedExternalstateBootstrap wiring
src/scheduler.rs:313andsrc/commands/scheduler_daemon.rs:124chain.with_reentry_defense(...)usingconfig.scheduler.securityfieldsTest plan
cargo nextest run --config-file .github/nextest.toml -p zeph-scheduler— 89/89 passcargo clippy --workspace -- -D warnings— cleancargo +nightly fmt --check— cleanRUSTFLAGS="-D warnings" cargo check --workspace --all-targets --features desktop,ide,server,chat,pdf,scheduler --locked— cleanCloses #4026