Skip to content

Secrets

A secret resource holds one value: an API token, a database password, a signing key. Its document carries the value encrypted, or names where to read it from (a command, a file, an environment variable). The daemon resolves the value into its memory and publishes a placeholder in its place:

runy-secret:_/github:3f9a0c1e

The placeholder is runy-secret:<namespace>/<name>:<revision>. The revision is eight hex digits that change when the value changes, so a resource that reads the secret renders a new spec and takes the change (a process restarts with the new value). It is not a hash of the value that anyone could test guesses against.

A resource reads a secret like any other resource, and the kinds that consume one swap the placeholder for the value at the last step:

kind: process
name: server
spec:
cmd: ./server
env:
GITHUB_TOKEN: ${ secret.github }

A hyphenated secret name needs a literal key in an expression, ${ secret["github-token"] }, as for every kind.

The value lives in the daemon’s memory while its secret runs. It is removed when the secret stops, goes idle or fails to resolve again, and when the daemon shuts down. It is never written to a record, a status or a file of runy’s own, and no call of the daemon’s API returns it. The one file it is written to is the one a file resource declares.

where what you see
runy get, the rendered spec, the status the placeholder
the console ••• and the secret’s id
mesh peers the placeholder; a peer cannot ask for a value
journals exact occurrences of a live value of 8 bytes or more are replaced with •••
a process’s environment the value itself, swapped in when the child starts
a file resource’s file the value itself, swapped in when the file is written

Masking in journals catches accidents, such as a process that prints its environment. A value the program has transformed is not caught.

The placeholder is swapped for the value in three places: a process’s env when the child is spawned, the env of its exec health checks on every attempt, and a file resource’s content when the file is written. A placeholder anywhere else, such as a cmd argument or a vm’s env, stays a placeholder.

An encrypted secret is an age file kept in the workspace’s resource files, so it can be committed. Each machine has its own key, created the first time it is needed and kept in the state folder. The workspace config lists the public keys the values are encrypted to, the recipients. Any machine whose key is a recipient can decrypt the value.

The CLI does the encrypting and decrypting in its own process with this machine’s key. The daemon is only asked where a secret’s document lives and how the secret is doing, so neither a browser nor a mesh peer can ask any daemon for a value. Secrets for a team walks through keys, recipients and rotation.

A process on the host gets the value in its environment, or reads it from a config file a file resource writes. For a client that should not hold the value, a secret with inject is also an HTTP endpoint on the host, the gateway. A virtual machine gets nothing unless its spec lists the secret under secrets, with one or more of three ways to use it:

way the consumer holds the value protects against does not protect against
host process env yes, the process the value in specs, statuses, logs and the console the process doing what it likes with it
a file resource yes, whoever can read the file the value in specs, statuses, logs, the console and the state database anyone who can read the file (mode 0600 by default), and copies of it such as backups
gateway on the host no, the daemon attaches it to requests a client reading the value any local process sending requests through it
credential in a vm no, the guest holds a stand-in that the driver replaces on HTTPS requests the guest reading the value the guest sending requests to the secret’s hosts
proxy in a vm no, the host’s gateway attaches it the guest reading the value any process in the VM sending requests through the gateway
resource in a vm yes, the runy daemon inside and the resources that read it a machine that is not granted the value reading it root in the VM, which can read it

The flags combine in one entry. Secrets in machines helps choose between them.