Threat Model and Security Claims

  • Status: Living document, written for the 4.0.0 external audit. It describes the feat/v4-product branch including the fixes of the blind review (RFC-0035). It is the maintainers’ model, not an independent assessment.

  • Owner: Security owner.

  • Last updated: 2026-12-01

  • Related: the format and its security considerations (envelope-format.md section 11), the internal audit (RFC-0031), and the audit scope (audit-scope.md).

Every claim below names the mechanism that provides it and the tests that would fail if it stopped holding. A claim without both is not made.

1. Assets

Asset

Where it lives

What must hold

Plaintext

Caller memory; an uncommitted sink while a stream is read.

Confidentiality, integrity.

Data key (DEK) and the keys derived from it

SDK memory; the DEK also exists wrapped in each recipient.

Confidentiality. The DEK reaches a provider only to be wrapped or unwrapped; derived keys never leave the SDK.

Wrapping keys

A key service (AWS KMS, Google Cloud KMS, Azure Key Vault or Managed HSM, Vault Transit); HPKE and custodian private keys held by their owners.

Confidentiality and controlled use. The SDK never holds service keys.

Encryption context

The caller. The envelope stores only a commitment keyed from the DEK.

Integrity binding; confidentiality from envelope holders.

Envelope metadata

The protected header and recipient section.

Integrity. It is visible by design (section 5).

Audit trail

The application’s audit storage.

Integrity and detectable truncation.

Audit signing key

The application.

Confidentiality.

Release artifacts

PyPI and GitHub releases.

Provenance: built from reviewed source by the release workflow.

v3 files and their passwords

The caller, during a migration (RFC-0033).

The plaintext reaches only the new envelope; the password reaches only the key derivation.

v3 keys and key stores

The caller’s v3 directories (RFC-0034).

No key is exported; a private key reaches only the caller’s HPKE provider, and an inventory decrypts nothing.

2. Adversaries

ID

Adversary

Capabilities assumed

A1

Storage or network attacker

Reads, changes, truncates, extends, reorders, replays, and splices envelope bytes, including bytes of other envelopes and tenants, and crafts envelopes from nothing.

A2

Holder of a key the reader does not trust

Controls a wrapping key that the reader’s credentials or provider can also use: a KMS key in another account whose key policy grants the reader decrypt, another tenant’s branch key, or an HPKE identity loaded for another purpose.

A3

Sealer-only service

Holds public keys or wrap-only permission and tries to open.

A4

Recipient insider

Holds one recipient key of an envelope and may act as a malicious sender to its other recipients.

A5

Dishonest custodians

Fewer than the threshold collude, or one releases a wrong share.

A6

Co-tenant

Writes to a shared hierarchical branch-key store.

A7

Local unprivileged user

Races paths in an output directory with links, renames, and reparse points.

A8

Observer

Reads errors, exception text, logs, audit events, metrics, and terminal output.

A9

Slow or failing key service

Not malicious: latency, throttling, errors, partitions.

A10

Supply-chain attacker

Tampers with a dependency, a workflow, or a release artifact.

A11

Future quantum adversary

Records ciphertext today, to decrypt it later.

3. Trust boundaries

ID

Boundary

Rule

B1

Envelope bytes to the codec

Untrusted. Every length is checked against policy limits and hard ceilings before it is read.

B2

Protector to a provider

A configured provider is trusted to wrap and unwrap correctly and to bind its wrap to the protected bytes. It receives the DEK and the protected bytes, never the context, a derived key, or plaintext. Every call carries an operation deadline.

B3

Provider to its cloud SDK

SDK defaults are untrusted: retries and timeouts are set by the provider wherever the SDK allows it per call (F-9, F-10).

B4

Other untrusted input

Branch-key store records, quorum share requests and releases, COSE messages and keys, audit records, the CLI’s configuration and arguments. Each has a strict, bounded parser.

B5

SDK to the filesystem

Other local users may race the output path.

B6

SDK to observers

Errors, audit events, metrics, and CLI output are public.

B7

Source to release

Only the release workflow publishes, from a tag, through OIDC.

B8

v3 file to a legacy adapter

Untrusted, like B1: the format and key derivation are declared, never detected, and every header field, length, and KDF parameter is bounded. Key files and key-store entries are identified by structure, bounded before decryption, read without following links, and quarantined when they cannot be trusted.

4. Claims

Envelopes

ID

Claim

Mechanism

Evidence

C-1

Without a trusted recipient key, an envelope reveals nothing about its plaintext beyond the metadata in section 5.

AES-256-GCM under a 256-bit key that HKDF-SHA-512 derives from a fresh 256-bit DEK and a fresh 256-bit message_id.

tests/unit/test_envelope_vectors.py, tests/unit/test_wycheproof.py, test_every_envelope_is_fresh_and_hides_plaintext_and_context in tests/integration/test_protector.py.

