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
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:
HTTP_USER_AGENT, QUERY_STRING): a stranger chose those bytes;EDITOR names the program the privileged one runs (the
sudoedit hole, CVE-2023-22809, was of this kind);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.
| 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 |
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).
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").
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.
[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.
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).
env::var("EDITOR") is the operator’s in a tool someone types and a
stranger’s in a setuid helper. One line in the manifest says which program
this is; a marker at every call said it a hundred times and meant nothing.main, so a
program not built for it does not run.What this record does not catch, said so that nobody counts on it:
GITHUB_ENV, a
CI step that writes the environment of the next one). Who controls the
environment of a process controls it before main: LD_PRELOAD,
LD_LIBRARY_PATH or PATH run the stranger’s code before any check the
program makes. No reading of env::var helps there; the runner has to keep
the variables out. A service that knows it is started this way declares
D4, which keeps its own reads honest, not the loader.sudo with env_keep (or sudo -E) runs the program as root without a
privileged start: AT_SECURE is not set, and the variables the
administrator keeps arrive as the operator’s. That is the administrator’s
configuration; a program meant to run under sudo declares D4.-- in it read as the end of the
options, which is about how an argument is read, not where it came from.
That half is
#1939’s.environment and --environment; Part III 17 says so at
std::env.std’s provenance for env::var and env::vars by
name, the removal of their trusted: option, the run-time check before
main on Linux, macOS and the BSDs, the manifest key, tests. The existing
test of this record changes with it.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.