Repository navigation
Closed
Labels
area:expansionword splitting, quote removal, parameter/brace expansionbugSomething isn't workinggnu-baselineTracked by the GNU Bash 5.3.0 true-baseline ledger
Milestone
Description
[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:
- PR fix(prompt): decode raw-byte transport markers after prompt expansion #2878 (in review): prompt strings decoded
\[/\]template escapes before the embedded-parameter expansion pass, so control bytes introduced by expansion (comsub output, parameter results) reached the PS0/PS1/PS2/PS4 terminal-bound channels still encoded as U+E000-pair PUA markers.
Earlier instances on record (non-exhaustive — completing this list is part of the sweep):
- 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 audit family: the shared decoder asserted on output that turned out to be legitimate user data ("panic family"); leak detection had to be moved out of the decoder to
tests/marker_leak_golden.rs. - [bug] tempenv compound append loses the base value and leaks the internal __RUBASH_CA1__ marker into child environments #1620: spawner re-applied prefix-assignment raw text to the child environment; the internal marker text
__RUBASH_CA1__leaked verbatim to external programs. - [bug] Internal marker strings __RUBASH_CA1__/__RUBASH_HD1__ in user data are consumed as protocol (type change, comsub/read data swallowed, eval deletion) #1634: protocol revision — COMPOUND_ASSIGNMENT_MARKER moved to U+E31A.
- user-typed PUA codepoints collide with the marker registry: ANSI-C E401 is silently swallowed (data loss); E301/E314 miscount as length 2 #735:
$'\uE3xx'registry-zone user data needed E400-escaping at entry. - declare -A name=(...) through the line-editor path panics in debug builds: COMPOUND_ASSIGNMENT_MARKER debug_assert (locale.rs) #802: host
decoded_wordspath had to whitelist a marker the parser legitimately pushes. - patsub 替换文本的用户 PUA 码点未 E400 转义,与 PATSUB 标记碰撞(release 可复现)——#838 CR NIT-3 #843: patsub replacement text needed in-flight E400 escaping + verbatim pair copying.
- [cosmetic] for (( i="1;2" )) 算术错误回显泄漏原始控制字符 0x1c:i=\x1c1;2(GNU 逐字回显 i="1;2)(P3) #548: carrier-byte defense on user-reachable input.
- issue431 prompt_marker_render: baseline reds on real-world theme shapes (bashit/inretio).
Mechanism map (starting point, verify and complete)
- Registry:
src/executor/markers.rs— every marker declared once with producer, decode boundary (Output/Storage/Reparse), and auser_reachableflag. - Sanctioned output decoder:
crate::locale::decode_to_visible_text; echo paths additionally runsubstitution_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 bytests/marker_leak_golden.rs. - Current grep surface on master:
E000appears in 138 lines across 30+ files undersrc/(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
- 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). - 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.
- Entry-encoding audit. For every
user_reachable == truemarker: 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. - 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.
- 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 throughdeclare -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). - 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
- Read-only: no product code changes in this sweep. PR fix(prompt): decode raw-byte transport markers after prompt expansion #2878 is a case fix already in review — treat it as one data point of class (b); do not duplicate or block it. Findings that implicate fix(prompt): decode raw-byte transport markers after prompt expansion #2878's shape get reported, not patched.
- GNU C source is the semantic spec where behavior is compared (
~/workspace/rubash-audit/build-gnu/bash-5.3/, esp. parse.y CTLESC handling + subst.c dequote paths); probes confirm, source decides. - Fix destination: findings split into 1.5.1 simple-fix lanes (per-finding issues) and, if the verdict is structural, a Stage-2 ③ scoping input.
Metadata
Metadata
Assignees
Labels
area:expansionword splitting, quote removal, parameter/brace expansionbugSomething isn't workinggnu-baselineTracked by the GNU Bash 5.3.0 true-baseline ledger
Activity
fix(prompt): decode raw-byte transport markers after prompt expansion (…
caomengxuan666 commentedon Nov 6, 2026
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 inmarkers.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
decode_raw_byte_markers_to_byte_charslacks theLITERAL_CHAR_ESCAPEarm (E1, XS)read -pprompt renders raw-byte pairs; outside PR fix(prompt): decode raw-byte transport markers after prompt expansion #2878's sites (E5, XS–S)__RUBASH_*respawn interpretation stays)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.
fix(2881): fold LITERAL_CHAR_ESCAPE in the boundary byte-char decoder
fix(2881): add the LITERAL_CHAR_ESCAPE arm to the boundary decoder (R…
caomengxuan666 commentedon Nov 9, 2026
关单证据(split-D1 定界,2026-11-09)
本审计单的 55 起发现已全部有独立归宿且归宿单全部关闭,伞形单关单:
\x1c、算术标记的\x01)载体协议本身成立,本单使命完成。
test: cfg-gate unix-only helpers in issue2883 stem with #[cfg(unix)] …