Incident runbooks¶
These runbooks cover the incidents an envelope-encryption deployment must be
ready for. Each starts with the signal, then gives containment, recovery, and
what to verify. Rehearse them before you need them: RFC-0010 requires them
exercised before a release candidate is promoted. The project exercises
their steps on every change, with in-memory key services standing in for
real ones (tests/integration/test_runbooks.py); rehearse them with your
own key services, logs, and people as well.
Two facts shape every runbook:
Rewrap changes who can unwrap, not the data key.
rewrapwraps the same data key for a new recipient. It stops a compromised key from opening envelopes in the future, but anyone who already unwrapped an envelope’s data key, and holds a copy of the envelope, can still read that copy. Data that must stay confidential against such an attacker is re-encrypted: opened and sealed again, which creates a new data key.Rewrap replaces one recipient. Name it with
replace=(or--replace-keyon the command line) whenever it is not the primary key. Without it, the recipient with the destination’s name is replaced, or else the first recipient, the primary key, whichever recipient unwrapped.
A key-service key may be compromised¶
Signal. Unexpected Decrypt or Encrypt calls in the key service’s
audit log, leaked credentials of a role that can use the key, or a key
policy changed without review.
Contain.
Revoke the credentials or grants involved, and restrict the key’s policy to the identities that must keep using it during recovery: the services, and the rewrap job.
Find what was exposed. With AWS KMS, every call carries the encryption context
cryptography-suite:binding, a digest of one envelope’s header, and CloudTrail records it: compute the same context withenvelope_binding_contextfromcryptography_suite_aws_kmsover your stored envelopes to find the ones each suspicious call opened. It reads only an envelope’s first bytes, up to the end of its header, and does not change when an envelope is rewrapped. The other services log the key version and the caller.
Recover.
Create a new key. Make it the primary key of every
Protector, and list the compromised key indecryption_keysso existing envelopes stay readable.Rewrap every envelope from the compromised key to the new key, with a job that runs under the restricted identity.
rewrapis idempotent, so the job can be rerun until it finds nothing to move.Re-encrypt the envelopes found in step 2 of containment, if their confidentiality must hold against whoever made those calls.
Remove the compromised key from
decryption_keys, then disable it and schedule its deletion.
Verify. inspect on a sample of envelopes shows the new key; opening
with a Protector that no longer trusts the old key succeeds.
The escrow key may be compromised¶
Signal. The escrow private key, or a copy of it, is missing or was handled outside its procedure.
The escrow key opens every envelope it is a recipient of, so treat this as a compromise of all of them.
Generate a new escrow key pair offline, register its public key, and make it the escrow recipient of every
Protector.Rewrap every envelope to it, naming the recipient to replace:
protector.rewrap( envelope, destination_key=KeyRef(escrow.provider_id, "break-glass-2028"), replace=KeyRef(escrow.provider_id, "break-glass"), )
The escrow recipient is replaced and the primary recipient is kept. Envelopes that already hold the new escrow key lose the old one, and envelopes already rewrapped are returned unchanged, so the job can be rerun.
Re-encrypt envelopes whose copies the holder of the old key may have.
Destroy every copy of the old escrow key once the rewrap is complete.
Verify. On an isolated machine, open a sample with only the new escrow key.
A quorum custodian leaves or loses a key¶
Fewer than the threshold of custodians learn nothing, so one lost or departed custodian is not a compromise. Restore the margin before another one is lost:
Add a new quorum version without that custodian, with a new one if needed:
add_quorumwith the same name.Rewrap every envelope to the new version. The name matches, so the quorum recipient is replaced and every other recipient kept.
If the threshold of custodians may have colluded, treat it as the escrow compromise above.
Authentication failures rise¶
Signal. AUTHENTICATION_FAILED or CONTEXT_MISMATCH above its usual
level.
Do not retry. These failures are permanent for the same input.
Separate the causes.
CONTEXT_MISMATCHmeans the caller supplies a different context: a deployment or routing error far more often than an attack.AUTHENTICATION_FAILEDmeans the bytes changed, or no trusted key opens them correctly.Check storage and transport first: truncated uploads, a proxy that rewrites bodies, a text-mode file transfer, or a mix-up of envelopes and their records. Such damage often fails before authentication, as
FORMAT_INVALID(the framing no longer adds up, as after truncation) orTRAILING_DATA(bytes appended), so a rise of those codes at the same time points the same way.inspectthe failing envelopes. It reads them without keys and is safe on hostile input; recipients that name keys you do not use point to envelopes that are not yours.Keep the failing envelopes and the audit trail as evidence, and verify the trail.
The audit trail fails verification¶
Signal. verify_audit_chain raises AuditChainError.
|
Means |
|---|---|
|
A line is not a valid record. |
|
A record belongs to another chain. |
|
A record is missing or inserted. |
|
A record does not follow the one before it. |
|
A record was edited. |
|
A record was not signed by this key. |
|
The trail does not end at the published checkpoint: records were removed from the end, or the checkpoint is not this trail’s. |
Preserve the trail and the storage’s own access logs before anything else writes to them.
Verify the trail up to the last published checkpoint that still matches: pass the lines up to that checkpoint’s
sequence, with the checkpoint asexpected_end. Everything up to it is intact.Investigate who could write to the trail’s storage. If the trail verifies record by record but no longer ends at a published checkpoint, or a published checkpoint names records that verify with different content, someone re-signed records: the signing key itself is compromised. Rotate it, and start a new chain.
A vulnerability affects your version¶
Read the advisory: it states the affected versions, the fixed version, and whether envelopes written by affected versions need action.
Upgrade, and run
cryptosuite doctoron the new build.If the advisory says so, rewrap or re-encrypt the affected envelopes; the advisory names which, by format version, suite, or provider.
Report suspected vulnerabilities privately, as described in SECURITY.md.