Repository navigation
Description
Summary
The governance §3.1 golden leak assertion — the gate that exists to prove no transport marker reaches stdout / declare -p / xtrace — scans the wrong UTF-8 lead byte. It therefore cannot see any registered marker, and instead fires on a PUA block the registry does not use.
The code
tests/marker_leak_golden.rs:21-30
fn assert_no_pua_marker(out: &[u8], ctx: &str) {
// U+E000..U+EFFF encodes as EF 80 80 .. EF BF BF; the registry zone is
// a subset but any private-use char reaching stdout is a leak signal.
for w in out.windows(3) {
if w[0] == 0xEF && (0x80..=0xBF).contains(&w[1]) {
let cp = 0xE000 + (((w[1] & 0x3F) as u32) << 6) + ((w[2] & 0x3F) as u32);The header comment (line 7) repeats it: "PUA codepoints (registry zone U+E000..=U+E3FF, UTF-8 lead EF 80..8F)".
UTF-8 disagrees
U+E000 -> ee 80 80
U+E3FF -> ee 8f bf
U+E400 -> ee 90 80
U+EFFF -> ee bf bf
U+F000 -> ef 80 80 <-- 0xEF starts here
The whole U+E000..=U+EFFF plane is lead byte 0xEE. Lead byte 0xEF is U+F000..=U+FFFF — a different private-use block that the registry does not use.
So both the predicate and its comments encode the range wrong: EF 80 80 decodes to U+F000, not U+E000.
Consequences
- Every registered marker is invisible to this assertion. Registry markers are
U+E000-based (E10A,E301,E314,E400, …) — all0xEE-led. - The codepoint recomputation is off by the same amount (
0xE000 + …while matching a0xEFlead), so even when the 0xEF branch is taken the printedU+…is wrong by+0x1000. - The assertion can only fire on user data in
U+F000..=U+FFFF— i.e. the false-positive path, not the leak path.
It contradicts the predicate in the same tree
src/executor/markers.rs:405-409:
/// … or the UTF-8 lead byte 0xEE of the U+E000..U+EFFF PUA
/// plane hosting the ANSI-C markers. …
pub(in crate::executor) fn contains_word_marker_bytes(value: &str) -> bool {
value.bytes().any(|byte| (0x11..=0x1f).contains(&byte) || byte == 0xEE)
}The predicate uses 0xEE; the golden assertion uses 0xEF. One of the two is wrong, and the one that is supposed to be the backstop is the wrong one.
Suggested fix
Match 0xEE (and keep the lead-byte check before recomputing the codepoint). Worth then asserting that the known-leak repros actually trip it — $'\x1f' through echo, and $'\uE301' through the xtrace path. Right now they cannot, so the test would stay green through exactly the regression it exists to catch.
Provenance
Source-level reading, verified against the UTF-8 encoding table above; not a runtime repro. carrier audit pass on origin/master (d24ee0f0).
Activity
fix: heredoc delimiter quote removal, shopt -O listing, marker-leak p…
caomengxuan666 commentedon Oct 17, 2026
修了,提交
3f2275a。你说得对,两个里错的是断言:U+E000..=U+EFFF 的 UTF-8 引导字节是 0xEE,0xEF 是 U+F000 区。断言原来扫 0xEF,所以任何注册 marker 都看不见,只会被用户数据触发;
0xE000 + ...的码点重算也差 0x1000。现在改成
w[0] == 0xEE(和markers.rs::contains_word_marker_bytes同一判据),注释里的区间也改对了(注册表目前最高 U+E401)。加了两个自测:喂 U+E301 必须 panic、喂 U+F000 必须不 panic。一个连带发现:断言真能看见之后,
xtrace_carries_no_markers里那个"PUA 用户数据必须原样 trace"的分支挂了——它本身就在往输出里写 U+E314,却调了assert_clean(禁止出现 PUA)。旧断言瞎着,所以一直空过。那个分支改成断言"每个被 trace 的词恰好一个 U+E314、没有 E400 转义、没有__RUBASH_",这才是它想验证的东西。顺带说明:因为注册区间的码点会作为用户数据合法出现,这类断言只适用于输入里没有 PUA 的用例。