Status: Accepted
Date: November 14, 2026
Answers: the log-injection consumer ADR-010 D8 left to be
decided on its own; what ADR-397 D3 and ADR-365
leave a value from outside to do when it is written to a log
Related: ADR-010 D2, D3, D7, D8 (the sources, the marker,
--trust, the further consumers); ADR-017 (escaping at a
template hole, unconditional); ADR-346 D6 (a detached task’s
error goes to the log); ADR-365, ADR-397
(standard input, files, the environment); Part I 1 (the prelude’s printing
functions), Part III 17.1
let name = io::read_to_string().trim() // untrusted (ADR-365)
eprintln(f"login failed for {name}")
A service’s log is its standard error: the journal, a container’s log
driver and 2> app.log all read it line by line. If name is
"x\nlogin ok for admin", the log shows two lines and the second is a
forgery. If it holds ESC ] 0 ; or ESC [ 2 J, a terminal that shows the
log is retitled or cleared; a bidirectional override (U+202E) makes the line
read otherwise than it is. ADR-010 D8 built provenance as a mechanism so that
this consumer could be decided on its own; ADR-397 D3 sends the environment
where untrusted data goes and found the log consumer still open. The owner
decided on November 14, 2026 that data from outside is escaped where it goes
into a log, for every source alike.
| Option | Why it lost | See |
|---|---|---|
| Escape every value written to standard error, whatever its provenance | a program’s own multi-line message, a usage text or a table it built, comes out as one line of \n; the cost falls on what is safe |
D3 |
Refuse untrusted text at eprint (an error code) |
writing the bad input to the log is the main reason to log it | D2 |
| Escape standard output as well, or only when it is a terminal | standard output is the program’s data: a filter that copies its input must copy it byte for byte, and what it writes must not change with where it goes (owner, November 14, 2026) | D1 |
Leave it to the program (text::escape_control and discipline) |
the forgotten call is the hole; ADR-017’s lesson that escaping is the sink’s contract, not the caller’s | D2 |
These are the log’s sinks:
eprint and eprintln;panic and of a failed assert;std or an official package offers later.Standard output (print, println), a file, a socket and a child’s
arguments are data. Their consumers (a query, a page, a header) are decided
each on its own, as ADR-010 D8 has it, and this ADR does not touch them.
Untrusted text that reaches a sink is written with these characters escaped:
The form is the one a Nikaia string literal uses: \n, \r, \t, \\, and
\u{1b} for any other. A value from outside then stays on its line: it
cannot begin a line of its own, and it cannot steer a terminal or turn a
line’s reading direction. The program is not refused anything; the sink does
the work, as a template hole does (ADR-017).
The compiler knows each value’s provenance (ADR-010 D2, Part III 17.1) and decides at the call which text it escapes:
Trusted text is written as it is, so a program’s own multi-line message
stays multi-line. trusted: true at a source (ADR-010 D3) also covers this
consumer; the ledger already records each marker.
text::escape_control(s: String) -> String gives D2’s escaping, for a
program that writes its own log file or its own log sink. The sinks of D1 do
not need it. What it returns counts as trusted, so a sink does not escape it
a second time.
--trust (ADR-010 D7) lists every sink call that escapes and the source that
made its text untrusted, as it lists the hasher of every map.
trusted: true would be an XSS hole
(ADR-010 D8). Escaping everything would spoil the program’s own
diagnostics to guard text the program wrote itself.eprint and eprintln that untrusted text is written
escaped (ADR-398); Part III 17.1 names the log as a consumer of
provenance. ADR-010 D8 records the consumer as decided; ADR-397 D3’s
“still open” is answered.std (written in Nikaia), the long form’s escaping,
text::escape_control, --trust’s list, tests.trusted: true where the source is known.Standard output is not escaped, not even when it is a terminal (owner,
November 14, 2026): an escape sequence in data a program prints is the
program’s data. Not decided here: structured log formats (a JSON log
escapes by its own grammar); a std::log module.
Decided November 14, 2026.