Skip to content

safekeys/encrypted-folder [built] ​

A Safekeys folder is the transport unit: an ordinary directory (or object prefix) holding ciphertext blobs, a manifest, and an agent-readable README with no secrets. Folders can be copied, synced, or passed between agents freely — copying increases no cryptographic exposure, and only a live token plus a reachable sidecar and key authority allow use.

Status: built

Why this exists ​

Secrets need to move the way artefacts move — through git, object stores, artefacts folders, and agent handoffs — without each hop being a new exposure. Making the transport unit an inert ciphertext container means the risky part of the journey (copying) carries no risk at all, and the only sensitive operation (resolve) is gated by a token and a privileged process.

Design decisions ​

ordinary-directory [accepted] ​

Decision: Use an ordinary directory or object prefix rather than a custom container format.

Rationale: Any filesystem, object store, or artefact system can carry it with no adapter, and tooling (diff, sync, tar) works unchanged. The security comes from the contents being ciphertext, not from the container.

aes-gcm-or-chacha [accepted] ​

Decision: Encrypt objects with AES-256-GCM or ChaCha20-Poly1305.

Rationale: Both are AEAD constructions with wide hardware acceleration and mature library support, giving confidentiality and integrity without bespoke crypto.

readme-is-a-feature [accepted] ​

Decision: Ship a README.safekeys in every folder, designed to be model-readable.

Rationale: Agents will encounter folders; a clear, secret-free explanation prevents an agent from attempting to extract values or misusing the folder, and keeps the folder self-describing in handoffs.

manifest-is-metadata-only [accepted] ​

Decision: The manifest may hold a wrapped DEK but never plaintext, an unwrapped DEK, or a KEK, enforced structurally via additionalProperties: false.

Rationale: Envelope-wrapped keys are useless without the KEK, which never leaves the key store, so permitting them lets the folder be a self-contained transport unit while granting nothing on its own. Forbidding everything else means a manifest can be leaked in full without exposing a secret. Schema-level rejection is stronger than a documented rule because it cannot be misconfigured.

Consequences: An implementation that encounters an unwrapped DEK in a manifest must refuse and log a security event, since it indicates a compromised writer. Conformance vectors assert the negative cases.

Date: 2026-09-22

objects-path-constraint [accepted] ​

Decision: Require every object path to match ^objects/[A-Za-z0-9][A-Za-z0-9._-]*.enc$.

Rationale: A path constraint prevents two failure modes at once: an unencrypted file masquerading as ciphertext, and path traversal escaping the folder. Both are structural, so the schema can reject them before any code runs.

Consequences: Folders must keep ciphertext strictly under objects/ with an .enc suffix. Enforced by the path-traversal and unencrypted-object-path conformance vectors.

Date: 2026-09-22

How it works ​

Build an encrypted folder (build-folder) ​

Ciphertext objects plus a manifest are written to a directory or object prefix.

  1. Generate — For each secret, generate a random DEK and encrypt the plaintext into objects/<id>.enc.
  2. Generate — Write manifest.json — object ids, content-type hints, token references, wrapping key ids, and hashes.
  3. Generate — Write README.safekeys describing the folder for humans and agents, containing no secrets.
  4. Observe — The folder is now inert; it can be copied or committed without further protection.

Transport a folder (copy-folder) ​

A folder is moved between environments or agents with no unwrap occurring.

  1. Receive — Destination receives the folder or object prefix verbatim.
  2. Observe — No unwrap is attempted; no key material is required to hold the copy.
  3. Observe — Cryptographic exposure is unchanged by the copy.