Skip to content

security(scheduler): add RTW-A temporal re-entry defense#4548

Merged
bug-ops merged 3 commits into
mainfrom
4026-scheduler-reentry-defense
May 28, 2026
Merged

security(scheduler): add RTW-A temporal re-entry defense#4548
bug-ops merged 3 commits into
mainfrom
4026-scheduler-reentry-defense

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented May 28, 2026

Summary

  • Implements four RTW-A mechanisms from arXiv:2605.02812 to prevent attacker-influenced persistent state (SQLite task records, memory files, skill state) from re-entering the LLM decision context across scheduled tick boundaries
  • New [scheduler.security] config section controls all mechanisms individually; enabled by default

Changes

New types and modules

  • TaskProvenance enum (Static / UserAdded / External) in task.rs
  • SchedulerSecurityConfig in zeph-config/features.rs
  • sanitize_task_prompt_checked() in new sanitize.rs — 22-pattern injection detection
  • SchedulerError::InjectionDetected variant

RTW-A mechanisms

  1. Write-Before-Exposed-Read Blockingtick_epoch fence; tasks written during the current tick are quarantined for one tick
  2. Sealed Configuration Protection — DB migration 094_scheduler_provenance.sql adds provenance column; startup tasks tagged Static, runtime-inserted tagged External
  3. Typed Memory Promotionsanitize_task_prompt_checked() blocks External prompts matching injection markers; returns SchedulerError::InjectionDetected
  4. Capability Attenuation — disables high-risk tool categories for the remainder of any tick that reads External state

Bootstrap wiring

  • src/scheduler.rs:313 and src/commands/scheduler_daemon.rs:124 chain .with_reentry_defense(...) using config.scheduler.security fields

Test plan

  • cargo nextest run --config-file .github/nextest.toml -p zeph-scheduler — 89/89 pass
  • cargo clippy --workspace -- -D warnings — clean
  • cargo +nightly fmt --check — clean
  • RUSTFLAGS="-D warnings" cargo check --workspace --all-targets --features desktop,ide,server,chat,pdf,scheduler --locked — clean
  • 4 new RTW-A mechanism tests cover: tick-fence quarantine, provenance hydration, injection pattern detection, capability attenuation flag

Closes #4026

@github-actions github-actions Bot added size/XL Extra large PR (500+ lines) documentation Improvements or additions to documentation rust Rust code changes core zeph-core crate labels May 28, 2026
@bug-ops bug-ops enabled auto-merge (squash) May 28, 2026 19:44
@bug-ops bug-ops force-pushed the 4026-scheduler-reentry-defense branch from 973f8da to acbade6 Compare May 28, 2026 19:44
bug-ops added 3 commits May 28, 2026 22:04
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
@bug-ops bug-ops force-pushed the 4026-scheduler-reentry-defense branch from aa926b4 to 56dab39 Compare May 28, 2026 20:04
@bug-ops bug-ops merged commit 53f8f05 into main May 28, 2026
32 checks passed
@bug-ops bug-ops deleted the 4026-scheduler-reentry-defense branch May 28, 2026 20:11
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core zeph-core crate documentation Improvements or additions to documentation rust Rust code changes size/XL Extra large PR (500+ lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

security(scheduler): add temporal re-entry defense for persistent scheduled task state (arXiv:2605.02812)

1 participant