Skip to content

[audit] Systematic sweep of the C0/PUA carrier protocol (markers.rs) — the recurring ESC/control-byte incident family #2879

Closed

Description

@caomengxuan666

[audit] Systematic sweep of the C0/PUA carrier protocol — the recurring ESC/control-byte incident family

Why this exists

The in-band carrier protocol declared in src/executor/markers.rs (1,740 lines; C0/PUA codepoints standing in for GNU's CTLESC/CTLNUL scheme, which cannot be reused because 0x01/0x7f are user-reachable in our transport text) keeps producing incidents — by the owner's count, the ESC/control-byte face of this family has surfaced dozens of times, each fixed case-by-case, never eradicated. The latest instance is in flight right now:

Earlier instances on record (non-exhaustive — completing this list is part of the sweep):

Mechanism map (starting point, verify and complete)

  • Registry: src/executor/markers.rs — every marker declared once with producer, decode boundary (Output / Storage / Reparse), and a user_reachable flag.
  • Sanctioned output decoder: crate::locale::decode_to_visible_text; echo paths additionally run substitution_metadata::decode_raw_byte_markers.
  • Golden rule (post-marker debug_assert family: user-literal text panics debug builds at two more decode boundaries (HD1 in declare -p; PARAM_WORD_BACKSLASH_GUARD in xtrace) #824): on marker-free input, no registry codepoint may appear in stdout / declare -p / xtrace — asserted only by tests/marker_leak_golden.rs.
  • Current grep surface on master: E000 appears in 138 lines across 30+ files under src/ (executor, builtins, api, debugger, console_readline). niubash side: 1 hit (shell.rs) — the protocol is engine-side, its failures surface at host boundaries (prompt rendering, PTY transcripts).

Audit tasks

  1. Boundary census. For every registered marker: enumerate every producer site and every consumer/output site, and mark whether the path passes the sanctioned decoder for its declared boundary. Output channels to cover exhaustively: all printing builtins, prompt strings (PS0/1/2/4 + PROMPT_COMMAND), xtrace, error/diagnostic messages, job notifications, completion candidates, declare -p / typeset -p, printf, read -p, history file writes, dump-strings / host AST inspection, child-process env/argv (external boundary).
  2. Decode-order audit. The fix(prompt): decode raw-byte transport markers after prompt expansion #2878 class: any place that decodes before a later pass can introduce new control bytes (expansion, comsub, substitution), or encodes after a pass that needed the raw form. List every decode/encode call site in pipeline order per channel.
  3. Entry-encoding audit. For every user_reachable == true marker: verify every entry point that produces transport text actually pair-encodes the user byte (the user-typed PUA codepoints collide with the marker registry: ANSI-C E401 is silently swallowed (data loss); E301/E314 miscount as length 2 #735/[cosmetic] for (( i="1;2" )) 算术错误回显泄漏原始控制字符 0x1c:i=\x1c1;2(GNU 逐字回显 i="1;2)(P3) #548 class). Grep-driven + spot-verified.
  4. Decoder-assertion audit. The marker debug_assert family: user-literal text panics debug builds at two more decode boundaries (HD1 in declare -p; PARAM_WORD_BACKSLASH_GUARD in xtrace) #824 class: any remaining place where a decoder/assert can fire on well-formed user data that legitimately contains registry codepoints.
  5. Differential probe battery. Marker-adjacent inputs (literal ESC and C0 bytes, $'\uE0xx'–$'\uE4xx' literals, raw bytes in comsub output, control bytes introduced by parameter expansion into prompts, markers in stored values round-tripped through declare -p, env export to a real external /usr/bin/env) × every channel from task 1, rubash vs GNU bash 5.3.20, byte-level comparison. Probes use the job-control-parent PTY harness where a terminal is involved (never orphaned-pgrp).
  6. Incident archaeology. Mine open+closed issues/PRs for the full family history; classify each incident into: (a) missing decode at a boundary, (b) decode order/timing, (c) missing entry encoding, (d) decoder asserting on user data, (e) leak to external processes, (f) other. The class histogram is a required deliverable — it decides the verdict.

Deliverable and verdict

A REPORT (workdir ~/workspace/pua-audit/) containing: the census tables (tasks 1–3), the assertion list (task 4), probe battery results (task 5), the incident classification (task 6), and a verdict:

  • If the protocol is sound but enforcement is incomplete → list the precise enforcement fixes (lint/gate/test additions + the missing decoders), sized as 1.5.1 simple-fix lanes.
  • If the carrier design itself is the recurring source → say so with evidence, and scope the structural alternative (e.g. typed segments instead of in-band carriers) as a Stage-2 project ③ input. No bridge fixes.

Boundaries

Activity

  1. added this to the 1.5.1 milestone on Nov 6, 2026
  2. added
    bug
    gnu-baseline
    area:expansion
    on Nov 6, 2026
  3. caomengxuan666 commented on Nov 6, 2026

    @caomengxuan666
    MemberAuthor

    Sweep complete — verdict: protocol sound but under-enforced

    Full report: ~/workspace/pua-audit/REPORT.md (captain-read in full; F1 root asymmetry, F2 repro, and F6 symptom 1 spot-verified independently by the captain).

    Evidence. 65-marker registry census (plus the unregistered ~40-name __RUBASH_* env namespace, only 7 in markers.rs); probe battery 52/58 script cells byte-exact vs GNU 5.3.20, every registry codepoint as user data clean through comsub/patsub/assoc/heredoc/eval/history; 55 marker-attributable incidents classified: (a) missing decode 22, (f) transport-into-views/enforcement 13, (c) entry encoding 7, (e) external leak 6, (d) decoder asserts 4 (extinct since the #824 protocol decision), (b) decode order 3.

    Reading. The two genuinely design-level classes were killed by protocol revisions and never recurred (ASCII markers → #1634's PUA revision; asserts → #824). Every live failure localizes to a named unenrolled consumer, channel, or entry point. (a)+(f) = 64% and both are enrollment failures: #729 censused this before and incidents continued, because a census is not a gate. The fix list is therefore gates-first (E6/E7 load-bearing); if gates are judged not credible, the report's §8 scopes the structural alternative (typed text segments at the value boundaries) as a Stage-2 ③ input.

    Findings filed

    F3 note

    PR #2878 (the class-(b) prompt fix) was captain-reviewed and merged 2026-11-06 (a412873) on its own full-green CI, just before this report landed. The sweep's c21 + PTY s1–s3 confirmations were run against pre-fix master; the post-merge acceptance run — those cells plus the open Q1 cell (U+E401 carried by a value into a rendered prompt; #2878's decode covers raw-byte pairs only) — is tracked as item E9 in #2885.

    This issue stays open until the captain accepts the sweep's filing set; the enforcement work itself lives in #2885.

  4. caomengxuan666 commented on Nov 9, 2026

    @caomengxuan666
    MemberAuthor

    关单证据(split-D1 定界,2026-11-09)

    本审计单的 55 起发现已全部有独立归宿且归宿单全部关闭,伞形单关单:

    载体协议本身成立,本单使命完成。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

area:expansionbuggnu-baseline

Type

No type

Projects

No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions