fastsecrets

The story, with the bad news left in

From 32 ms to 3 ms. Mostly by removing things.

This started as a bash script that took 32 ms to read one secret. We rewrote the reader in Rust, a language built for fast, safe programs, and now it takes 3 ms on an M5 Mac. AI agents did a lot of the building, and we kept notes like anthropologists, mistakes included.

Timeline

  1. First commit: age-encrypted env files in git, one file per scope (age is a small, widely used open-source file encryption tool).
  2. A bash tool, version 2.0: run, verify, logins, time limits, Secure Enclave keys.
  3. Round 1. The bash tool spawned age for every read: 46 to 48 ms. A first Rust reader, the start of fastsecrets, read the same store in 5.78 ms with a software key and 11.38 ms through the chip.
  4. age 1.4.0 shipped that same day with a new chip-key format older readers could not read. We caught it on dummy data before any machine upgraded, pinned age and added native support for both formats.
  5. Round 2. A native Rust run: 6.3 ms software, 11.8 ms chip, against 46 to 61 ms for the bash run.
  6. The public benchmark: 3.24 ms software, 9.05 ms chip on the M5 (all results).
Research footnote

The December 2 numbers come from benchmark protocol v0.3.1, 5 sessions per kind per machine.

What changed, step by step

  1. Stop spawning age. The reader decrypts the store itself, Secure Enclave keys included. No age process, no plugin process, no shell. With this reader, round 1 went from 46 to 48 ms to 5.78 ms.
  2. One decrypt per scope. Five names cost what one name costs. On the M5 chip path, five secrets take 9.06 ms and one takes 9.05 ms.
  3. A names-only index. It records which scope holds which name, so a warm read decrypts one scope instead of all of them. No values, no keys.
  4. No PATH search. The reader never runs a binary it finds on PATH. That closed a security hole (see the lessons).
  5. Native run. The reader puts values in the program's environment and, without --mask, becomes the program itself, so no parent holding the values stays alive. With --mask it stays as a filter on the program's output.

Where it started, where it ended

Same machine, same protocol, bash tool versus Rust reader (M5, software key).

bash toolfastsecrets
read one secret32.07 ms3.24 ms
start a program with one secret45.44 ms4.70 ms
start a program with five secrets174.53 ms4.75 ms

We did not measure each step's saving in isolation. The table shows where it started and where it ended.

Research footnote

Round 1 timed the bash read at 46 to 48 ms; under the final protocol, its software-key read measured 32.07 ms. The 0.34 ms in the diagram's top note below is one sandbox trace on the M5, not a benchmark figure.

Two read paths side by side. fastsecrets get is one native process (run takes the same path): process start, read key and scopes, the names-only index, decrypt in-process with no age binary, value out plus an access log line; 3.24 ms get1 median on the M5 with a software key, 9.05 ms with the Secure Enclave. The old bash reader starts bash, lists scopes, spawns age -d per scope, lets age decrypt the whole scope and finds the line with awk; 32.07 ms. Bars below compare get1 medians: software key fastsecrets 3.24, fnox 6.74, fnox daemon 7.93, sops 12.82, the old bash reader 32.07, pass 41.86; Secure Enclave fnox daemon with its cache 8.00, fastsecrets 9.05, fnox 17.90, sops 25.68.
Where the milliseconds go.

What we learned

  1. Compare mode to mode. Our first comparison set our chip mode against a rival's software mode, and it looked like a loss. Mode for mode we were ahead: 6.3 vs 9.8 ms in software, 11.8 vs 20.8 ms on the chip.
  2. The chip has a fixed price. About 4.5 ms of every chip read is the Secure Enclave itself. No code removes it. We budget for it.
  3. The language is not the speedup. Rivals are written in Rust too. The time came out of three removals: the age spawn, the shell and the extra decrypts.
  4. We chased the outright chip win, and parked it. We built a helper that keeps a connection to the chip, measured it and had it reviewed. At best it tied. It also opened an offline leak path. We shelved it. The fast path we recommend is batching: one call per agent step.
  5. Our worst hole came from our own fallback. A fallback in the reader ran whatever age was first on PATH. A planted program there could return a forged value with exit 0. Our own security detectors found it. Version 0.2.0 removed it.
  6. Pin your upstream. age 1.4.0 changed the chip-key format on our release day. A pin and a dummy-data compatibility matrix turned a breaking change into a planned upgrade.
  7. The benchmark needed adversaries too. An outside review found that our round-1 runner timed only successful samples, had no timeout and let entrants read the fixture. All three were fixed before the numbers above.

The agents' mistakes

Digital anthropology with AI. We ran this project with AI agents and wrote rules for them. They still broke some.

  • One let a keychain test hang for 8 minutes in a sandbox.
  • One ran a safety wrapper that hashed values from the real store and keychain.
  • One ran a downloaded binary outside the sandbox.
  • On the Linux box, one agent blamed slow sessions on host cron, then on zombie processes. Checking the timings showed the real cause: other tenants on the shared host were taking CPU.
  • In the voice-agent test, an agent's first process sampler used the wrong ps flag and reported zero leaks. The result was invalid. It caught the error, fixed the flag and ran again.

The first three were self-reported, and all three were checked afterward. Written rules help. Checking the work catches the rest.

Where to go from here

The benchmark

Every table, every non-win and the fnox daemon row.

The guide

Install, store, read, sync, recover and uninstall.

For agents

The rules, a copy-paste SKILL.md and the voice-agent pattern.