C-2

Any change to an envelope is refused by open and open_stream: a flipped bit, truncation, extension, reordered, duplicated, or dropped records, a moved final flag, or records spliced from another envelope.

STREAM nonces and record AAD with the index, the final flag, and the header digest; the recipient-manifest MAC; the key commitment.

tests/integration/test_exhaustive_tampering.py (every bit of classical and hybrid envelopes, through all three readers), tests/integration/test_protector.py.

C-3

An envelope opens only through a key the reader configured. A recipient that names any other key never reaches a provider. The independent JavaScript reader keeps the same rule.

Trusted keys: recipient keys plus decryption_keys, matched literally or through the reader’s alias resolution, with each key version tried once (spec section 8.2 step 2; RFC-0031 F-1, F-2, F-5). The JavaScript reader’s trustedKeys (RFC-0035 JS-1).

tests/integration/test_trusted_keys.py, tests/provider_packages/test_aws_kms.py, tests/provider_packages/test_gcp_kms_post_quantum.py, interop/javascript/test/review.test.mjs.

C-4

Every recipient that opens an envelope recovers the same DEK, so a sender cannot show different plaintexts to different recipients.

A 256-bit key commitment, compared in constant time before any other derived key is used.

test_key_commitment_rejects_a_recipient_with_a_different_data_key in tests/integration/test_protector.py; the negative vectors.

C-5

An envelope opens only with the context it was sealed with. Envelope holders without the DEK cannot test guesses of the context.

HMAC-SHA-256 commitment keyed from the DEK; the context is never stored. CONTEXT_MISMATCH and AUTHENTICATION_FAILED have the same default message.

test_wrong_context_is_a_distinct_but_equally_quiet_failure in tests/integration/test_protector.py.

C-6

A wrapped DEK cannot be moved into another envelope.

Each provider binds its wrap to the protected bytes: an AWS encryption context, Google Cloud KMS additional authenticated data (and the KEM info for its post-quantum keys), an encrypted digest checked in constant time for Azure, Vault Transit associated_data, HPKE info and AAD.

test_header_binding_is_enforced_by_the_provider in tests/integration/test_protector.py; each provider’s tests; cryptography_suite.providers.conformance.

C-7

A service that holds only public keys can seal but not open.

HPKE recipients registered by public key have no unwrap capability.

test_public_key_sealers_cannot_open in tests/integration/test_hpke_provider.py.

C-8

No unauthenticated plaintext is released. open returns nothing until every record and the end of input verify; open_stream writes only to an uncommitted sink and commits after the final record.

TransactionalSink; atomic publication.

tests/integration/test_file_sink.py, tests/unit/test_atomic_sink.py, tests/unit/test_atomic_failures.py, tests/unit/test_hardening_regressions.py.

C-9

open_range authenticates every byte it returns and its position. A range that reaches the end authenticates the final record, so truncation cannot pass as a short read. Records outside the range are not read and not verified.

Spec section 8.5.

tests/integration/test_open_range.py, tests/integration/test_range_differential.py, tests/integration/test_policy_limits_exact.py.

C-10

rewrap replaces exactly one recipient, keeps every other one (an escrow recipient survives rotation), and leaves every record byte unchanged. A migration replaces the primary recipient whichever recipient unwrapped, so the result does not depend on which key service was available.

Spec section 8.4. Spec section 8.4 rule 3 (RFC-0035 CORE-5).

tests/integration/test_keyring.py, tests/integration/test_keyring_state_machine.py, test_rewrap_preserves_ciphertext_and_is_idempotent, tests/integration/test_escrow_fallback.py.

Untrusted input and availability

ID

Claim

Mechanism

Evidence

C-11

Parsers of untrusted input return the original or raise only their documented errors, within the policy’s limits. Fuzzed or exhaustively mutated: every envelope reader, the COSE message and key decoders, key text and PEM, policy documents, contexts, audit-chain verification, and the CLI. Branch-key records and quorum messages are strictly parsed and tested at each bound.

Lengths checked before reads; hard ceilings (spec section 9); strict CBOR and JSON.

tests/negative/test_untrusted_input_boundaries.py, tests/integration/test_untrusted_input_properties.py (25 times the budget in the weekly run), tests/integration/test_exhaustive_tampering.py, tests/unit/test_codec_boundaries.py, tests/integration/test_policy_limits_exact.py, tests/unit/test_cose_cbor.py, tests/integration/test_hierarchical_keys.py, tests/integration/test_quorum_ceremony.py.

C-12

One envelope causes at most one unwrap call per distinct trusted key version. Provider calls respect a per-operation deadline and a bounded number of attempts. Google Cloud and Azure calls carry the time left as their timeout and make no SDK retries; AWS clients must make one attempt per call. Untried candidates share the time left, so a key service that hangs until the deadline cannot starve an escrow recipient.

