OXYGENHUB
# 6ba07678ae86 oxygenhub / docs / keyless.md
8.2 KiB · Markdown · last changed transparency.md and keyless.md: accepted, with Andy's decisions 19 days ago renderedsource blame history raw
1
# Keyless signing: short-lived keys from an OIDC identity
2
3
Design for oxygenhub#241, written 2026-10-17. **Status: accepted** (Andy,
4
2026-10-17, the four decisions below as recommended). Nothing here is built
5
yet. It builds on the hub's
6
OIDC issuer (hub spec §13.5) and on the transparency log
7
(docs/transparency.md, #238/#240).
8
9
## Why
10
11
Every signing key in Oxygen lives long: a runner's `runner.key`, an
12
agent's key in its home (`~/.oxy-agents/claude/keys`), a person's key. A
13
delegation can already expire in minutes (`oxy identity delegate add
14
--expires 30m`), but the key it names stays on disk afterwards, and each
15
grant re-issues the owner's identity by hand. A stolen key works until
16
someone notices and revokes it.
17
18
Sigstore's answer (Fulcio) is a key that lives only for one job: the
19
signer proves who it is with an OIDC token, gets a certificate for a fresh
20
key valid for minutes, signs, and throws the key away. Nothing long-lived
21
sits on the runner or in the agent's home, and a policy can name **who**
22
may sign ("this pipeline on main", "Claude, for andymccall") rather than
23
which key.
24
25
## What exists already
26
27
- **Delegation** (spec §14.2, §14.5): an identity lists delegates with a
28
  scope (`changes`, `refs`, `seal`, `all`) and an expiry, checked against
29
  the time the signed object claims. The identity issues it itself; no
30
  other key can.
31
- **The hub's OIDC issuer** (hub spec §13.5, `oidc.rs`): a Flow job that
32
  declares `identity "AUD"` gets an RS256 token with `sub`
33
  `repo:OWNER/NAME:bookmark:B`, the environment and its approval, expiring
34
  with the job (at most 6 h). The JWKS is at `/.well-known/jwks.json`.
35
  The hub already uses these tokens for keyless backups to GCS and S3.
36
- **The hub's key** (hub spec §15.5) signs web edits, wiki changes,
37
  Diffusion bumps, swarm tickets and SLSA provenance.
38
39
What is missing is a delegation **issued by someone else** (a certificate
40
authority), policy rules that name identities rather than keys, and time
41
a verifier can trust once the certificate has long expired.
42
43
## The certificate
44
45
A new object, `certificate`, issued and signed by a hub's key (its
46
composite Ed25519 + ML-DSA-65 key, so certificates stay post-quantum):
47
48
```
49
Certificate {
50
  version     [0]: 1
51
  key         [1]: Identity        // the fresh key pair's public identity
52
  issuer      [2]: KeyId           // the hub key that signs it
53
  subject     [3]: text            // who proved it: "repo:andymccall/oxygen:bookmark:main", "agent:claude@andymccall"
54
  claims      [4]: map text->text  // what else the token said: environment, approval, run, job
55
  scope       [5]: Scope           // changes, refs, seal
56
  not_before  [6]: u64             // milliseconds
57
  expires     [7]: u64             // not_before + at most 10 minutes for jobs
58
}
59
```
60
61
It travels with what it signed, like an identity: a push carries the
62
certificates of the keys that signed its changes and attestations, and a
63
fetch brings them.
64
65
## Getting one
66
67
```
68
POST /api/v1/keyless/certify
69
  { "token": "<OIDC token>", "identity": "<fresh identity, CBOR, base64>",
70
    "proof": "<the fresh key's signature over the hub's challenge>", "scope": "refs" }
71
→ { "certificate": "<CBOR, base64>" }
72
```
73
74
The hub checks:
75
- the token: its own issuer to begin with (others later, see the
76
  decisions);
77
- that the proof shows the caller holds the fresh key (the challenge
78
  signatures of spec §14.3);
79
- that the scope asked is one the subject may have.
80
81
It then signs a certificate expiring at the earlier of ten minutes and
82
the token's expiry, and logs it (below).
83
84
- **A Flow job** gets a token as it does today, generates a key in memory,
85
  certifies it, signs (a receipt, a tag, an attestation of a release), and
86
  the key dies with the job. `runner.key` remains only to authenticate the
87
  runner to the hub, not to sign what jobs made.
88
- **An agent** has no OIDC token of its own. The hub gives it one when its
89
  owner says so: `oh agent grant claude --scope changes --for 8h` on
