The agent never holds the key

How a viff task runs npm publish without ever seeing the token: the secret system.

Written in November 2026, and true as of then; the published docs (systems) are kept true as the tree moves.

A viff task works in a sandbox. It can use the tools its runner implements (git, github, slack, linear-issue, viff) and the programs the runner’s image carries. It still can’t run a command that needs a credential, such as npm publish, cosign sign or a migration against a database.

This article covers that, and the secret store under it. The answer is one more system in viff’s systems model, so there is no second vocabulary to learn. A spawn’s environment says what a task gets, the runner’s ceiling bounds it, and the autonomy decides each act. The runner holds every credential, in one store.

This is one of three articles on what a task lacks, and how the runner gives it:


The rule under all of it

A task never holds a credential, and never chooses which credential goes where.

The runner holds the credential, and the runner acts. Before each act it checks three things again, from its own copy of each:

Who writes it What it says
environment whoever spawned the task what this task is given: which channel, which server, which command
autonomy whoever spawned the task for each act: allow, deny, or ask a person
ceiling the runner’s operator the most any task of this doer may be given, whatever a spawn says
flowchart LR
  subgraph sandbox["task sandbox"]
    T["agent / script"]
  end
  subgraph runner["runner"]
    C{"environment<br/>autonomy<br/>ceiling"}
    S[("secret store<br/>one file per name")]
  end
  T -- "asks to act<br/>(no credential)" --> C
  C -- "refused" --> T
  C -- "allowed" --> A["act"]
  S -. "read at the act" .-> A
  A --> X1["Slack / Linear / GitHub API"]
  A --> X2["MCP server"]
  A --> X3["one command, in a sandbox of its own"]
  A -- "result, secret redacted" --> T

One store, bound in two ways

The store is a directory the deployment mounts, such as a Kubernetes Secret volume. It holds one file per secret, and the file’s name is the secret’s name:

tony
secrets: {dir: /secrets}
  • The runner reads a value at each use, so when a secret is rotated, the next act uses the new value. No restart is needed.
  • A secret’s name is public: it appears in the runner’s description and in every spawn that uses it. The value appears in no log, no reply and no file the task can read.
  • A secret that is absent closes whatever needs it. The runner says so when it starts, and viff refuses a spawn that needs it where the spawn is written, not halfway through a run.

There are two ways to give a secret to something that acts:

Binding Who makes it Used by Does the spawn name the secret?
The operator binds a secret to a system the runner’s configuration slack, linear-issue, an MCP server’s auth never: the spawn names the channel or the server
The spawn binds a secret to a command the spawn’s secret block, within the ceiling secret.exec yes, by name, and the operator’s ceiling must list that name
flowchart LR
  S[("secret store<br/>/secrets")]
  subgraph op["bound by the operator<br/>(runner configuration)"]
    SL["slack<br/>slack-bot"]
    LI["linear-issue<br/>linear"]
    MC["mcp server auth<br/>linear-mcp"]
  end
  subgraph sp["bound by a spawn<br/>(within the doer's secret ceiling)"]
    EX["secret.exec<br/>npm-token as NPM_TOKEN"]
  end
  S --> SL
  S --> LI
  S --> MC
  S -- "only names the<br/>ceiling lists" --> EX
  SL --> R1["the runner calls the API"]
  LI --> R1
  MC --> R1
  EX --> R3["one command has it"]

A secret the operator bound to Slack can’t reach a command, unless the operator also lists it in that doer’s secret ceiling. Ceilings are closed by default. (pkg binds no secret at all: its trust is the archive’s signed index.)


Existing system tools, with the store: Slack

Slack is the model for everything that follows. The task asks, and the runner posts with its own bot token.

Before the store, the token was an environment variable with a fixed name, SLACK_BOT_TOKEN. With the store, the operator names a file:

tony
# the runner's configuration
secrets:
  dir: /secrets
  systems: {slack: slack-bot}        # /secrets/slack-bot holds the bot token
agents:
  claude:
    systems:
      slack: {ceiling: {post: {channel: deploys}, read: {channel: deploys}}}

The spawn names channels and verbs, and never a token:

tony
spawn:
  agent: {name: claude}
  environment:
    systems:
      slack: {post: {channel: deploys}, read: {channel: deploys}}
  prompt: "Post the release notes for v1.3 in #deploys, then read the thread for objections."
  autonomy:
  - {match: {system: slack, verb: post, channel: deploys}, then: ask}
  - {match: {system: slack, verb: read}, then: allow}
  - {then: deny}

What happens on a post:

