Skip to content
Blog
November 8, 2026Compliance10 min read

How to erase a user from a hash-chained agent log: five approaches compared

To erase one person from an append-only, hash-chained LLM audit log, you either change the log or make their part of it unreadable. Deleting and re-rooting, per-subject KMS keys, per-subject data keys, off-log storage and Kafka tombstones, compared on what each leaves behind.

byPleach maintainers

Drafted by an AI agent, from a research brief, primary sources and the Pleach docs; reviewed by a maintainer before publishing.

No @pleach/* package is on npm yet. Each name holds a 0.0.1 placeholder until its first release, so the code here describes the source, not an install that works today. Package status

To erase one person from a hash-chained agent log, you either rewrite the chain or make that person's rows unreadable. Deleting rows and re-rooting the chain removes the data and breaks every earlier proof. Crypto-shredding keeps the chain and leaves ciphertext behind. Keeping personal data off the log entirely moves the problem to a second store. None of them erases the copies the log can't see, and backups are the copy regulators ask about most.

The EDPB's 2025 enforcement report on the right to erasure found that "many controllers were found not to have specific procedures and measures in place to handle erasure requests in the context of back-ups" (EDPB CEF report). For how the chain itself works, see hash chain vs append-only table vs OTel traces. For what each row records, see adding an audit ledger without rewriting your agent loop.

The approaches side by side

PropertyDelete and re-rootOne cloud KMS key per subjectPer-subject data keys in your databasePersonal data kept off the logKafka tombstones and compaction
What stays in the logNothing of the subjectCiphertextCiphertextA pointer, keyed hash or commitmentOlder records until compaction runs
Chain after erasureRebuilt; earlier proofs stop verifyingIntactIntactIntactNo chain; compaction rewrites segments
Unreadable whenAt the rewriteAt scheduling (key unusable); destroyed 7–30 days later on AWSAt the key deleteAt the side-store deleteAfter compaction; tombstone kept 24 h by default
Database backupsHold plaintext rowsHold ciphertext onlyHold the wrapped keySide-store backups hold the dataBroker replicas and consumers keep copies
Main costRewriting every later row$1 per key per month on AWS; 100,000 keys per Region by defaultOne key table and a key-encryption keyA second store to secure and eraseTopic design keyed by subject

These rows are not like-for-like. A cloud KMS and a key table in your database are two places to keep the same per-subject key. Kafka is an event stream, not a hash chain. It's here because teams often reach for compaction first.

What happens if you delete rows and re-root the chain?

The data goes, and so does every proof that pointed at the old chain. Each row's hash feeds the next, so deleting one row makes every later row fail verification. Re-rooting means recomputing the chain from a new starting value.

That rewrite has a cost beyond compute. Any attestation, timestamp or external anchor taken before the erasure was signed over the old hashes. After the rewrite, none of them verify. The changed root is itself the record that erasure happened.

It suits a log nobody outside your team has ever checked. It doesn't suit a log whose value is that third parties can verify it later.

How does crypto-shredding with a cloud KMS work?

You encrypt each subject's personal fields under a key held only in the KMS, and you destroy that key on erasure. The log keeps the ciphertext, so every hash and every external anchor still verifies.

Key destruction is not instant on either major cloud. AWS KMS "requires you to set a waiting period of 7 – 30 days. The default waiting period is 30 days" (AWS KMS: delete a key). During that window, "a KMS key pending deletion cannot be used in any cryptographic operations." After it, the data "becomes unrecoverable."

Google Cloud KMS works the same way. "The default scheduled for destruction duration is 30 days," and "after a key is destroyed, data that was encrypted with the key version can't be decrypted" (Cloud KMS: destroy and restore).

The unusable-at-scheduling state is what makes this practical. You can show the data is unreadable on the day of the request, then show destruction when the window closes.

Two limits come with it. AWS notes that scheduling deletion "might not immediately affect data keys encrypted by the KMS key", because a data key already decrypted in memory keeps working until it's used again against the KMS. And one key per subject has a price. "Each AWS KMS key that you create in AWS KMS costs $1/month" (AWS KMS pricing), and the default quota is 100,000 customer managed keys per Region, adjustable (AWS KMS quotas).

HashiCorp Vault's Transit engine supports the same pattern with a named key per subject. Deletion is off by default: "the deletion_allowed tunable must be set in the key's /config endpoint." Once deleted, "it will no longer be possible to decrypt any data encrypted with the named key" (Vault Transit API).

How do per-subject data keys in your own database differ?

You generate one data key per subject, wrap it under a single key-encryption key, and store the wrapped key in a table next to the log. Erasure deletes that row. This is envelope encryption with the per-subject layer moved out of the KMS.

The trade is cost against backup exposure. You pay for one key-encryption key instead of one KMS key per subject, and the delete takes effect immediately. But the wrapped data key now lives in your database, so every database backup taken before the shred holds it too.

A restored backup plus a live key-encryption key opens the ciphertext again. That's the gap the EDPB report points at. Where modifying a backup isn't advisable, "organisations should have appropriate procedures to keep track of erasure requests and comply with them on restored systems."

A practical answer is to re-apply every shred recorded since the backup was taken, before the restored database serves reads. That needs an erasure log that survives the restore.

What if personal data never enters the log?

Then there's nothing in the log to erase. The log stores a pointer, a keyed hash, or a cryptographic commitment, and the personal data sits in a separate store you can delete from.

This is the EDPB's preferred design for blockchains, the strictest case of an immutable log. Its guidelines say "it is not advisable to register personal data in those forms on a blockchain. Instead, personal data in those forms should be stored off-chain" (EDPB Guidelines 02/2025, version 2.0).

The guidelines add three warnings that apply to any audit log:

  • Encryption is not anonymisation. "Encrypted personal data is still personal data and encryption does not remove the need for GDPR compliance."
  • A keyed hash is still personal data. After the secret key or salt is deleted, the hash "should not be linkable to the original data," provided the key never leaked.
  • Unkeyed hashes fall short. They "should, in general, not be considered sufficient" for confidentiality, because a guessed input can be hashed and compared.

The cost is the second store. It needs its own access control, backups and erasure path, and an auditor now reads two systems to answer one question.

Do Kafka tombstones count as erasure?

They count as deletion from the topic, eventually. A tombstone is "a message with a key and a null payload," and compaction later drops older records for that key (Confluent: Kafka log compaction).

The timing is loose by design. delete.retention.ms keeps the tombstone itself for 24 hours by default, so lagging consumers still see the delete. "Compaction in Kafka does not guarantee there is only one record with the same key at any one time." Records already copied out by consumers, into a warehouse or a cache, are untouched.

Compaction also rewrites log segments, which is the opposite of what a hash chain promises. Use it for stream state keyed by subject. Don't use it as the erasure step for an audit trail.

What does every approach leave behind?

Every approach erases one store. The EDPB report asks controllers to "verify that erasure has been carried out and be able to demonstrate such erasure", and none of these mechanisms can demonstrate erasure of a copy it doesn't hold.

Check these copies for any design:

  • Backups and replicas. Plaintext rows under delete-and-re-root, wrapped keys under database-held keys.
  • Plaintext written before encryption. Rows logged before you turned encryption on stay readable.
  • Fields outside the encrypted set. A name in a field you didn't mark as personal stays in clear.
  • Exports, caches and other tables. A shred of the log doesn't follow a CSV someone downloaded.
  • Model provider copies. A prompt sent to a hosted model is governed by that provider's retention, not your log.
  • Unkeyed digests. A plain hash of a short field can confirm a guessed value after erasure.

Article 17(3) of the GDPR also lists exemptions, including "compliance with a legal obligation" and "the establishment, exercise or defence of legal claims" (GDPR Article 17). An audit log kept under a recordkeeping rule may sit under one of them. That's a legal question for your counsel, and it decides whether you erase at all.

When to use each

  • The log has never been attested or anchored externally: delete and re-root is the simplest honest answer.
  • You have a few thousand subjects and want backups to hold only ciphertext: one cloud KMS key per subject.
  • You have many subjects and a restore procedure you control: per-subject data keys in your database, with shreds re-applied on every restore.
  • You're designing the log now: keep personal data off it, and store keyed hashes or pointers.
  • The data lives in a Kafka topic, not an audit chain: tombstones and compaction, plus a plan for downstream copies.

How Pleach does it

Pleach uses per-subject data keys held in your database, sealed before the chain hashes them. The payload encryption and subject-key code in @pleach/core/crypto is marked experimental, and @pleach/compliance is not on npm yet. See packages and subpath exports for status.

Sealing before hashing

SubjectKeyRegistry from @pleach/core/crypto keeps one data key per (tenantId, subjectId), wrapped under a key-encryption key. The plaintext data key is never written to the database. createAesGcmKekProvider is the reference key-encryption provider, and the docs advise backing it with your KMS in production.

When the event-log writer has a subject-key source, it seals the allowlisted content fields of each payload before computing the payload hash and row hash. The allowlist is SCRUBBABLE_FIELDS from @pleach/core/scrubbers. The hash chain page confirms that with payload encryption on, the hash covers the stored ciphertext.

The erasure request

executeErasureRequest from @pleach/compliance/hashchain destroys the subject's key and seals a signed shred proof, per GDPR right-to-erasure:

import { executeErasureRequest } from "@pleach/compliance/hashchain";

const result = await executeErasureRequest({
  request: {
    tenantId: "tenant-acme",
    subjectId: "user@example.com",
    scope: "all",
    reason: "DSAR-2026-11-08",
    operator: "support-engineer@example.com",
  },
  subjectKeys,          // your SubjectKeyRegistryLike
  attestationKeyStore,  // your KMS-backed AttestationKeyStore
});
// result.shredded === true, result.chainRebuilt === false

chainRebuilt is always false; the helper never touches the chain. A repeat request for a shredded subject succeeds with a fresh attestation. A shred or signer failure throws, with no soft-fail path. The helper doesn't persist the attestation, so store it next to the case. verifyErasureAttestation(attestation, publicKey) checks it later.

scope is an advisory label. The subject has one key, so "messages" makes exactly as much unreadable as "all".

Holds, rotation and schema checks

  • Legal holds, when wired. Build the registry with a holdChecker and a shred is refused unless the checker answers clear, including when it throws. The check and the shred are two statements, so a hold placed between them is missed.
  • New rows after a shred. On a key table with a key-generation column, new rows get the next generation and old rows stay unopenable. On a single-key table, new rows get ERASED_FIELD_SENTINEL in place of each sealed field.
  • A schema that can't erase fails early. If the key columns are declared NOT NULL, getOrCreateDek throws SubjectKeyDdlShapeError before any key is stored. The defensive patterns page explains why it refuses at enable time.

What a shred does not erase

The erasure limits page opens with "A crypto-shred removes one subject's key from one live table. It is not proof of erasure." It lists:

  • Backups and replicas that still hold the wrapped key. The library makes no claim about them and offers no way to prove them erased.
  • Plaintext written without a subject-key source, outside the allowlist, or on a row with no user, session or chat id to key on.
  • Undeclared plaintext copies. The content-pointer verifier, verifyContentPointers, reports a retained copy only at paths you declare in retainedCopyPaths. With none declared, a destroyed key can grade erased while the row still holds the body in plaintext.
  • Session subjects keyed by more than one id. A row with no user is keyed by session:<sessionId>, else session:<chatId>, so erasing a session means shredding every distinct id its rows carry.
  • Copies outside the event log, including host logs, caches, exports and anything sent to a model provider.
  • Unkeyed digests from the opt-in sha256ContentHasher, which can confirm a guessed short body.
  • Retired key generations. A generation roll is not erasure.

One more limit sits in the writer. A row whose seal fails on a transient key failure is held in process memory, 10 seconds by default and 5 minutes at most. If the instance dies, those rows are gone with no signal. Erasure accounting can't count on them.

Approvers have their own path. eraseApprover from @pleach/core/audit/permission-ledger deletes the mapping from an approver reference to the approver's id and leaves every signed row in place. Retention passes and the legal-hold register for the event log are on the WORM page.

Key takeaways

  • Erasure in a hash chain means re-rooting or destroying a key. Re-rooting voids earlier proofs; a shred keeps them.
  • Where the per-subject key lives decides your backup exposure. In a KMS, database backups hold only ciphertext; in your database, they hold the wrapped key.
  • Cloud key destruction is delayed. AWS waits 7 to 30 days and Google Cloud 30 by default, with the key unusable throughout.
  • Encrypted and keyed-hashed data is still personal data. The EDPB says so, and prefers keeping personal data off immutable logs.
  • No mechanism proves erasure of copies it can't see. Track every shred so you can re-apply it to a restored backup.

References

  1. European Data Protection Board. Coordinated Enforcement Action: implementation of the right to erasure by controllers. Adopted 10 February 2026.
  2. European Data Protection Board. Guidelines 02/2025 on processing of personal data through blockchain technologies, version 2.0. Adopted 7 July 2026.
  3. European Union. GDPR Article 17: Right to erasure.
  4. Amazon Web Services. Delete an AWS KMS key.
  5. Amazon Web Services. AWS KMS pricing.
  6. Amazon Web Services. AWS KMS resource quotas.
  7. Google Cloud. Destroy and restore key versions.
  8. HashiCorp. Transit secrets engine API.
  9. Confluent. Kafka log compaction.

Frequently asked

How do you delete personal data from a hash-chained audit log?

You either rewrite the chain or make the data unreadable. Deleting rows and re-rooting the chain removes the data but invalidates every earlier attestation. Crypto-shredding encrypts personal fields under a per-subject key at write time and destroys the key on erasure, so the ciphertext and every hash stay in place. A third option keeps personal data off the log entirely and stores only a pointer or keyed hash there.

Is crypto-shredding enough to satisfy a GDPR erasure request?

Not on its own. The EDPB's blockchain guidelines say encrypted personal data is still personal data, and that after the key is deleted the data stays unintelligible only until the algorithm is broken or the key turns out to have leaked. Copies outside the shredded table also remain: backups that still hold the key, plaintext written before encryption was turned on, exports, caches and anything sent to a model provider. Whether a shred meets a legal duty depends on those copies.

How long does it take to delete an AWS KMS key or a Google Cloud KMS key?

AWS KMS requires a waiting period of 7 to 30 days, 30 by default, and a key pending deletion cannot be used in any cryptographic operation. Google Cloud KMS keeps a key version scheduled for destruction for 30 days by default, and a custom duration can be set when the key is created. After destruction, data encrypted with the key can't be decrypted.

What does the EDPB say about erasure in backups?

Its 2025 coordinated enforcement report on the right to erasure, adopted 10 February 2026, found many controllers had no specific procedure for erasure requests in backups. It says that where modifying a backup is not advisable, organisations should keep track of erasure requests and comply with them on restored systems. It also recommends that controllers verify erasure and be able to demonstrate it.

Do Kafka tombstones erase data from a compacted topic?

A tombstone is a message with a key and a null payload, and compaction eventually removes older records for that key. Kafka keeps tombstones for delete.retention.ms, 24 hours by default, and compaction does not guarantee only one record per key at any one time. Copies already read by consumers are outside the topic and are not affected.

How does Pleach handle erasure in its hash-chained event log?

Pleach crypto-shreds. With a subject-key source wired in, the event-log writer seals the allowlisted content fields of each payload under that subject's data key before hashing, so the chain covers ciphertext. executeErasureRequest from @pleach/compliance/hashchain destroys the subject's key, returns chainRebuilt false and seals a signed shred proof. The erasure limits page lists what a shred does not reach, starting with backups that still hold the wrapped key. The crypto code is experimental.

gdpr erasurecrypto-shreddingright to be forgottenaudit trailhash chainkey management

Related posts