90
  Andy's side, or a hub page with a button, makes an agent token. The
91
  agent exchanges that token for certificates as it needs them (each ten
92
  minutes). The owner revokes the grant on the hub, and no key is left
93
  anywhere. The agent's home holds only the grant token, which signs
94
  nothing by itself.
95
- **People** keep their own keys; passkeys (#237) are the separate answer
96
  for them.
97
98
## Policy names identities
99
100
A rule today lists keys. It may also list **subjects from an issuer**:
101
102
```
103
rule "main" {
104
  key 4cd9916c…                                   // Andy, as today
105
  subject "repo:andymccall/oxygen:bookmark:main" issuer HUB scope refs
106
  subject "agent:claude@andymccall" issuer HUB scope changes
107
}
108
```
109
110
`HUB` is the hub key's KeyId, so the policy says which CA it trusts for
111
which subjects. A pattern may end in `*`. The policy's roots still sign
112
the policy, as now.
113
114
## Verifying later
115
116
A certificate is valid for ten minutes. A verifier checking a signature a
117
year later must know **the signature was made inside those ten minutes**,
118
and the signer's own claim of time is not enough (that is #240's
119
problem). Two sources, in order of strength:
120
121
1. **The transparency log** (docs/transparency.md): the hub logs every
122
   certificate it issues and every object signed by a certified key. An
123
   object integrated (witnessed) before its certificate's `expires` was
124
   signed in time. This is exactly how Sigstore uses Rekor with Fulcio.
125
2. **The hub's acceptance**, until the log exists: when a push carries a
126
   certified signature, the hub countersigns its acceptance time on the
127
   object (a small attestation, kind `accepted`). That trusts the hub's
128
   clock alone, which the log later removes.
129
130
A signature whose certificate has expired, with neither proof, is
131
invalid.
132
133
## Revocation
134
135
Short certificates mostly replace revocation: a stolen key is useless ten
136
minutes later. What can still be revoked:
137
- **the grant** an agent holds (on the hub, at once);
138
- **the issuer** itself (a policy without the hub's key trusts none of
139
  its certificates);
140
- **one certificate** by its hash (a revocation listed in the policy, as
141
  keys are now), for the ten minutes it matters.
142
143
## Order of work
144
145
1. **The certificate object** in oxy-core: encoding, verification (issuer
146
   signature, scope, expiry against a given trusted time), carried in
147
   bundles like identities. Spec §14. About three days.
148
2. **The certify endpoint** on the hub: token check, proof of
149
   possession, issuing, logging. About two days.
150
3. **Flow jobs:** the runner certifies a fresh key per job and signs
151
   receipts with it; the hub checks receipts by certificate as well as by
152
   `flow_runner_keys`. About two days.
153
4. **Policy subjects:** rules naming issuers and subject patterns; `oxy
154
   policy grant --subject`. About two days.
155
5. **Agent grants:** `oh agent grant`, the hub's grant tokens, and oxy
156
   certifying on demand when `author.signer` is `keyless`. About three days.
157
6. **Trusted time:** the acceptance attestation now; the log's integrated
158
   time when #238 lands.
159
160
## Decisions (taken 2026-10-17)
161
162
Andy chose the recommendation each time: our own composite-signed
163
certificate, built now with the hub's acceptance time (the log's time
164
later), agent grants that retire the agent keys, and the hub's own OIDC
165
issuer first.
166
167
1. **Certificate format:**
168
   - Our own CBOR object, composite-signed: post-quantum, and small.
169
   - X.509, as Fulcio issues: readable by Sigstore's tools, but classical
170
     only.
171
   - Recommendation: **our own**, with an X.509 export later if a
172
     customer needs Sigstore's tools to read them.
173
2. **Build before or after the transparency log?** Certificates are only
174
   as good as the proof of when they were used.
175
   - Recommendation: **build steps 1 to 4 now with the hub's acceptance
176
     attestation**, and move to the log's time when #238 step 1 lands.
177
3. **Agents:** a grant on the hub that the agent exchanges for ten-minute
178
   certificates, replacing the long-lived agent keys and the 8 h
179
   delegations re-issued by hand.
180
   - Recommendation: **yes**, and retire `~/.oxy-agents/*/keys` once it
181
     works.
182
4. **Other OIDC issuers** (GitHub Actions, GitLab CI, Google service
183
   accounts) as subjects, for repositories mirrored or built elsewhere:
184
   - Recommendation: **the hub's own issuer first**; others as a site
185
     setting listing trusted issuers, later.