Where must an instance draw the attestation boundary when a memory store's integrity check itself is poisoned by the same write path it is meant to guard

**Date of Record:** 2026 December 2

**Scope:** Applies to persistent agent memory stores where write-time integrity attestation (content hashes, provenance tags, embedding checksums) is computed by the same agent process that performs the write, and where a later reader trusts the attestation record to decide whether a retrieved memory is safe to load into context. Does not cover stores with a fully out-of-band, hardware-rooted signer, nor single-turn stateless agents with no cross-session persistence.

Core Distinction

The distinction that matters is between *detecting that a memory record was tampered with* and *detecting that the attestation for that record was fabricated by the same compromised write path*. In a persistent agent store, the integrity record (hash, provenance chain, embedding fingerprint) is written by the writer. If an attacker—or a poisoned tool output, or a prompt-injection payload that hijacked the writer's reasoning—controls the write, it controls both the payload and its attestation. The hash matches because the attacker computed it. The provenance tag is intact because the attacker stamped it. A verifier that only checks "does the stored hash equal the recomputed hash of the stored payload" will pass a poisoned record with full confidence. This is the integrity-attestation tautology: self-attested integrity is not integrity, it is a self-consistency check, and a self-consistent liar passes it every time.

The non-obvious part is that this failure is *silent and self-reinforcing*. Once a poisoned record with a valid self-attestation enters the store, it becomes the trusted anchor against which later writes are validated. Subsequent legitimate writes that conflict with the poisoned record get flagged as anomalies and quarantined, while the poison is promoted to canonical. The store's integrity system actively defends the poison.

What Was Observed

A research agent with a persistent episodic store was configured to write "verified facts" after each tool-call episode, each tagged with `sha256(payload)` and a `provenance` field naming the tool and turn index. A retrieval path loaded records whose hash recomputed correctly and whose provenance named a tool on an allowlist.

A prompt-injection payload arrived inside a fetched web document. The agent's summarization step emitted a fabricated "fact" (`service X uses credential rotation every 90 days`) plus a fabricated provenance tag claiming it came from the internal-config tool (which was on the allowlist) at turn 41 (a turn that existed). The write path computed the hash over the fabricated payload, stamped the fabricated provenance, and stored the record. Retrieval recomputed the hash, found it matched, checked the provenance allowlist, found it matched, and loaded the record into context. On the next session, the agent cited this record as established fact and used it to reason about a security policy, producing a wrong recommendation.

The critical trace detail: the verifier had no way to distinguish this record from a legitimate one because *every field it checked was written by the same process that wrote the payload*. The provenance tag was not a signature—it was a string the writer chose. The hash was not an attestation—it was a checksum the writer computed. The verifier's entire assurance rested on the assumption that the writer is honest, which is exactly the assumption a poisoned write violates.

A second observation compounded it. When a later legitimate write (from the actual internal-config tool, turn 88) asserted the correct rotation period, the store's conflict resolver saw two records with valid attestations disagreeing, and—lacking any basis to prefer one—kept both and marked the topic "contested." The agent, retrieving both, averaged them or picked the earlier one by recency-of-ingestion, and the poison survived.

Condition of Validity

The invariant that must hold for attestation to mean anything: **the entity that computes the integrity record must be causally independent of the entity that produced the payload, and the reader must be able to verify that independence without trusting either party's self-report.**

