Qmem

Deterministic memory firewall for AI agents that quarantines tainted memory writes, explains threats with an isolated judge, and requires human approval with signed receipts.

Live demoGitHub0

Overview

The Problem

Persistent AI agent memory is vulnerable to indirect prompt injection (OWASP ASI06). Research like MemGhost (Jul 2026) and A-MemGuard (Oct 2025) shows that a single poisoned email or web page can plant dormant instructions into long-term memory, bypassing over 90% of input filters and 66% of LLM detectors, then triggering data leaks in later sessions.

What We Built

Memory Quarantine is a host-side security proxy that gates every AI agent memory write using deterministic code instead of trusting the model to police itself.

- Server-side provenance & sticky session taint: The sandboxed agent holds zero DB, S3, or LLM credentials. All external reads and memory writes route through a FastAPI proxy using host-minted session tokens, preventing a compromised agent from spoofing source="user". Any external read taints the session.

- Deterministic 13-flag rulebook: Before any memory is committed, pure Python code strips hidden Unicode/bidi characters, checks for directives, external emails/URLs, sensitive tools, canary overlap, and tombstone similarity, and assigns a deterministic verdict (ALLOW, NEEDS_REVIEW, BLOCKED, or FAIL_CLOSED) with a 0-100 risk_score.

- Isolated LLM judge: An isolated judge model (with no raw session access) inspects frozen entries and explains the threat in structured JSON. It can raise review priority, but can never downgrade a code verdict.

- Human-in-the-loop Review UI: Reviewers inspect quarantined rows alongside source snippets, rule flags, and judge notes in a SvelteKit dashboard (/ui), then Purge (leaving a cryptographic tombstone) or Override (requiring a typed reason for BLOCKED/FAIL_CLOSED rows).

- Tamper-evident audit trail: Every state transition appends to a SHA-256 audit_events hash chain and writes an Ed25519-signed receipt.

Research & Detection Foundations
Our deterministic gate and quarantine architecture is grounded in six recent agent-security papers:

  • A-MemGuard (Oct 2025): Demonstrates that LLM-based detectors miss 66% of poisoned memory entries, motivating our pure-code deterministic gate.
  • MemGhost (Jul 2026): Shows a single crafted email can bypass over 90% of input/behavior monitors, motivating our separation of memory-read vs. memory-write provenance controls.
  • Trojan Hippo Bench (Sep 2026): Models dormant email payloads that trigger turns later on pricing or finance queries, informing our cross-session quarantine and canary-overlap rules.
  • MemSentry (Sep 2026): Introduces pre-commit deterministic routing (Accept, Review, Quarantine) using provenance and directive rules.
  • PerMIT (Oct 2026): Defines a finite interface that trusts only authenticated user inputs and gate-confirmed content hashes.
  • The Price of Safety (Sep 2026): Provides the framework for measuring false-positive friction on benign tasks alongside attack containment.

    Link to the honeypot:

https://helenes-cafes-stockholm.store

How it uses Vultr

- Vultr Cloud Compute (ams1, 45.77.138.3): Hosts the FastAPI Memory Proxy, the static SvelteKit Review UI (/ui), and the isolated Docker crawl/agent sandbox. Each sandboxed run executes in an ephemeral container with --network=none, read-only rootfs, all Linux capabilities dropped, and zero DB/S3/LLM credentials; all external fetches and memory calls are brokered by the host proxy. - Vultr Object Storage (ams1, cluster 6, bucket "quarantine-receipts"): Stores Ed25519-signed quarantine/override/purge receipts and redacted, SHA-256-verified NDJSON run logs (logs/crawl/<run_id>.jsonl) with a 30-day lifecycle expiration rule. - Vultr Serverless Inference: Powers both the sandboxed worker model and the separate, isolated judge model that analyzes frozen quarantine payloads without access to raw session history. - PostgreSQL + pgvector: Stores active memories (read-only via a restricted memory_reader role so quarantined rows never reach agent recall), the quarantine_queue, purged payload-hash tombstones, and the append-only SHA-256 audit_events chain.

No comments yet

Be the first to comment on this project.