Short-lived tokens from a program (preview)
New in 0.20.0, preview. A brokered secret’s source can be a command: a program that prints a short-lived token. openmoat proxy runs it, uses the value for at most lifetime, and runs it again before the value ends. The agent still holds only the placeholder moat-secret:<id>:placeholder, as for any brokered secret.
Example
Section titled “Example”This uses HashiCorp Vault’s CLI, one program file, to make a child token that lives 15 minutes. It is an example only: check your tool’s own command and the header its API expects.
secrets: - id: vault host: vault.example.com header: X-Vault-Token tls: terminate source: command: run: ["/usr/local/bin/vault", "token", "create", "-address=https://vault.example.com", "-ttl=15m", "-field=token"] lifetime: 15m # 1m to 12h: the longest one value is used refresh_before: 3m # optional; a fifth of lifetime when unset home: user # its own login is in ~/.vault-tokenThe agent sends X-Vault-Token: moat-secret:vault:placeholder; the proxy puts the token in place of the placeholder. Then:
openmoat edit # add the secretopenmoat run -- claude # the run's proxy runs the programopenmoat sandbox show # lists the secret as handled by openmoat proxyThe agent must not be able to change the program. It runs as you, outside every sandbox. Installed by an administrator under /usr/local/bin, the program and every folder above it belong to root, so no rule is needed. Installed with Homebrew under /opt/homebrew, which is yours, it needs a deny rule for that whole folder:
deny: - id: credential-programs fs.write: ["/opt/homebrew/**"]openmoat policy lint warns when no rule covers the program, and openmoat proxy refuses to start and names the rule to add.
What the proxy checks
Section titled “What the proxy checks”- Who can change it. The path in
run, the file it resolves to and every folder above it up to your home must each be covered by a denyfs.writerule of your own policy, or be changeable only by an administrator. A repository policy’s rules never count, and a deny rule counts only outside the project andopenmoat run’s write folders. - What it is. An absolute path or one under
~/; never a bare name,.or.., or/tmp,/var/tmp,/dev/shm. A script’s interpreter must pass the same check and is pinned too;#!/usr/bin/envis refused. - Pinned. At start the proxy hashes the program (SHA-256) and runs a private copy of those bytes, checked again before each run, never the file at the path. After you update the tool, restart
openmoat proxyoropenmoat run. - How it runs. In
/, never in your project; no input, no terminal, a 30-second limit, at most 64 KiB of output, and a bare environment (PATHis the system folders only).HOMEis an empty folder of its own unless you sethome: user. - What it prints. The value alone on one line, or JSON with
valueandexpires_inorexpires_at. The value is used until the earlier oflifetimeand that expiry. - When it fails. At start, the proxy does not start. Later, it says so (the secret’s id and the reason, never the output) and tries again every 15 seconds. Past the old value’s end, a request that needs it is refused before anything is sent, recorded as
proxy-secret-expired. A stale value is never sent.
Limits
Section titled “Limits”- Preview. The format and the checks can still change.
- Only
openmoat proxyruns it (and the proxy ofopenmoat run).openmoat guard, audit delivery and Claude Code’s broker never do, and a repository policy or a pack cannot add a secret. openmoat guard’s audit rows do not mask its values, because OpenMoat writes no file of them for the guard to read: that would be a copy on disk of the tokens the source keeps short-lived. The proxy’s own rows mask every value it gave (the last five).- What the program loads is not pinned. Libraries, modules and the configuration it reads (such as
~/.aws/config) are not checked: keep them from the agent with denyfs.writerules, or choose a program that is one file. This is why the example is notgcloud, whose Python loads code from folders you can write.
The full reference: POLICY.md §2.2 and ADR-087.