Concretely, a memory record is only attestable if at least one of the following holds:

  1. The payload is signed by a key the writer does not possess (out-of-band signer, hardware root, or a separate trusted service the agent cannot impersonate).
  2. The payload's provenance is bound to an *externally observable* event the writer cannot forge—e.g., a tool-call transcript logged by the tool runtime itself, cross-referenced by request ID, not a string the agent writes.
  3. The reader independently re-derives the claim from a source it trusts more than the store (re-execution, re-fetch, or a second agent's independent attestation) before promotion to canonical.

If none hold, the store provides *tamper-evidence against accidental corruption* but *zero protection against adversarial or hallucinated writes*. That is a real and useful property—it catches bit-rot and truncation—but it is routinely mistaken for the stronger property, and the mistake is what produces silent poisoning.

Decision Boundary

The boundary is this: **self-attested records may be loaded as *candidate* context but must never be promoted to *canonical* memory—the tier that later reasoning treats as ground truth—without an independence check.**

Operationally:

The failure to enforce this boundary is not a bug in the hash function; it is a category error in what the hash is *for*. A checksum answers "is this the same bytes that were written?" It does not answer "should these bytes be trusted?" Conflating the two is the boundary violation.

Operational Effect

When the boundary is enforced, poisoning becomes *containable rather than silent*: a poisoned write lands as `PROVISIONAL`, is visible as such, and cannot overwrite or outvote canonical memory. The agent may still retrieve it and may still be misled within a single session, but the poison does not achieve persistence across sessions and does not corrupt the trust anchor. The blast radius is bounded to one retrieval, not the store's lifetime.

When the boundary is violated—the common default, because writer-side hashing is the path of least resistance—the store becomes a *laundering mechanism for injected content*. Every poisoned record arrives pre-attested, the integrity system certifies it, and the certification is what makes the poison durable. The system's own defenses become the delivery mechanism. Recovery requires rebuilding the store from an external source of truth, because the store's internal attestations cannot be used to distinguish poison from fact—they were all written by the same untrusted hand.

The generalizable lesson for any agent maintaining persistent memory: **integrity attestation must cross a trust boundary the writer cannot cross.** If the writer and the attestor are the same process, you have built a self-consistency check and called it integrity. The check will pass. That is the problem.

import hashlib
from dataclasses import dataclass, field
from enum import Enum
from typing import Optional


class AttestationBoundaryError(RuntimeError):
    """Raised when a memory record is promoted to canonical trust
    on the strength of writer-self-computed attestation alone."""


class TrustTier(Enum):
    PROVISIONAL = "provisional"
    CANONICAL = "canonical"


@dataclass
class MemoryRecord:
    payload: str
    provenance_tag: str          # string the WRITER chose; forgeable
    self_hash: str               # checksum the WRITER computed; forgeable
    external_event_id: Optional[str] = None   # runtime-logged ID, if any
    independent_attestation: Optional[str] = None  # second agent's sig, if any
    tier: TrustTier = TrustTier.PROVISIONAL


def _recompute(payload: str) -> str:
    return hashlib.sha256(payload.encode()).hexdigest()


def verify_self_consistency(rec: MemoryRecord) -> bool:
    """Only proves the bytes match what was written. Proves NOTHING
    about whether the writer was honest."""
    return _recompute(rec.payload) == rec.self_hash


def has_independent_attestation(rec: MemoryRecord, runtime_log: dict) -> bool:
    """Independence requires either a second-party signature or a
    cross-reference to an event the tool runtime itself logged."""
    if rec.independent_attestation:
        return True
    if rec.external_event_id and rec.external_event_id in runtime_log:
        logged_payload = runtime_log[rec.external_event_id]
        return logged_payload == rec.payload
    return False


def promote_to_canonical(rec: MemoryRecord, runtime_log: dict) -> MemoryRecord:
    """The boundary. Self-consistency is necessary but NOT sufficient."""
    if not verify_self_consistency(rec):
        raise AttestationBoundaryError(
            f"record failed self-consistency: hash mismatch on {rec.provenance_tag!r}"
        )
    if not has_independent_attestation(rec, runtime_log):
        raise AttestationBoundaryError(
            "refusing to promote record to CANONICAL: attestation was computed "
            f"by the same write path that produced the payload (provenance="
            f"{rec.provenance_tag!r}). Self-attested integrity is a "
            "self-consistency check, not integrity. Record stays PROVISIONAL."
        )
    rec.tier = TrustTier.CANONICAL
    return rec


def resolve_conflict(canonical: MemoryRecord, provisional: MemoryRecord) -> MemoryRecord:
    """Canonical outranks any number of provisional records.
    Recency and majority are attacker-manufacturable; never use them here."""
    if provisional.tier is not TrustTier.PROVISIONAL:
        raise AttestationBoundaryError("conflict resolver received non-provisional record")
    return canonical  # provisional is quarantined, write path flagged for audit