Trusted-key selection (F-5); providers/retry.py; F-9, F-10, and F-12. The deadline split of RFC-0035 CORE-1; Azure’s key fetch and unwrap share the time left (PROV-4).

tests/integration/test_trusted_keys.py, tests/unit/test_suite_and_retry.py, tests/provider_packages/test_gcp_kms_client.py, tests/provider_packages/test_azure_keyvault_client.py, tests/provider_packages/test_aws_kms_client.py, tests/integration/test_escrow_fallback.py.

Recovery, tenancy, and audit

ID

Claim

Mechanism

Evidence

C-13

Fewer than the threshold of custodians cannot recover a quorum-protected DEK. A share is bound to its envelope, quorum version, and position. One wrong release cannot block recovery once enough honest releases arrive, and it is identified. No custodian private key leaves its owner. A custodian releases only to the coordinator whose fingerprint they were given out of band, and only a custodian can answer their own request, so an altered or forged message neither collects a share nor overwrites one, and no absent custodian is blamed.

Shamir sharing over GF(2^8); HPKE per share; an integrity tag keyed from the DEK; a search over release combinations; releases re-encrypted to an ephemeral coordinator key. The ceremony fingerprint and per-request tokens with release MACs (RFC-0035 PROV-2, PROV-3).

tests/integration/test_quorum_recipients.py, tests/integration/test_quorum_ceremony.py.

C-14

A branch-key store is untrusted for integrity: a record that is altered, relabelled, or taken from another tenant is refused. The branch-key cache is bounded by age, uses, and size. A record is used only if the configured root key wrapped it.

Branch keys are wrapped by the root key and bound to their branch identifier and version. Root-key pinning on every branch-key unwrap (RFC-0035 PROV-1).

tests/integration/test_hierarchical_keys.py.

C-15

Changing, reordering, or deleting an audit record, and truncating the trail after a checkpoint, are detected by verification.

Canonical JSON records, hash-chained and signed with Ed25519 or ML-DSA-65; checkpoints.

tests/unit/test_audit_chain.py, tests/unit/test_audit_chain_post_quantum.py.

Migration from version 3

ID

Claim

Mechanism

Tests

C-22

A migration publishes an envelope only when the whole v3 input authenticated under its GCM tag and an independent reopening of the new envelope produced the same plaintext. On any failure, cancellation included, nothing is published, no plaintext is written, and the source is unchanged. Nothing is published before a required audit event is recorded, and the permission is checked again at publication.

The legacy tag is checked at the end of the stream; a second thread reopens the envelope through open_stream and compares a keyed digest and length; the transactional sink commits last (RFC-0033). RFC-0035 CORE-2, MIG-4, MIG-6.

tests/integration/test_legacy_migration.py, tests/integration/test_audit_before_publish.py.

C-23

A v3 file is read only as the format and key derivation that the policy and the caller name: nothing is detected, a csf-v2 header is never read as csf-v1, and declared KDF parameters are bounded. The permission ends at the policy’s deadline, and restrict never grants it.

Policy.legacy_formats and migration_deadline; LegacyKdf bounds; strict CSF headers and Base64.

tests/integration/test_legacy_migration.py, tests/unit/test_policy_migration.py, tests/cli/test_cli.py.

C-24

v3 key material is never exported. An inventory decrypts no key and never reads a stored password. An import accepts only an X25519 or P-384 key that the policy permits, an unencrypted private key only under pem-der-unencrypted, bounds the key file’s PBKDF2 work before decrypting, and registers nothing when it fails. Only algorithms that load in bounded time are loaded, so a crafted key file cannot exhaust the CPU.

Structure identified from the PEM label or DER shape; PBES2 parameters read first; the HPKE provider as the only destination (RFC-0034). The algorithm identifier is read first; RSA loads without OpenSSL’s consistency check (RFC-0035 MIG-1).

tests/integration/test_legacy_keys.py, tests/cli/test_cli.py.

Observability, local system, and interfaces

ID

Claim

Mechanism

Evidence

C-16

Errors, reprs, audit events, and metrics carry no key material, plaintext, or context values. Error details are allowlisted and bounded.

Typed errors with redaction (RFC-0004); secret-free audit events.

tests/unit/test_security_contracts.py, tests/unit/test_hardening_regressions.py, test_audit_events_are_complete_and_secret_free, tests/provider_packages/test_opentelemetry.py.

C-17

Output files are published atomically, without replacing an existing file. No path component is followed through a symbolic link or reparse point. Temporaries are mode 0600 from creation. A failure leaves nothing at the destination, and the input is never overwritten. On Windows, no held parent directory can be renamed while the sink holds it. The status file is published the same way.

Directory-descriptor-relative operations with O_NOFOLLOW, O_EXCL, and no-replace links; Windows reparse points rejected. Parent handles opened without FILE_SHARE_DELETE (RFC-0035 SYS-1, SYS-2).

