Rotating a Transit Key Does Not Migrate the Data
10 min read
Listen to this article
Matthew · Amazon Polly
A key can rotate successfully while every stored object remains encrypted under an older version. A migration worker can rewrite most records while one stale reader still depends on the old format. A key policy can then turn off decryption of that older version, turning an apparently completed security change into an application outage.
These are separate transitions. Vault Transit provides cryptographic operations and versioned keys; the application remains responsible for its data and for the process that moves stored ciphertext between versions.
The platform problem is therefore a data migration with cryptographic consequences. Treating key rotation as a complete migration hides the work that must happen outside Vault.
This historical study uses the Transit interfaces captured in Vault 1.18.0, released before the May 2026 editorial cutoff. It concerns the basic Transit engine and its versioned ciphertext operations, not later managed-key integrations or an asserted HCP service rollout. The archived version is a documentation baseline, not production upgrade advice. Release record.
Three operations with different effects
A key rotation creates another version of a named key. Newly encrypted data can use the newer version, while existing ciphertext still identifies the earlier key version. Transit returns ciphertext to the application rather than acting as the application's primary data store. Archived Transit concepts.
Rewrap performs a different job. It takes existing ciphertext and returns ciphertext protected by the target key version without returning the underlying plaintext to the caller. The application must still save that returned value in its own storage system.
Changing the minimum permitted decryption version is a third operation. It changes which older ciphertext versions the key will accept for decryption. It does not search the application's database or transform objects that remain under an old version. Archived Transit API.
A complete migration sequence must therefore consider writers, stored records, and readers. Key rotation prepares a new version. Application migration changes stored representations. Reader and recovery verification establish whether restricting older versions is safe.
Rewrap authority is narrower than decrypt authority
A migration process can be designed to allow rewrapping a particular key without decrypting its data. That reduces the plaintext exposure of the migration service. It is still a powerful operation: the service can read stored ciphertext and may have write authority over production records.
The resulting trust boundary is easy to understate. Keeping plaintext out of the worker does not make arbitrary database writes safe. A compromised worker could replace records, erase ciphertext, or mix up object identifiers even if Transit never returns plaintext.
The storage update therefore needs the same controls as another sensitive data migration: scoped access, stable object identity, concurrency protection, validation and a recovery plan. Encryption does not eliminate those responsibilities.
An AI assistant can help explain migration progress or identify anomalous batches from sanitized metadata. It does not need Transit decrypt permission or access to full ciphertext collections merely to summarize the work. The execution worker should own the bounded transformation and persistence contract.
The optimistic update boundary
Consider an object with an application revision and ciphertext at key version one. A worker reads it and obtains a version-two replacement. While the remote rewrap operation runs, the application writes new data to the same object.
If the worker stores its result without question, it overwrites the application's newer write with a re-encryption of the older content. The cryptographic operation may be correct while the data migration is wrong.
The update must compare the record revision observed at read time with the revision at commit time. If they differ, the worker discards or records its unused transformation result and retries from a fresh read. A replacement ciphertext cannot justify ignoring a revised application.
The record revision should be independent of the ciphertext key-version prefix. Multiple legitimate application writes can use the same key version. A version-two string alone says nothing about whether it represents the latest business value.

