---
title: "Security lesson 5: Keys an auditor can account for"
description: "Account for the organization's keys as an auditor does - who may use each and how, every change a request in the log, a key that is disabled or due for deletion used by no one, and signatures checked with a key that never leaves the vault."
---

> Documentation Index
> Fetch the complete documentation index at: https://docs.forge.workreef.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Security lesson 5: Keys an auditor can account for

**Time:** 20 minutes. **Track:** [security and compliance](https://docs.forge.workreef.dev/learn/#security-and-compliance). **Before this:** [security lesson 1](https://docs.forge.workreef.dev/learn/security/the-record/).

By the end of this lesson you will be able to:

- list the organization's keys, each with who may use it and how;
- say whose word a grant of a key takes effect on, and when it waits for someone other than its asker;
- show that a disabled key, or one due for deletion, is used by no one, and that each such change is a request in the log;
- check a post-quantum signature with a key that never leaves the forge.

## The keys, and who may use them

The organization's keys live in the forge's vault and are used through it: no person, agent or program outside the forge ever holds one. An auditor's first question is which keys there are, and who may use each. Start a forge, and make two, one to encrypt the app's secrets and one, post-quantum, to sign releases:

```console server
$ af-server --dev
...
```

```console check
$ source ~/af-dev/dev/env
$ af kms create app-secrets --use-person dev@localhost --reason "the app's secrets"
done: it took effect at once, on your word as an administrator
$ af kms create releases --spec ml-dsa-65 --use-person dev@localhost --reason "signing releases"
done: it took effect at once, on your word as an administrator
$ af kms list
app-secrets (symmetric, version 1, enabled): person dev@localhost may use
releases (ml-dsa-65, version 1, enabled): person dev@localhost may use
```

Each key names its kind, the version that encrypts or signs now, its state, and each person or team that may use it: to **use** it is to encrypt and decrypt, or sign and verify; to **seal** with it is only to encrypt, or only to verify.

## A grant, and on whose word

Give the payments team leave to seal with the app's key, so their service can encrypt card tokens it may never decrypt:

```console check
$ af kms grant app-secrets --team payments --may seal --reason "payments seal card tokens"
done: it took effect at once, on your word as an administrator
$ af requests
$ af kms list
app-secrets (symmetric, version 1, enabled): person dev@localhost may use, team payments may seal
releases (ml-dsa-65, version 1, enabled): person dev@localhost may use
```

Making the keys and granting one took effect at once, on your word as an administrator: an administrator's word is enough, and every report lists each change so made as an exception, approved by no one else, for an auditor to account for. Anyone else's grant waits. A developer who asks to use a key is approved by someone who holds it at least as the grant gives, or by an administrator, never by the developer or an agent of theirs, and `af requests` shows what waits, in words, with who asked. A forge that runs with `af-server --two-administrators` holds an administrator's requests too, until another administrator approves them: separation of duties for the administrators themselves.

## Disabled, or due for deletion: used by no one

Encrypt a secret, then disable the key, as you would on a suspected exposure. Nothing decrypts with it while it is disabled, and enabling it again brings everything it sealed back:

```console check
$ printf 'hunter2' | af kms encrypt app-secrets --context env=prod > token.enc
$ af kms disable app-secrets --reason "suspected exposure"
done: it took effect at once, on your word as an administrator
$ af kms decrypt --context env=prod < token.enc
Error: InvalidState: key "app-secrets" is disabled: only an enabled key is used
[1]
$ af kms enable app-secrets --reason "cleared"
done: it took effect at once, on your word as an administrator
$ af kms decrypt --context env=prod < token.enc
hunter2
```

A key is deleted only after a waiting period, from 7 to 30 days, in which it is used by no one and the deletion can be called off. A deletion called off leaves the key disabled, as AWS KMS does, so it is used again only once someone enables it on purpose:

```console check
$ af kms schedule-deletion app-secrets --days 7 --reason "retiring the key"
done: it took effect at once, on your word as an administrator
$ af kms list
app-secrets (symmetric, version 1, pending deletion until 2026-12-02T17:21:25.647Z): person dev@localhost may use, team payments may seal
releases (ml-dsa-65, version 1, enabled): person dev@localhost may use
$ af kms cancel-deletion app-secrets --reason "still needed"
done: it took effect at once, on your word as an administrator
$ af kms list
app-secrets (symmetric, version 1, disabled): person dev@localhost may use, team payments may seal
releases (ml-dsa-65, version 1, enabled): person dev@localhost may use
$ af kms enable app-secrets --reason "still needed"
done: it took effect at once, on your word as an administrator
```

Every one of these changes was a request, recorded in the organization's log with the authority it took effect on, so the period's [compliance report](https://docs.forge.workreef.dev/concepts/compliance-reports/) accounts for each, and lists each an administrator made on their own word as an exception.

## Keys that never leave the vault

A signing key signs inside the forge. Its public key is all that ever leaves, so anyone can check a signature against it, and only the forge can make one:

```console check
$ printf 'v1.0' | af kms sign releases > v1.sig
$ printf 'v1.0' | af kms verify releases --signature "$(cat v1.sig)"
valid
$ af kms public-key releases > releases.pem
$ sed -n '1p;$p' releases.pem
-----BEGIN PUBLIC KEY-----
-----END PUBLIC KEY-----
```

`releases` is ML-DSA-65, the post-quantum signature of FIPS 204, so its signatures stay sound against an attacker with a quantum computer. The forge seals its own recovery shares with X-Wing, a post-quantum key exchange joined to a classical one, for the same reason: a share recorded today stays secret tomorrow.

To encrypt more than a secret, an application asks for a **data key**: a fresh key, given once in the clear to encrypt with locally, and once sealed under the organization's key, to keep beside what it encrypts. The lab cuts the keys themselves short, as they differ on every run:

```console check
$ af kms data-key app-secrets --context env=prod | sed 's/[A-Za-z0-9+/]\{16,\}=*/…/g'
{"ciphertext":"…","key":"app-secrets","plaintext":"…","version":1}
```

## Exercises

1. Check the first release's signature against another release, `v1.1`. What does the forge answer, and why does that matter to an auditor?

   ```console check
   $ printf 'v1.1' | af kms verify releases --signature "$(cat v1.sig)"
   Error: the signature does not verify
   [1]
   ```

   A signature covers exactly what was signed: a changed release fails, so a signature an auditor checks shows the release is the one that was signed.

2. Disable `releases`, and try to sign with it.

   ```console check
   $ af kms disable releases --reason "the exercise"
   done: it took effect at once, on your word as an administrator
   $ printf 'v1.2' | af kms sign releases
   Error: InvalidState: key "releases" is disabled: only an enabled key is used
   [1]
   ```

## Check your understanding

<details>
<summary>Your grant took effect at once. When would it have waited?</summary>

When someone who is no administrator asked for it: it waits until someone who holds the key at least as the grant gives, or an administrator, approves it, never the asker or an agent of theirs. And on a forge that requires a second administrator (`af-server --two-administrators`), an administrator's own request waits for another administrator. Taken on an administrator's word, a change is approved by no one else, and every report lists it as an exception.

</details>

<details>
<summary>A key is due for deletion. Can anyone still decrypt with it?</summary>

No. Through its waiting period it is used by no one, as a disabled key is; the period is there so the deletion can be called off, and calling it off leaves the key disabled until someone enables it.

</details>

<details>

<summary>

Where is the private half of `releases`?

</summary>

In the forge's vault, sealed under the cluster's key. It signs there; only its public key leaves, so a signature can be checked by anyone and made by no one but the forge.

</details>

## Next

The [curriculum map](https://docs.forge.workreef.dev/learn/) lists the other lessons. [Keys and the vault](https://docs.forge.workreef.dev/concepts/keys/) explains the keyring and the cluster's key in depth, and [operator lesson 1](https://docs.forge.workreef.dev/learn/operators/vault-and-keys/) rotates it.

Source: https://docs.forge.workreef.dev/learn/security/keys/index.mdx