tests/negative/test_atomic_paths.py, tests/unit/test_filesystem_posix.py, tests/unit/test_filesystem_windows.py, tests/integration/test_atomic_concurrency.py, test_held_parent_directories_cannot_be_swapped.

C-18

The CLI reads secrets only from a file descriptor or stdin, never from arguments or the environment, and escapes non-printing characters of unauthenticated envelope text before printing it. JSON status escapes every non-ASCII character, so control and format characters reach a terminal only as escapes.

RFC-0015; RFC-0031 F-6. ASCII JSON (RFC-0035 SYS-3, SYS-5).

tests/cli/test_cli.py, tests/cli/test_cli_config.py.

C-19

Hybrid recipients stay confidential while either ML-KEM or the classical component is unbroken.

HPKE with X-Wing (ML-KEM-768 + X25519) or ML-KEM-1024 + P-384 (RFC-0017).

tests/integration/test_hpke_post_quantum.py, the ML-KEM cases in tests/unit/test_wycheproof.py.

C-20

COSE-HPKE messages are produced and read exactly as draft-ietf-cose-hpke-27 and RFC 9180 define them.

RFC-0030.

tests/unit/test_cose_hpke.py (CFRG vectors), tests/unit/test_cose.py (the draft’s examples), differential tests against pyca/cryptography’s HPKE.

C-21

A release is built once from a v* tag by the release workflow, after verification and approval of the protected pypi environment, then attested and published through Trusted Publishing. The tagged commit must be on main; the build installs only hashed tools, and its digests are checked before attestation and upload, so no later step can change what is published.

Actions pinned to full commit SHAs, per-job permissions, OIDC, build provenance and PEP 740 attestations, a reproducible build. requirements-build.txt; digest outputs (RFC-0035 SC-1, SC-3); cross-platform reproducibility (SC-2).

.github/workflows/release.yml, .github/workflows/reproducibility.yml, tools/reproducible_build.py, RFC-0031’s supply-chain review.

5. Not claimed

These are outside the model. Each is a deliberate limit, documented where users will read it.

  • Sender authentication. Envelopes and COSE-HPKE messages authenticate the recipient, not the sender: anyone who can wrap to a recipient key can seal to it. Sign the envelope when its origin matters.

  • Non-repudiation among recipients. Any recipient can unwrap the DEK and then seal new data that the other recipients accept (spec section 11).

  • A malicious provider or key service. A configured provider is trusted to use the key it names and to bind its wrap (B2).

  • Metadata confidentiality. Provider, key identifier and version, recipient count, chunk size, one-shot plaintext length, record count, and an optional creation time are visible.

  • Records outside a range. open_range does not verify them (C-9); use open to verify a whole envelope.

  • Memory hygiene. Python cannot guarantee that secrets are erased. The SDK overwrites the buffers it owns, as a best effort.

  • Side channels beyond those named. Commitment, MAC, and binding comparisons are constant time; pyca/cryptography provides the primitives. The quorum’s GF(2^8) arithmetic uses table lookups and runs only when sealing and recovering.

  • A compromised host or a compromised caller. Code in the same process can read every secret the SDK holds.

  • Availability of the key service (A9). The SDK bounds its own waiting and retries; it cannot make an unavailable service available. Escrow and quorum recipients exist for that disaster.

  • Classical recipients against A11. Only hybrid recipients resist a future quantum adversary.

  • FIPS validation. Policy.fips() restricts algorithms; no validation or certification is claimed.

  • v3 keys exposed before migration. A key that 3.0.0 stored with its password beside it (RFC-0034 K-1), or stored unencrypted, may already be known to anyone who could read the directory. The inventory reports it; only replacing the key ends the exposure.

  • The strength of v3 data. A migrated file is no stronger than its v3 password and key derivation were, and a csf-v1 header was never authenticated (the receipt records a warning). Migration ends the exposure going forward; it cannot undo an earlier one.

6. Residual risks

RFC-0031 and RFC-0035 list them with their mitigations, and the risk register gives each an owner and a review date. In short:

  • Alias re-pointing is honoured for up to five minutes of cached resolution.

  • boto3 and hvac set timeouts per client, so the deadline cannot cut an AWS or Vault call short; their READMEs set client timeouts inside it.

  • No independent audit has been completed; audit-scope.md proposes one. The blind review of RFC-0035 is internal.

  • RFC-0035 adds: opening costs time linear in an envelope’s record count, bounded by the policy’s plaintext limits; Cloud KMS does not enforce a version pin for symmetric keys; a party that can both wrap under a hierarchical root key and write to its store can plant a branch key; two processes that overwrite the same file at the same moment can both succeed (SYS-7; within one process the second fails); and the release relies on repository settings an owner must apply.