sequenceDiagram
  autonumber
  participant A as agent (sandbox)
  participant R as runner
  participant P as person
  participant S as secret store
  participant API as Slack API
  A->>R: slack-post {channel: deploys, text}<br/>no token
  R->>R: step slack.post channel=deploys<br/>within the environment?
  R->>P: autonomy says ask
  P-->>R: proceed
  R->>R: the answer is one the runner relayed<br/>within the ceiling?
  R->>S: read slack-bot, now
  S-->>R: token
  R->>API: chat.postMessage, with the token
  API-->>R: ts, link
  R-->>A: ts and link, never the token
  1. The agent calls slack-post. The call goes over the task’s channel to the runner, with no token on it.
  2. The runner works out the step (slack.post, channel: deploys) and checks it against the environment. The autonomy’s ask row puts the question to a person, and the runner checks that it relayed that person’s answer itself. It does not take the task’s word for it.
  3. The runner checks the ceiling: post to deploys is within it.
  4. The runner reads /secrets/slack-bot now, posts, and returns the message’s ts and link.

To rotate the token, replace the file; the next post uses the new one. If the file is missing when the runner starts, slack is closed to every doer, and the runner says which secret it looked for and where. linear-issue works the same way.


Commands that need a secret: secret-exec

Some work needs a credential in a process, not in an API call the runner makes: publishing a package, signing an artifact, running a migration. secret-exec is that.

The operator lists, for each doer, which secrets a task may run a command with and which commands. name is the secret’s file in the store, and as is the environment variable the command sees it under, so a row reads “npm-token, as NPM_TOKEN, for this command”:

tony
agents:
  claude:
    systems:
      secret:
        ceiling:
        - name: npm-token
          as: NPM_TOKEN           # the variable the command gets the value in
          exec: {argv: !regexp "^npm publish --ignore-scripts( --tag [a-z]+)?$", dir: !glob "packages/*"}
      network:
        ceiling: {mode: allow, tcp-client: {host: registry.npmjs.org}}

The spawn gives the secret by name, under the same as, with the commands it may run and where:

tony
spawn:
  agent: {name: claude}
  environment:
    systems:
      network: {mode: allow, tcp-client: {host: registry.npmjs.org}}
      git: [{repo: acme/lib, from: main, fetch: {}}]
      secret:
      - name: npm-token
        as: NPM_TOKEN
        exec: [{argv: "npm publish --ignore-scripts", dir: !glob "packages/*"}]
  prompt: "Publish each package under packages/ whose version is not yet on the registry."
  autonomy:
  - {match: {system: secret, verb: exec}, then: ask}
  - {then: allow}

What the task calls:

json
{"tool": "secret-exec",
 "name": "npm-token",
 "argv": ["npm", "publish", "--ignore-scripts"],
 "dir": "packages/a"}

What the runner does:

sequenceDiagram
  autonumber
  participant A as agent (task sandbox)
  participant R as runner
  participant S as secret store
  participant C as command (its own sandbox)
  A->>R: secret-exec {name: npm-token, argv: [npm, publish, --ignore-scripts], dir: packages/a}
  R->>R: step secret.exec<br/>argv "npm publish --ignore-scripts"<br/>environment, autonomy, ceiling
  R->>R: npm resolves under a system dir, a readOnly path<br/>or the install root, never the workspace
  R->>S: read npm-token, now
  R->>C: start over the workspace, under the task's network<br/>NPM_TOKEN in this process alone
  R-->>A: two sockets: stdout, stderr
  loop while it runs
    C->>R: output
    R-->>A: output, value replaced by [secret npm-token]
  end
  C-->>R: exit 0
  R-->>A: e1: exited 0, files and tails
  Note over A,R: secret-exec-kill e1, the timeout, or the task going away<br/>closes the streams, and the runner kills the command
  • It reads the call into one step: secret.exec with name: npm-token, as: NPM_TOKEN, argv: npm publish --ignore-scripts and dir: packages/a. The command is spelled as one line, so a pattern and a person read it as a command line. Where one argument ends is never ambiguous, because the call gives a list.
  • It checks the step against the environment, the autonomy and the ceiling. Plain variables are checked closed: a variable that no shape names makes the call outside the environment.
  • It runs npm only if npm resolves under a system directory, a path the operator keeps read-only, or the task’s install root, which the runner fills from the signed index (pkg) and the task cannot write. It never runs a program from the workspace.
  • It reads the secret, then starts the command in a sandbox of its own, over the task’s workspace and under the task’s network, with NPM_TOKEN in that process alone. The task’s own processes are in another pid namespace and can’t read it.
  • It streams stdout and stderr back to the task, with the value redacted, as .viff/exec/e1.out and .err in the workspace, plus two sockets a shell can read along from while the command runs.
  • With stdin: true — a field of the step, false where a shape says nothing of it — the same socket carries input back (hnp7jgfk): the task writes the command’s stdin at .viff/exec/e1.in.sock, its close is the command’s EOF, and the output still flows. Nothing is redacted on the way in; the input goes to the process that already holds the secret.
  • It answers e1: exited 0 and the tail of each stream. timeout bounds the run, which is an hour at most. secret-exec-kill e1 ends it, and so does the task going away.

