1.9 KiB
1.9 KiB
ADR-0043: Explicitly granted env.get resource operation
Status: Accepted
Date: 2026-11-21
Relates to: ADR-0041, ADR-0042
Specs: spec/security.md, spec/evaluation.md
Evidence: docs/evidence/2026-11-21-env-product.md
Context
A product std:env module needs to read process environment variables. The
environment is an ambient OS side channel that can contain secrets and
credentials. Reading it through a wildcard path grant or by default would
silently widen the capability surface; env.list would expose every variable
without naming it.
Decision
Add one operation to resource.request:
resource.request("env.get", [name]) -> {ok:true, value:Text}
| {ok:false, code:"env.not_found"}
| {ok:false, code:"env.not_unicode"}
- Arguments: exactly one
Textvariable name. Non-Text or wrong arity is a fatal type/arity error. - Grants: a new
Capabilities::env: Vec<String>with exact name matching (no glob).--allow-env NAMEadds one grant; un-granted names returnpermission.deniedbefore the OS is read. - The check happens before
std::env::var. Project mode only;pureandstrictrefuse. No default grant. - Missing variables and non-UTF-8 variables are recoverable
env.not_found/env.not_unicode, not fatal errors. - There is no
env.list,env.set, process spawning orstd::env::set_varin this decision. A futureenv.listwould need a separate ADR because it changes the disclosure model. stdlib/env.mq.mdis a thin.mq.mdfacade:读取returns the Result and存在mapsenv.not_foundto{ok:true, value:false}.
Consequences
- The environment is readable only by exact, operator-supplied names in project mode.
- The CLI gains
--allow-env NAME; strict mode rejects it with exit 2. std:processremains unsupported in this decision; process execution needs its own capability and OS-sandbox story.