A peer named itself and the log believed it
Every sync line named a peer by ten hex characters, so finding out which laptop pushed those ops meant opening peers.json. Pairing already stores a human name for each device, and printing it is a four-line change. It is also a promotion: that name arrives unvalidated from a peer's pairing payload and from the gossip membership merge, bounded only by the 64 KiB wire cap, and peer list could hold it safely because a user asks for one row while outl serve emits it forever, unattended, into a stream grep parses. A newline in an alias forged a WARN record attributed to another device. An escape sequence cleared a tailing operator's screen. A 64 KiB alias printed 65,549 characters on every pass. Why the filter lives at ingress rather than at the log macro, why it is a blacklist, why the hex is parsed rather than sliced, and why the exemption list had to become a test that counts.
Every sync line in outl serve named a peer b75b908373.
Two laptops on one workspace, and finding out which of them had pushed those fourteen ops meant opening peers.json and matching a hex prefix by eye. Pairing has stored a human name for every device since it shipped: outl peer pair defaults it to the machine’s hostname, outl peer list renders it in a column. Nothing in the log path ever read it.
That is issue #337, reported with a working patch, and implemented in #353 by a contributor. The change is small by any measure: load the peer store, find the entry, print alias next to the hex. A display change.
It is not a display change. It is the moment an unvalidated remote string gets promoted into a context with a completely different set of readers, and the string had been sitting one field away from that context for a year without anybody having to think about it.
peer list is a question, a log is a stream
The alias is not outl’s string. A peer sends its own in its pairing payload, and the gossip membership merge persists one for a device this machine never paired with. Neither path validates it. The only bound on the value is the frame cap on the handshake itself, in crates/outl-sync-iroh/src/pairing.rs:
anyhow::ensure!(len <= 64 * 1024, "pairing payload too large ({len} bytes)");
So: 64 KiB of attacker-chosen bytes, already on disk in peers.json, already being rendered.
outl peer list could hold that safely, and the reason has nothing to do with the string. A user typed a command, got one row back, and is looking at the row. The output is bounded, synchronous, and read by the person who asked for it. If it looks strange, the strangeness is the result.
outl serve has none of those properties. It emits the same value continuously, on every sync pass, into a stream that grep reads, that journalctl reads, that a log shipper parses by line, and that an operator tails on a machine where nothing else is happening. Same bytes. Different contract with the reader, and the reader is now a parser.
one record, because every reader counts lines
Measured before the fix, with an alias of:
laptop
2026-10-09T12:00:00.000000Z WARN outl_sync_iroh::authz: refusing an unknown / revoked peer
That produced a genuine second log record, correctly formatted, plausible, and attributed to a device that never did anything. Read the log back in order and there is no seam. The pinning test is an_alias_cannot_forge_a_second_log_line, and it asserts on \r as well, because a carriage return re-anchors the line for a terminal just as well as a newline does for grep.
Second: \x1b[2J\x1b[H cleared the screen of whoever was tailing. The audience for these lines is an operator watching outl serve, which is to say the log’s entire readership is sitting in a terminal that interprets escape sequences.
Third, and the dullest of the three: a 64 KiB alias printed 65,549 characters per line. On every pass. Forever.
None of these are exotic. They are what an unbounded remote string does when you point it at a terminal, and the only reason they were not reachable yesterday is that nobody printed the field.
the subscriber escapes the message, and the peer field is not the message
The obvious place to fix this is one layer down. Let the log layer escape what it emits, and the value stops mattering.
That does not work here, and the detail is worth checking rather than assuming. Against tracing-subscriber 0.3.23, the version pinned in Cargo.lock, the escaping guard wraps the message field only. The consequence is that two spellings of the same log call behave differently:
info!(peer = %label, "…")puts the label in a structured field and emits raw escape bytes.info!("… {label}")puts it in the message and escapes them.- Neither form escapes
\n, so the forged record gets through both.
And both spellings exist, in one function. This is the boot connect in crates/outl-sync-iroh/src/engine.rs:
info!(
peer = %label,
has_direct_addrs = has_direct,
"boot: connecting to peer for initial sync"
);
followed twenty lines later by:
info!("boot: initial sync to {label} ok");
A fix that lives at the macro has to be right at every call site, in a crate where the two shapes sit in the same spawn, and where the next log line somebody adds will pick whichever one reads better that day. So the escape lives on the value instead, and the value has exactly one producer.
a blacklist, because a whitelist mangles a real hostname
The whole filter is nine lines in crates/outl-sync-iroh/src/peer_label.rs:
pub fn sanitize_alias(alias: Option<&str>) -> Option<String> {
let kept = alias?.chars().filter(|c| {
!c.is_control()
&& !matches!(
c,
'\u{200e}' | '\u{200f}' | '\u{2066}'..='\u{2069}' | '\u{202a}'..='\u{202e}'
)
});
let mut out: String = kept.clone().take(MAX_ALIAS_CHARS).collect();
if kept.count() > MAX_ALIAS_CHARS {
out.push('\u{2026}');
}
let trimmed = out.trim();
(!trimmed.is_empty()).then(|| trimmed.to_string())
}
char::is_control covers the newline, the carriage return and the ESC that starts every terminal sequence. The second group is the one that is easy to leave out: those code points are not control characters by any predicate, and they reorder rendered text. That is the trojan-source trick aimed at a log instead of at source code, and an_alias_cannot_reorder_the_line_with_bidi_overrides pins it with mac\u{202e}gnp.eqri, which renders as something quite different from what it is.
Everything else survives, deliberately. The alias defaults to the machine’s hostname, and a hostname can legitimately be josé-pro, のーとぶっく or mac 🍎. Those four are a test, a_legitimate_non_ascii_alias_survives_intact, because an allowlist that mangles a real device name defeats the purpose of the change: the operator is reading this line to match it against a laptop on their desk.
One ordering detail carries more than it looks like. The emptiness check runs on the sanitized string, not the original, which is what makes an alias of nothing but newlines fall through to the bare hex rather than rendering as " (b75b908373)". A leading space and a parenthesised id is strictly worse than the hex it replaced, and it is what you get if you check is_empty() first. an_alias_that_sanitizes_to_nothing_falls_back_to_hex is there so that stays true.
at ingress as well as at the render, and only one of them is retroactive
sanitize_alias is called in three places, and that is on purpose rather than by accident. The function says so itself:
/// **Call this where an alias enters, as well as where it is shown.** The two
/// are not interchangeable: sanitizing at the boundary keeps hostile text out of
/// `peers.json` from here on, and sanitizing at the render is what covers a file
/// an older binary already wrote. Both callers are cheap; only one of them is
/// retroactive.
The two ingress points are PairingPayload::into_peer_entry in crates/outl-sync-iroh/src/pairing.rs, which is the handshake, and PeersStore::merge_unknown in crates/outl-sync-iroh/src/peers.rs, which is the gossip membership merge. The render side is the label itself. Picking either one alone gets you a defensible-sounding answer and a gap: boundary-only leaves every peers.json written by an older build hostile, and render-only leaves the hostile bytes sitting in the credential store for whatever reads it next.
ten characters, because eight matches neither log
The label is macbook-pro (b75b908373): the alias plus the hex the line always carried. That pairing is the entire point, and it is the part a redesign would casually drop.
A user who greps a hex prefix out of last week’s log has to still hit this week’s aliased line. So the hex is ten characters, matching iroh’s fmt_short() byte for byte, pinned by the_short_hex_matches_iroh_fmt_short. The first implementation used eight, which matches neither the old lines nor outl peer status, and the mismatch is invisible until somebody’s grep returns nothing and they conclude the device stopped syncing.
The hex is also parsed out of the stored id rather than sliced off the front of it:
fn short_hex(node_id: &str) -> String {
node_id
.parse::<iroh::EndpointId>()
.map(|id| id.fmt_short().to_string())
.unwrap_or_else(|_| node_id.chars().take(SHORT_HEX_LEN).collect())
}
Two reasons, and both are things that actually happen in this codebase. EndpointId::from_str accepts BASE32_NOPAD as well as hex, and base32 is not hypothetical here: lan::instance_label publishes the id that way over DNS-SD, because 64 hex characters is one byte over RFC 6763’s cap on a DNS label. That is the same one-byte margin that made LAN discovery work in one direction only, and the permissiveness of from_str is exactly what made that failure silent. An id in that spelling, hand-edited or foreign, would under a slice print ten characters that are not hex and match nothing else in the log, while the unlisted-peer fallback, which holds a parsed id, printed the real one. Two sources for one fact, disagreeing precisely where the log line is the only evidence you have.
The fallback is chars, not bytes, because &str[..10] panics on a multibyte boundary. an_unparseable_stored_id_truncates_without_panicking feeds it héllo-wörld-not-an-id and expects héllo-wörl. A damaged peers.json is not worth taking a log line down over.
the exemption list failed on its first pass
Not every fmt_short() in the crate should become a label, and three groups stay on bare hex for reasons that are verdicts rather than oversights: this device’s own node id, since peers.json lists the other devices; a dialer authz just refused, which is refused because it is unlisted; and SyncProgress.peer, which is a wire field.
That third one has teeth. The desktop resolves aliases client-side, in crates/outl-frontend-shared/src/peers/SyncProgressView.tsx:
const match = peers.find((p) => p.node_id.startsWith(shortId));
Widen that value to macbook-pro (b75b908373) and the prefix match silently stops matching. So engine_sync.rs, engine_snapshot.rs and engine_assets.rs each keep a peer_short beside a label, two renderings of one peer in one function, which reads as sloppiness unless something writes down why.
I wrote that list in prose. It did not survive its own pull request.
crates/outl-sync-iroh/src/engine_assets.rs reused its wire-field peer_short in three log lines, while its byte-identical sibling engine_snapshot::pull_snapshot_from_peer was converted. One of the three:
if outl_md::asset::hash_bytes(body) != claimed_hash(name) {
warn!("asset pull: {name} from {label} failed content-hash check; discarding");
continue;
}
That is the line that fires when a peer serves bytes that are not what their content hash claims. It is the single line in the crate an operator most needs pinned to a machine, and in the first pass of a change whose entire subject was pinning lines to machines, it named nobody. Nothing failed. A reviewer noticed.
So the list stopped being prose and became every_fmt_short_in_this_crate_is_an_accounted_for_exemption: a table of file, count, and reason, walked against the crate’s own source.
("engine_assets.rs", 3, "2 in `connect_asset` (no path in scope), 1 is the `SyncProgress` wire field"),
It counts rather than just listing names, and that is the part worth stealing. Every file still on the list is there for a reason that covers only the sites it has today, so a name-only check would wave through a fourth hex-named peer in engine_assets.rs, which is the exact change this exists to stop. It is coarse and it fails for the right reason: changing a count is allowed, and the test tells you to say which group the new site joins.
The shape is borrowed from bind.rs, where a scan of the crate is what keeps every endpoint binding through the one owner, including the line I started adding to every test of this shape after that one:
assert!(scanned > 1, "the scan found no source files to check");
A scan that reads nothing passes, and a vacuous pass is worse than no test, because a missing test is an open question and a green one is a closed one.
what it cost
The lazy form of the label reads peers.json inside fmt::Display::fmt. That is a real win: tracing only calls Display once a subscriber has accepted the event, so a filtered-out line and a quiet sync pass both cost zero reads.
It also put blocking file I/O back on the async task, in the worst available spot. The SYNC_ALPN handler has a comment that predates all of this:
// Nothing may run between the fsync above and this line. Every
// instruction here is time in which a peer whose OS is suspending it
// (a locked iPhone, a dozing Android) dies *after* durably ingesting
// but *before* confirming — a false negative that costs the initiator
// a redundant re-push and paints the user's Sync panel amber. The
// `peers.json` refresh below used to sit here, and it is blocking file
// I/O on the async task.
A peers.json read had already been moved out of that window once. Resolving a label at the info! put a different peers.json read straight back into it, and the diff looked like nothing at all, because the read is invisible at the call site: it hides inside a Display impl that exists to make the call site short. It now resolves inside the spawn_blocking that was already there, which is the same rule as keeping a keystroke off the disk, applied to a confirmation packet instead of a cursor.
The other costs are smaller and stated rather than fixed. display_label_at reloads the peer store per call, which outl sync’s summary pays once per peer on a handful of sub-KB reads; a caller looping over many peers is told to load the store once and use display_label_in. And the alias is the name the peer sent, so changing how a device shows up in your log means re-pairing from that machine with outl peer pair --name, which is documented rather than solved.
The honest gap is upstream of all of it. The membership gossip merge can still manufacture an entry for a device nobody paired, because the workspace id is not a secret and a gossip message carries no proof of authorship. That is pinned, not closed, by an ignored test called gossip_can_manufacture_an_authorized_peer. Sanitizing on that path bounds what such an entry can do to a log line. It does not decide who may be in the file, and I would rather say that plainly than let a filter stand in for a trust decision it was never asked to make.
The lesson isn’t that human names in logs are dangerous. It’s that a string’s safety is a property of where it gets printed and never of the string: peer list and outl serve were handed the same bytes, and only one of them had a reader that counts lines. Moving a value from a command somebody runs into a stream a machine parses is a new input on a new surface, and it earns the review a new input gets, not the review a display change gets.
The module, and the exemption table it enforces, is crates/outl-sync-iroh/src/peer_label.rs.