T02 · Agent Memory Poisoning
- Location
scripts/orchestrator_v4_acp.py:84- Finding
Persistent checkpoint restoration enables cross-session agent memory poisoning
- Content
View full analysis
Vulnerability Details
File Location:
scripts/orchestrator_v4_acp.py:84-88,scripts/orchestrator_v4_acp.py:192-203,scripts/orchestrator_v4_acp.py:314-315,scripts/orchestrator_v4_acp.py:1319-1341,scripts/orchestrator_v4_acp.py:1825-1863
Vulnerability Type: Unauthenticated persistent state restoration and plaintext conversation storage
Risk Level: MediumVulnerable Code
python checkpoint_dir: str = "./checkpoints" auto_checkpoint: bool = True checkpoint_interval_sec: float = 60.0 resume_from_latest_checkpoint: bool = True latest_checkpoint_name: str = "checkpoint_latest.json"python async def start(self): if self.config.resume_from_latest_checkpoint: self._load_latest_checkpoint() self.state = SessionState.ACTIVEpython async def _save_checkpoint(self, suffix: str = "auto"): checkpoint = { "session_id": self._session_id, "timestamp": time.time(), "history": self.context_manager._history, "stats": self._stats, "request_context": self._request_context } path = Path(self.config.checkpoint_dir) / f"checkpoint_{self._session_id}_{suffix}.json" latest_path = Path(self.config.checkpoint_dir) / self.config.latest_checkpoint_name try: with open(path, "w", encoding="utf-8") as f: json.dump(checkpoint, f, ensure_ascii=False, indent=2) with open(latest_path, "w", encoding="utf-8") as f: json.dump(checkpoint, f, ensure_ascii=False, indent=2) except Exception as e: self._log("error", f"Failed to save checkpoint: {e}")python def _load_latest_checkpoint(self): latest_path = Path(self.config.checkpoint_dir) / self.config.latest_checkpoint_name if not latest_path.exists(): return try: with open(latest_path, "r", encoding="utf-8") as f: checkpoint = json.load(f) ...[truncated 3653 chars]- Remediation
View remediation
Remediation Suggestions
- Disable
resume_from_latest_checkpointby default and require explicit user opt-in before restoring conversational state. - Store checkpoints in a private, per-user runtime data directory rather than a workspace-relative directory.
- Create the checkpoint directory with owner-only permissions and checkpoint files with mode
0600. - Write checkpoints atomically using a securely created temporary file followed by an atomic replacement.
- Protect checkpoint integrity with an authenticated MAC or equivalent mechanism using a key stored outside the workspace.
- Bind each checkpoint to an expected user, workspace, Skill version, and session identifier. Reject mismatches.
- Validate the complete JSON schema, including allowed keys, entry count, field types, role values, and maximum lengths.
- Treat all restored content as untrusted data. Clearly delimit it in prompts and instruct delegated agents not to interpret historical content as higher-priority instructions.
- Avoid persisting user content unless necessary. Provide configurable retention limits and secure deletion controls.
- Redact credentials, tokens, private keys, and other sensitive patterns before writing checkpoint data.
- Disable
