ADR-397: The Environment Is the Operator’s, Except a Host’s Names and a Privileged Start

Status: Accepted Date: November 14, 2026; changed November 19, 2026 (owner’s decision in the discussion of #1938: grey levels by deployment, not a marker at each call) Answers: who chose the bytes of an environment variable, which ADR-010 D2 answered the operator and ADR-365 left open; whether an assert about one is checked or refused; what a value from the environment may reach Related: ADR-010 D2, D5, D8 (the sources, the hasher, the further consumers); ADR-365 (standard input and files); ADR-prover-refusals-v1 (NK1302); ADR-108 (a path names its root); ADR-243 D5-D8 (a child’s environment); ADR-raw-sinks-1 D10 (a program from outside); Part III 13.3, 14.2, 17.1; #1597

1. Question

let depth = text::parse_i64(env::var("DEPTH") ?? "8") ?? 8
assert(depth > 0)
log("user agent: " + (env::var("HTTP_USER_AGENT") ?? ""))
let editor = env::var("EDITOR") ?? "vi"
process::run(editor, [path])

ADR-010 D2 took the operator to have chosen the environment. Often that is true: whoever types the command, writes the unit file or the container’s configuration sets DEPTH and EDITOR, and could run any program anyway. Sometimes it is not:

The first version of this record (November 14) made every value untrusted and let trusted: true at each call say the operator chose it. In a command-line tool, the common case, that marker went on nearly every read: the owner rejected it as boilerplate, not security. A marker that every call carries says nothing a review can use.

2. Options

Option Why it lost See
Every value untrusted; trusted: true at each call (this record, November 14) in a command-line tool the marker is on every read, so it records nothing; the decision belongs to the deployment, not to the call D1
Every value trusted, as ADR-010 D2 had it a CGI program and a setuid program read a stranger’s bytes as the operator’s D2, D3
Untrusted only for a host’s names, nothing else a privileged start inherits every variable its caller chose D3
A privileged start makes every value untrusted at run time, checked at each sink the same program means different things by how it was started; a sink that throws at run time is the taint mode ADR-raw-sinks-1 rejected D3

3. Decision

D1 — The environment is the operator’s.

env::var and env::vars (#1597) hand back trusted text, as ADR-010 D2 had it, with the exceptions of D2 and D4. A claim about it is checked as any claim is, its maps may take the fast hash, and it may reach a raw sink (ADR-raw-sinks-1 D2, case 1). No call carries a marker: the trusted: option of env::var and env::vars goes.

env::temp_dir(), env::current_exe() and env::current_main() give a path, and no provenance travels a path (ADR-010 D8): where a path reaches the filesystem it names its root (ADR-108).

D2 — The names a CGI host fills are untrusted.

A variable whose name starts with HTTP_, or is one of RFC 3875’s meta-variables (AUTH_TYPE, CONTENT_LENGTH, CONTENT_TYPE, GATEWAY_INTERFACE, PATH_INFO, PATH_TRANSLATED, QUERY_STRING, REMOTE_ADDR, REMOTE_HOST, REMOTE_IDENT, REMOTE_USER, REQUEST_METHOD, SCRIPT_NAME, SERVER_NAME, SERVER_PORT, SERVER_PROTOCOL, SERVER_SOFTWARE), is untrusted wherever it is read: an assert about it is NK1202, an index it reaches is proved or refused (NK1302, ADR-prover-refusals-v1), and a map keyed by it gets the keyed hash (ADR-010 D5). The text keeps that provenance through every value made from it (Part III 17.1).

The compiler decides it from the name. A name it does not know while building is untrusted. env::vars(prefix) is untrusted when a name of the list can start with prefix: env::vars(""), env::vars("H"), env::vars("HTTP_"), env::vars("REMOTE").

D3 — A privileged start ends before main unless the manifest says the environment is untrusted.

A program started with more rights than its caller (on Linux AT_SECURE in the auxiliary vector: setuid, setgid, file capabilities; issetugid() on macOS and the BSDs) does not reach main unless its manifest declares the environment untrusted (D4). The run time writes on standard error that the program was started with more rights than its caller and that its manifest does not declare the environment untrusted, names the line to add, and ends with exit status 1. Nothing of the program runs.

So a program never means two things by how it was started: what was proved while it was built holds for every run that reaches main. Windows has no such start; a program there runs as built.

D4 — [build] environment = "untrusted" makes the whole environment untrusted.

[build]
environment = "untrusted"

Every value env::var and env::vars hand back is then untrusted, as D2’s names are, and a privileged start reaches main (D3). It is for a program meant to run setuid or with capabilities, and for a service whose environment a less trusted party sets (a job runner, a deployment that copies variables from a request). The default is "operator". The key is read from the application only; a package’s own [build] is ignored, as every build option of a package is (Part III 13.3). It is a cache-key dimension, as raw-sinks is. --environment=untrusted sets it for one build.

D5 — Where an untrusted value goes, it goes as untrusted data does.

A value D2 or D4 makes untrusted is not written raw where untrusted data is not: into a log, a terminal, a query or a page it goes the way a header or a line from a socket goes there, escaped where that consumer escapes. The consumers are ADR-010 D8’s, decided once for every untrusted source; the log is one of them (ADR-398), the raw sinks are ADR-raw-sinks-1’s. Request and socket data stay untrusted in every deployment (ADR-010 D2).

4. Reasons

5. Limits

What this record does not catch, said so that nobody counts on it:

6. Consequences

Not decided here: cli::args, decided by ADR-399: untrusted. Whether the command line follows this record’s model is open.

Decided November 14, 2026; D1-D5 and the limits decided November 19, 2026.

This site is open source. Improve this page.