Proposed workflow: rewrap transforms ciphertext, a conditional write protects application updates, and a separate review governs old-version retirement.
A complete model of conditional persistence
The following standard-library example models the storage commit rule. It does not implement encryption or call Transit. Ciphertext strings are identifiers in synthetic test data; successful checks make no claim about cryptographic security.
from dataclasses import dataclass
@dataclass(frozen=True)
class Record:
revision: int
key_version: int
ciphertext: str
def commit_rewrap(current, observed_revision, replacement, target_version):
if current.revision != observed_revision:
return current, "CONFLICT"
if target_version <= 0:
return current, "INVALID_TARGET"
if current.key_version > target_version:
return current, "NEWER_VERSION"
if replacement.key_version != target_version or not replacement.ciphertext:
return current, "INVALID_RESULT"
if current.key_version == target_version:
return current, "ALREADY_CURRENT"
updated = Record(
revision=current.revision + 1,
key_version=target_version,
ciphertext=replacement.ciphertext,
)
return updated, "UPDATED"
old = Record(7, 1, "ciphertext-a")
candidate = Record(7, 2, "ciphertext-b")
updated, status = commit_rewrap(old, 7, candidate, 2)
assert status == "UPDATED" and updated.revision == 8
concurrent = Record(8, 2, "application-write")
assert commit_rewrap(concurrent, 7, candidate, 2)[1] == "CONFLICT"
print("Conditional persistence examples passed")
The replacement's revision is not trusted as a storage revision. The function creates the next revision only after checking the current record. In an actual database, that check and write must be atomic. Recreating them as separate client-side read and write operations would reintroduce the race.
The result ALREADY_CURRENT means that this simplified migration no longer needs to rewrite the record. It does not prove that the application value is correct, that the ciphertext can be decrypted or that every backup has migrated. Those questions require different evidence.
The NEWER_VERSION branch prevents a delayed worker from forcing a record backward to its own older target. A real migration controller should similarly pin its target and recognize when another approved migration has advanced the system.
Rotation needs a writer contract
A migration over existing records cannot converge if writers keep producing the version being retired. Before declaring completion, the platform needs to understand which key version new writes use and whether any client explicitly requests an older permitted version.
A practical rollout starts by changing the writer contract, then migrates the backlog, then verifies the remaining population. The exact ordering depends on application compatibility, but it must account for concurrent writes rather than assuming a frozen dataset.
The writer path also needs to retain enough metadata to support validation. A record identifier, revision and cryptographic key reference are often more useful for migration control than a log containing the full ciphertext. Avoiding plaintext does not make unlimited ciphertext logging operationally necessary.
A data store containing several Transit keys needs an explicit mapping. Guessing the key from an object type or a filename can fail when historical records used another key. The key reference belongs to the data envelope or another reliably maintained schema.
That envelope is application design, not a built-in Transit database schema. It must be reviewed for integrity and access control alongside the encrypted field.
Old-version retirement is a separate decision
A count of migrated live records is necessary but incomplete. Backups, snapshots, delayed messages, exported archives and replicas may retain older ciphertext. A rollback release may also expect the old representation or use a different key reference.
Before increasing a minimum decryption version, the platform needs an inventory of those consumers and recovery paths. The question is not merely whether the primary table contains version-one ciphertext today. It is whether an operationally legitimate path can still require it tomorrow.
The Transit API's version controls make that decision consequential. Raising a decryption threshold can prevent access to older ciphertext; lowering a threshold can re-enable access where the retained key material permits it. This is distinct from irreversible key deletion or destructive trimming, which needs a separate assessment. The article does not propose deleting key material.
A retirement checklist can be precise without claiming perfect knowledge: current data population checked, writer behavior verified, restore rehearsal completed, delayed-work window covered and rollback implications accepted. Missing evidence should keep retirement pending, not be translated into a fictional zero count.
Rewrap failure is not data loss by itself
If a rewrap request fails before persistence, the original ciphertext should remain authoritative. A migration worker that clears the old value before receiving and committing the replacement creates a failure mode that Transit did not require.
A lost response creates another possibility: Vault may have produced a replacement, but the worker has not saved it. The next attempt can begin from the still-current stored ciphertext, while the controller records that the earlier remote outcome was uncertain. The application database's revision remains the decisive boundary for whether anything changed.
Batch processing adds accounting concerns. A partially successful batch should retain per-record outcomes. Reporting one success for the batch can hide skipped records; retrying every record without checking revisions can create unnecessary churn and misleading counts.
A useful progress measure is the number of current records verified at the target version, with separate counts for conflicts, remote failures and unexamined partitions. “Requests sent” measures activity, not migration completion.
Key configuration changes deserve different privileges
The migration worker needs to transform eligible data and persist it conditionally. It does not necessarily need permission to rotate keys, change minimum versions, enable export or delete a key.
The archived API exposes exportability and plaintext-backup settings independently, including irreversible enablement constraints. Those settings change key handling and should not be casually bundled into the policy used by a rewrap worker. Key configuration reference.
A narrow ACL policy can separate the rewrap path from administrative paths. The application decrypt identity and the retirement operator should likewise remain distinguishable. The objective is not the largest possible number of roles; it is a clear account of which identity can expose plaintext, alter cryptographic policy or rewrite stored data.
The worker's database privileges deserve equal attention. A Transit-only review could approve a narrowly scoped cryptographic identity while overlooking a database account able to replace every tenant's record. The data-plane authority can dominate the risk even when the key-plane policy looks careful.
Validate the migration, not a toy cipher
The accompanying synthetic checks cover stale revisions, empty transformation results, wrong target versions, repeated work, a newer stored version and successful revision advancement. They validate the original commit model. They do not test AES, Vault's cryptographic implementation or a live database transaction.
An integration exercise should encrypt known nonsensitive fixtures, rotate the named key, rewrap them and confirm that the application still reads the same content. It should also race an application update against the migration worker and verify that conditional persistence refuses the stale result.
A restore rehearsal is particularly informative. Restoring a backup containing older ciphertext after a threshold change reveals whether the recovery design actually accounts for key history. A successful live-data migration cannot stand in for that test.
Migration scheduling should also account for application load. A large rewrite can consume database write capacity, invalidate caches or increase replication lag even when the cryptographic service remains healthy. Batch size and concurrency therefore belong to the migration controller's operating envelope. They should be adjusted from observed capacity, not from an assumed relationship between key size and workload throughput.
The controller needs a stop condition that leaves data usable. Pausing after a batch should retain a mixture of supported ciphertext versions, with readers capable of handling that mixture. A design that requires every record to change simultaneously creates a much stronger coordination problem than the rewrap interface itself demands.
Finally, progress records need a snapshot or reconciliation strategy. A simple scan can miss objects inserted behind its cursor or revisit objects whose application revision changed. A second verification pass, combined with a writer contract that no longer produces the old version, gives retirement review a more meaningful evidence set.
Transit reduces the amount of cryptographic implementation an application must own. It does not remove ownership of data movement. A reliable platform treats rotation, transformation, persistence and retirement as separate operations, with evidence connecting them. That separation is what makes key evolution an explainable engineering change instead of an opaque security ceremony.