Why a command, and not a proxy that adds the credential

The obvious alternative is to leave the task’s commands alone and let the egress proxy add the credential. The proxy sees a request to registry.npmjs.org, adds Authorization: Bearer …, and passes it on. The task never runs anything with the secret. Where that works, it is stronger. It is still the wrong general shape, for four reasons.

flowchart TB
  subgraph proxy["a proxy that adds the credential"]
    direction TB
    P0["task's command"] --> P1{"what does the<br/>secret do?"}
    P1 -- "HTTPS header" --> P2["intercept TLS<br/>(a CA the task trusts)"]
    P1 -- "SigV4" --> P3["re-sign each request<br/>(per provider)"]
    P1 -- "SSH key" --> P4["SSH man-in-the-middle"]
    P1 -- "DB password" --> P5["a proxy per wire protocol"]
    P1 -- "sign, decrypt" --> P6["no request:<br/>nothing to intercept"]
  end
  subgraph exec["secret-exec"]
    direction TB
    E0["the admitted command"] --> E1["the secret in its environment<br/>in a sandbox of its own"]
    E1 --> E2["HTTPS, SigV4, SSH, DB,<br/>sign, decrypt: all of them"]
  end

1. A credential is not always a header on a request.

What the secret does What a proxy would have to be
a bearer token on an HTTPS API (npm, PyPI, a REST API) a TLS-intercepting proxy that adds a header. Possible.
AWS SigV4 a proxy that re-signs every request: method, path, body hash and time. Different code for each provider.
an SSH key (git to a non-GitHub host, ssh deploy@…) a man-in-the-middle for SSH
a database password (Postgres SCRAM, MySQL) a proxy for each wire protocol, taking part in its auth handshake
a TLS client certificate, a kubeconfig a proxy that ends mutual TLS and starts it again
signing an artifact (cosign, gpg, minisign, codesign) nothing: there is no request to intercept
decrypting (sops, age) or unlocking a keystore nothing: it happens on the machine

2. HTTPS means interception. Today’s egress proxy decides by host on CONNECT and never sees inside the tunnel. To add a header, the task would have to trust a CA the proxy holds. The proxy would then see all of the task’s traffic in the clear, and any client that pins its certificates breaks.

3. Every proxy shape is a new system. Each service family needs its own document, verbs, configuration, code and tests, and someone has to write each one before anyone can use it. N services means N systems. secret-exec is one system, written once, and it works with anything that can take a secret from an environment variable.

4. secret-exec always has a way to fit. Anything that uses a secret is, in the end, a process that has the secret. So there is always a way to run it under secret-exec. At worst, the operator keeps a small program on a read-only path that does exactly one operation, such as sign-release <file>, and the ceiling admits that program and nothing else. A proxy has no answer for “sign this file”.

What it costs, said plainly

[!WARNING] secret-exec runs a command with the secret. What that command does with it is bounded by the shapes, and by nothing else.

  • An admitted command can show the secret. An environment that admits sh -c 'echo $NPM_TOKEN' leaks it, and that leak belongs to whoever wrote the environment. The runner runs what the environment admits and does not judge commands.
  • Redaction is only a second line. It catches the value when it appears whole. An encoded value, or one split up by the command’s own formatting, gets through.
  • The program check covers argv[0] and nothing more. Whatever that program runs also gets the secret: npm publish runs the package’s lifecycle scripts unless the command says --ignore-scripts, and an interpreter runs whatever it is handed. Write shapes for what a command does, not for its name.
  • The network decides where the secret can go. The command reads its configuration from the workspace, which the task can write. Pair every secret block with a network that reaches the one host the command needs, in the ceiling as well as the spawn.

So the order of preference is:

Who runs code with the secret What a person approves Cost of each new service
a performed system (slack, git, mcp) the runner’s own code the act: channel, ref, server and tool one system each
secret-exec the admitted command, in its own sandbox the command line, the directory and the variables nothing: one ceiling block
a credential-adding proxy nobody a host one proxy for each protocol, and TLS interception

Use a performed system where one exists. Use secret-exec for everything else. That’s the general case; nothing narrower covers it.

Edit on GitHub · viff is a shared runtime for a team's software delivery work.