Background and interactive runtime
fnox exposes secret access through four runtime surfaces: a per-user daemon for faster repeated reads, a credential proxy for destination-limited requests, a terminal dashboard for people, and an MCP server for AI tools. Each surface starts from the active configuration and profile, then uses the common secret resolution flow while applying a different boundary for how values are used.
Runtime model
The command line is the common entry point for all four surfaces. A command loads the active configuration and profile, chooses a runtime surface, and asks fnox to resolve only the secrets that surface needs.
flowchart LR
A[fnox command] --> B[Active config and profile]
B --> C{Runtime surface}
C --> D[Daemon-backed reads]
C --> E[Credential proxy]
C --> F[Terminal dashboard]
C --> G[MCP server]
D --> H[Resolved secret values]
E --> I[Approved HTTPS requests]
F --> J[Human view and session actions]
G --> K[Agent tools and command output]
The daemon can support the TUI, MCP server, and proxy while they resolve secrets. The proxy and MCP server still define their own rules for what a child process or agent can receive. This keeps faster resolution separate from the question of whether a secret value is exposed.
Shared resolution context
The shared resolution context carries the selected config file, profile overlays, missing-value policy, key settings, and interactive mode into each runtime. This lets the daemon-backed and direct paths produce the same result for the same command context. Profile composition also informs provider selection and cache identity, so an inherited profile does not reuse a value from a different effective configuration. src/daemon.rs• L36-89, src/daemon.rs• L189-217, src/daemon.rs• L220-297, src/daemon.rs• L353-433
References: src/daemon.rs• L36-89 src/daemon.rs• L189-217 src/daemon.rs• L220-297 src/daemon.rs• L353-433 src/…/mod.rs• L40-89
Background services
Background services support work that lasts beyond a single secret lookup or that must control access to another process. The daemon persists for a user session, while the proxy lives only for the lifetime of its child command.
Per-user daemon
The per-user daemon keeps resolved values in memory so repeated read operations do not need to contact secret providers each time. Supported commands can start it when enabled, or an engineer can manage it with fnox daemon start, status, clear, and stop. home/…/daemon.rs• L595-675, home/…/daemon.rs• L677-790, home/…/daemon.rs• L13-69
The daemon starts as a detached background process with / as its working directory. It therefore does not keep the caller's current directory or terminal session open. home/…/daemon.rs• L607-675
The daemon serves one user through a local Unix socket or a current-user named pipe. Its cache is session state rather than durable storage, so it disappears after a clear, stop, idle exit, or relevant context change. Individual entries can also expire after an idle period or a maximum lifetime. Daemon use is opt-in and can be disabled for one invocation or for a session. home/…/daemon.rs• L105-152, home/…/daemon.rs• L478-592, home/…/daemon.rs• L712-790, home/…/daemon.rs• L838-909
Interactive clients do not make the daemon perform provider prompts. When an interactive request has a cache miss, the client resolves the missing values in the foreground, combines them with cached values, and sends safe results back to the daemon for later reuse. A changed configuration fingerprint or cache-clear epoch prevents stale foreground results from filling the cache. home/…/daemon.rs• L236-297, home/…/daemon.rs• L435-460, home/…/daemon.rs• L1469-1480
For the security boundary and cache rules, see Daemon and proxy runtime. For request framing and daemon client behavior, see Daemon client protocol.
References: src/daemon.rs• L105-152 src/daemon.rs• L595-675 src/daemon.rs• L677-790 src/daemon.rs• L926-969 src/daemon.rs• L1015-1057 src/daemon.rs• L1066-1120 src/daemon.rs• L1211-1321 src/…/daemon.rs• L13-69
Credential proxy
The credential proxy lets a child process call approved external services without placing real credentials in that process. The child receives placeholders, and fnox replaces them only when the request matches the configured domain, route, and target location. A rule can place a credential in one permitted header or named query parameter. src/…/plan.rs• L82-275, src/…/policy.rs• L45-105, src/…/policy.rs• L385-489
The proxy runs for one fnox proxy run command. It creates a session boundary, authenticates clients with a session token, and exposes either a loopback listener or a private Unix socket. For credential injection, it terminates the child TLS connection locally and forwards only approved HTTPS requests. It removes the temporary trust material when the child exits. Strict egress rejects destinations without rules; permissive egress can tunnel approved destinations without injecting credentials. src/…/server.rs• L6-15, src/…/server.rs• L94-195, src/…/server.rs• L236-375, src/…/policy.rs• L335-361
The proxy limits request body size before forwarding a request. It also removes resolved credentials from response headers and bodies before they return to the child. It keeps this protection for streamed responses and for query credentials in common URL-encoded forms. Requests with ambiguous path encodings are refused because their route meaning is not safe to establish. src/…/server.rs• L419-524, src/…/server.rs• L552-615, src/…/policy.rs• L128-264, src/…/policy.rs• L583-680
The proxy checks the addresses returned for a destination before it connects. Public addresses are allowed, while non-public addresses need an explicit allow_private entry that can also limit the port. This check applies to the upstream client's own name resolution, which prevents a later lookup from bypassing the destination rule. src/…/destination.rs• L41-149, src/…/server.rs• L310-354
The proxy can also use short-lived lease credentials. It mints or renews a lease when a matching request needs it, then revokes credentials minted during the session when the proxy stops. src/…/leases.rs• L1-10, src/…/leases.rs• L211-316
The proxy limits credential use but does not sandbox a same-user child. A separate container, virtual machine, or equivalent boundary is needed when the child must not reach fnox files or provider credentials directly.
For the request path and proxy security model, see Daemon and proxy runtime.
References: src/…/plan.rs• L38-275 src/…/policy.rs• L45-105 src/…/policy.rs• L266-489 src/…/policy.rs• L583-680 src/…/server.rs• L6-15 src/…/server.rs• L94-195 src/…/server.rs• L236-375 src/…/server.rs• L391-596 src/…/server.rs• L642-708 src/…/destination.rs• L41-149 src/…/destination.rs• L153-215 src/…/leases.rs• L211-316 src/…/tests.rs• L330-377 src/…/tests.rs• L662-745 src/…/tests.rs• L1078-1227
Interactive interfaces
Interactive interfaces let a person or an agent use fnox without treating every operation as a plain environment injection. The terminal dashboard is for direct human control, while MCP presents a controlled tool interface over a session.
Terminal dashboard
The terminal user interface (TUI) is a live dashboard for viewing and working with the active profile. It shows providers and secrets, loads values in the background, supports search and profile changes, and gives explicit views for details and copying. home/…/tui.rs• L24-79, home/…/ui.rs• L70-130
The TUI keeps its edits in memory. It can update the current view or add a secret to the session state, but it does not write those changes to the configuration. Use the normal write commands when a change must persist. home/…/app.rs• L623-738, home/…/tui.md• L47-53
The dashboard starts in non-interactive provider mode and uses the shared daemon context for resolution. This keeps terminal controls responsive and avoids provider prompts that could disrupt the dashboard. When a person switches profiles, the TUI loads both the effective secrets and providers before it commits the new view. home/…/tui.rs• L28-57, home/…/app.rs• L805-840
For the dashboard views and agent-facing interface, see TUI and MCP interfaces.
References: src/…/tui.rs• L24-79 src/…/app.rs• L69-198 src/…/app.rs• L247-318 src/…/app.rs• L320-513 src/…/app.rs• L623-738 src/…/app.rs• L805-840 src/…/ui.rs• L70-130
MCP server
The Model Context Protocol (MCP) server gives an AI agent a session-scoped secret broker over standard input and output. It exposes only the configured tools: get_secret returns an allowed value, exec runs a command with allowed execution secrets, and request_secret lets the user provide a missing value without sending it through the agent. src/…/server.rs• L13-44, src/…/server.rs• L65-127, src/…/tools.rs• L64-146, src/…/request_secret.rs• L33-63
The MCP session resolves execution-ready secrets in a batch on first use and resolves more sensitive non-injected secrets only when requested. It caches the results in process memory until the agent disconnects. An optional secret allowlist and tool list reduce the surface before a tool call is made. src/…/server.rs• L65-127, src/…/tools.rs• L86-145
The exec tool does not give an agent a shell with hidden powers. The agent chooses the command, so the main controls are the configured tools and secrets, bounded command output, redaction of resolved values before output returns over MCP, and a command timeout. The child receives only allowed resolved secrets. fnox removes its ambient age identity, keeps file-backed secrets in temporary files, and does not pass non-execution secrets to the child. src/…/tools.rs• L148-231, src/…/tools.rs• L233-361
When the user must provide a missing value, request_secret uses a one-time local page on a random loopback port with an unguessable path. The page accepts one same-origin submission, keeps a confirmation page for a short time, and sends its URL through MCP URL-mode elicitation. The value goes from the browser to fnox, and the agent learns only whether fnox stored it. Host and browser-origin checks reject requests that do not come from the page itself. If the client cannot open such a page, fnox gives the user a terminal command instead of asking for the value in chat. src/…/request_secret.rs• L82-157, src/…/request_secret.rs• L215-265, src/…/page.rs• L125-167, src/…/page.rs• L220-303
Inside fnox proxy run, MCP becomes a relay to the proxy-owned service. The agent receives placeholders and usage information instead of real values, request_secret can hand a stored value to the proxy, and exec is not offered because the proxy already runs outside the sandbox. src/…/server.rs• L38-71, src/…/proxied.rs• L10-59, src/…/relay.rs• L1-3
For tool access, session limits, and output handling, see TUI and MCP interfaces.
References: src/…/server.rs• L13-127 src/…/server.rs• L131-219 src/…/tools.rs• L64-146 src/…/tools.rs• L148-231 src/…/tools.rs• L233-361 src/…/request_secret.rs• L33-63 src/…/request_secret.rs• L82-213 src/…/page.rs• L125-167 src/…/page.rs• L220-355 src/…/proxied.rs• L10-79 src/…/relay.rs• L17-173
Surface selection
Choose a surface based on who needs access and where the real secret value may exist:
| Surface | Main user | Secret access goal | Lifetime |
|---|---|---|---|
| Daemon | fnox read commands | Reuse resolved values for faster reads | User session or idle timeout |
| Proxy | Child process or agent | Send credentials only to approved HTTPS routes | One child command |
| TUI | Human operator | Inspect and work with profile secrets interactively | Open terminal session |
| MCP server | AI agent | Request named secrets or run commands through an explicit tool contract | Agent session |
These surfaces can work together. The daemon can reduce provider work for the proxy, TUI, or MCP server, but it does not widen their access rules. The proxy protects request destinations, and MCP limits tools and secret names at its own boundary.
Change checklist
When these files or sections are changed, remember to consider these:
- When the daemon request context, purpose values, or protocol fields change, check every caller that uses daemon-backed resolution, especially proxy, TUI, and MCP.
- When profile composition or provider selection changes, check daemon cache fingerprints and TUI or MCP session reloads together. An effective profile must resolve the same providers and secrets in both paths.
- When secret environment modes change, check the distinction between shell injection, child-command injection, direct MCP retrieval, and proxy placeholders.
- When proxy rule fields change, check both child placeholders and the request route checks so the child view and upstream policy stay aligned. For query rules, check the named parameter and its encoded value separately from headers and paths.
- When proxy authentication or listener behavior changes, check loopback and Unix-socket access, session-token handling, temporary trust material, and shutdown cleanup together.
- When proxy request limits or response handling changes, check body-size rejection, header redaction, streamed body redaction, encoded query values, ambiguous paths, and responses that cannot be safely redacted together.
- When proxy destination or lease behavior changes, check strict egress, private-network and port rules, DNS filtering, renewal, and shutdown revocation together.
- When MCP tools or allowlists change, check tool advertisement, tool-call rejection, and proxy-mode tool descriptions. An agent must not see a tool that the server will reject.
- When MCP command environment handling changes, check that subprocesses receive only resolved allowed secrets, file-backed values use temporary paths, ambient decryption identities are removed, and non-execution secrets are absent.
- When MCP command output or timeout handling changes, check bounded stdout and stderr collection, cancellation cleanup, exit reporting, truncation reporting, and secret redaction together.
- When
request_secretor its local page changes, check URL-mode elicitation, loopback host and origin checks, terminal fallback, one-time submission, confirmation retention, and the rule that the agent never receives the value. - When TUI write behavior changes, check whether the action updates only session state or also changes the persistent configuration contract.
Important failure modes
| Trigger | Consequence | Guard |
|---|---|---|
| Daemon is enabled on an unsupported platform | Read commands cannot use the background service | Use direct resolution with --no-daemon or disable daemon mode |
| A daemon cache is stale after config, profile, or provider context changes | A read can use a value from an old session context | Invalidate the cache when relevant context changes, or run fnox daemon clear |
| An inherited profile cannot produce a valid effective provider or secret set | Daemon-backed resolution or a TUI profile switch fails instead of showing the requested profile | Fix the profile composition and provider definitions before switching or resolving |
| A proxy request body exceeds the configured limit | The request is rejected before it reaches the upstream service | Set a limit that fits the request, or reduce the request body |
| A proxy rule does not match the destination, method, path, or header or query target | The request is rejected or the credential is not injected | Inspect the proxy rules and keep rules aligned with the client request |
| A placeholder appears more than once or outside its configured request target | The proxy refuses the request instead of guessing which occurrence should receive the credential | Send one placeholder in the configured header or query parameter on an allowed route |
| A request uses an ambiguous path encoding | The proxy refuses the request because route checks could use different path meanings | Use a canonical path without encoded separators, dot segments, or repeated encoding |
| A client lacks the session token or uses a non-CONNECT request | The proxy challenges or rejects the connection before it reaches an upstream service | Pass the session proxy credentials and use HTTPS CONNECT |
| An upstream response uses an unsupported content encoding or ends during streaming | The response is rejected or ends without a complete body | Use an identity-encoded response and handle the proxy connection as a streamed response |
| A proxy destination resolves only to a non-public address without an allow entry, or the entry excludes its port | The proxy refuses the connection | Add only the required private network and port to the destination policy |
| A proxy child bypasses proxy settings or reads same-user credential sources | The child may access credentials outside the proxy policy | Run the child in a sandbox that blocks direct egress and source access |
| A proxy lease cannot be minted or renewed | Requests that need the lease are refused, and an expired credential is never injected | Check the lease backend and use the lease ledger or service to revoke stale credentials |
| MCP receives a command that prints an injected secret | Secret content could return in tool output | Keep output redaction enabled and use an allowlist with only required secrets |
MCP exec receives a command that runs too long or emits too much output | The agent session can stall or consume excessive memory | Use the execution timeout and bounded concurrent stdout and stderr collection |
MCP exec receives a file-backed or non-execution secret | A child can receive a raw secret or an unintended environment value | Pass file-backed values as temporary paths and remove secrets that are not enabled for execution |
| MCP starts with provider interaction enabled | Prompts can corrupt the stdio protocol | MCP runs non-interactively and needs cached or otherwise non-prompting provider auth |
| A browser sends the MCP secret-page request with the wrong host or origin | fnox rejects the submission and does not store the value | Open the exact loopback URL from the MCP client and submit only from that page |
| An MCP client cannot support URL-mode elicitation | The user cannot enter a value through the secure page | Use the terminal fallback and call request_secret again after the user stores it |
| A TUI edit is treated as a persistent write | The change disappears when the TUI exits | Use fnox set or another write command for durable changes |
Key files
| File | Why to read it |
|---|---|
| src/…/mod.rs | Shows how the CLI selects the daemon, proxy, MCP, and TUI surfaces. |
| src/daemon.rs | Defines the shared resolution context, daemon lifecycle, detached background process, cache, and client calls. |
| src/…/daemon.rs | Shows the user-facing daemon lifecycle commands. |
| src/…/plan.rs | Turns proxy rules and resolved values into the child-facing policy, including header and query targets. |
| src/…/policy.rs | Defines destination, route, substitution, and response-redaction rules. |
| src/…/destination.rs | Defines public-address checks and the private-network and port policy for upstream connections. |
| src/…/server.rs | Shows proxy listeners, HTTPS interception, tunneling, streaming responses, request limits, and shutdown. |
| src/…/leases.rs | Explains on-demand lease minting, renewal, ledger records, and revocation. |
| src/…/tui.rs | Shows how the interactive dashboard starts and connects to secret resolution. |
| src/…/app.rs | Defines the dashboard session state and user actions. |
| src/…/server.rs | Defines MCP session state, tool filtering, and proxy-mode behavior. |
| src/…/tools.rs | Defines secret retrieval, command execution, environment limits, output bounds, timeout, and redaction controls. |
| src/…/request_secret.rs | Defines the user-assisted flow for storing a missing secret. |
| src/…/page.rs | Defines the loopback page, request checks, one-time submission, and short confirmation period. |
| src/…/relay.rs | Shows how MCP reaches the proxy-owned service when running under fnox proxy run. |
| crates/…/config.rs | Defines the daemon, proxy, and MCP configuration contracts. |
| docs/…/daemon.md | Gives the user-facing daemon model and cache behavior. |
| docs/…/proxy.md | Gives the user-facing proxy model and security limits. |
| docs/…/mcp.md | Gives the user-facing MCP setup and tool behavior. |