# External Audit Scope - **Status:** Proposal for the independent audit that RFC-0010 makes a release gate for 4.0.0. No audit has been commissioned. - **Owner:** Security owner. - **Last updated:** 2026-11-30 This document tells an audit team what to review, in what order, what the maintainers want answered, and what evidence already exists. The claims under review are in [threat-model.md](threat-model.md). ## 1. Target The audit runs against one tagged commit, cut when the envelope format freezes for RC1. Findings are fixed on later commits, and each fix gets a regression test that fails on the audited commit, as RFC-0031 did. Sizes are non-blank lines at the time of writing. ### Tier 1: the cryptographic core (about 2,900 lines) | Component | Lines | Review focus | | --- | ---: | --- | | `envelope/codec.py` | 561 | Parsing of untrusted envelopes; every length before it is read; canonical CBOR. | | `envelope/suites.py` | 139 | Suite 1: key schedule, commitments, MAC, STREAM records. | | `_internal/cbor.py` | 174 | The strict deterministic CBOR codec. | | `context.py` | 102 | Canonical, NFC-normalized context encoding. | | `protector.py` | 1,261 | Seal, open, range open, rewrap; trusted-key selection; retries and deadlines; DEK lifetime. | | `providers/hpke.py` | 565 | HPKE recipients, classical and hybrid post-quantum. | | `providers/retry.py`, `_internal/secrets.py` | 121 | Retry classification and deadlines; secret buffers. | | [`spec/envelope-format.md`](../spec/envelope-format.md) and its vectors | | Is the format as specified sound, and does the code match it? | ### Tier 2: recipients, key services, and other formats (about 5,700 lines) | Component | Lines | Review focus | | --- | ---: | --- | | `providers/quorum.py` | 785 | Share binding, robust reconstruction, the distributed ceremony and its ephemeral key, blame. | | `providers/hierarchical.py` | 429 | Branch-key binding, store integrity, cache bounds and concurrency. | | AWS, Google Cloud, Azure, and Vault provider packages | 1,431 | Header binding, key and version selection (F-1, F-2), alias resolution, error mapping, SDK retries and timeouts. | | `audit/chain.py` | 367 | Canonical records, hash chain, signatures, checkpoints. | | `cose/` | 1,123 | COSE-HPKE, the HPKE key schedule assembled from primitives, COSE_Key validation, the COSE CBOR decoder. | | `legacy/`, `migration.py` | 1,580 | Parsing of untrusted v3 files, key files, and key stores; KDF and PBKDF2 bounds; link-safe reads; the verifying transaction and its thread; nothing published or registered on failure (RFC-0033, RFC-0034). | ### Tier 3: system interfaces (about 4,600 lines) | Component | Lines | Review focus | | --- | ---: | --- | | `_internal/filesystem.py`, `streaming/atomic.py`, `streaming/files.py` | 2,138 | Races with links, renames, and reparse points on Linux, macOS, and Windows; atomic, no-replace publication. | | `cli/main.py`, `cli/config.py` | 855 | Secret input, configuration parsing, terminal output. | | `policy.py`, `errors.py` | 659 | Policy limits and monotonic restriction; error redaction. | | `interop/javascript/src/` | 899 | The independent reader and sealer: constant-time comparisons and key trust. | | `.github/workflows/` | | Release integrity, permissions, injection. | ## 2. Questions for the auditors 1. Is suite 1 sound as specified? In particular, is authenticating the recipient section with a MAC keyed from the DEK sufficient, given that any recipient can rewrite it (an accepted limit, spec section 11)? 2. Is there any path on which the envelope, rather than the reader, chooses the key that unwraps it (spec section 8.2 step 2)? Consider alias resolution and its five-minute cache, version pinning, and each provider's own key selection. 3. Can `open_range` return a byte that is unauthenticated or at the wrong position, or can truncation pass as a short read (spec section 8.5)? 4. Is each provider's header binding sufficient, and is it checked where the key service cannot check it (Azure's encrypted digest)? 5. Can a coalition below the threshold, or a coordinator, learn anything about a quorum-protected key? Can one custodian block recovery or escape blame? 6. Can a co-tenant with write access to a branch-key store make another tenant's envelopes open under a key it chose? 7. Does the HPKE implementation in `cose/_hpke.py` match RFC 9180 for every suite, including the PSK mode? 8. Can a local user redirect, replace, or read output through the filesystem sink? 9. Do error codes, error timing, or provider-call patterns give an attacker a useful oracle? 10. Can a pull request, a dependency, or a compromised maintainer token publish a release that the release workflow did not build from a tag? 11. Can a crafted v3 file make a migration publish an envelope whose plaintext differs from the authenticated v3 plaintext, write plaintext anywhere, or exhaust memory or time before it is refused? Can a crafted key file or key-store entry be imported as something it is not, make an inventory follow a link, or leak a stored password? ## 3. Evidence the maintainers provide | Evidence | Where | | --- | --- | | Normative specification and positive and negative vectors | `docs/v4/spec/` | | Design decisions | RFC-0011 to RFC-0035 in `docs/v4/rfcs/` | | Second internal review: a blind adversarial review, its 36 findings, fixes, and residual risks; to read after your own review | [RFC-0035](../rfcs/RFC-0035-blind-review.md) | | Threat model and claims, each linked to its tests | [threat-model.md](threat-model.md) | | Internal audit: findings F-1 to F-12, their fixes, and residual risks | [RFC-0031](../rfcs/RFC-0031-security-audit.md) | | Mutation testing: 425 mutants in the core and 75 in the provider distributions, every survivor explained | RFC-0031; the harness is available on request | | 100% line and branch coverage, combined across platforms | `fail_under = 100` in `pyproject.toml`; `.github/workflows/filesystem-boundary.yml` | | Fuzzing of every untrusted-input boundary, 25 times the budget weekly | `tests/integration/test_untrusted_input_properties.py`, `.github/workflows/fuzz.yml` | | Exhaustive bit-flip and truncation tests | `tests/integration/test_exhaustive_tampering.py` | | Project Wycheproof and CFRG HPKE vectors, pinned and checksummed | `tests/vectors/` | | A 248-case conformance corpus and an independent JavaScript implementation | `conformance/`, `interop/javascript/` | | Real-SDK tests for AWS, Google Cloud, Azure, and Vault | `tests/provider_packages/test_aws_kms_client.py`, `test_gcp_kms_client.py`, `test_azure_keyvault_client.py`, `test_hashicorp_vault.py` | | Reproducible build | `tools/reproducible_build.py`, `.github/workflows/reproducibility.yml` | | Runnable examples | `examples/` | ## 4. Out of scope - pyca/cryptography, OpenSSL, and the cloud SDKs, except how this SDK calls them. - The key services themselves. - The 3.x toolkit, which v4 does not contain (README, "Historical v3 code"). - The documentation site. ## 5. Process - Findings are reported through the private channel in SECURITY.md and handled under its 90-day coordinated-disclosure target. - Each finding is fixed with a regression test that fails on the audited commit, and recorded in an RFC as RFC-0031 records the internal audit. - The final report is published with the maintainers' response, before 4.0.0 is released.