Repository navigation
fix(#824): decode-boundary leak asserts fired on user-literal marker text (HD1 in declare -p, guard in xtrace) - #838
Merged
Merged
Conversation
…decode boundary (#824) User-literal text panicked debug builds at two more decode boundaries after #802 (marker entry-inventory leak, same #729 methodology): - x=a__RUBASH_HD1__b; declare -p x -> QUOTED_HEREDOC_MARKER leaked to output (declare -p value rendering feeds stored user data through decode_to_visible_text; the named ASCII marker is typeable text). - set -x; v=$'\uE314Z'; echo "$v" -> PARAM_WORD_BACKSLASH_GUARD leaked to output (xtrace carries the user's own U+E314 char, restored verbatim through the E400 literal-char escape, rubash#735). Root cause (one class, one boundary): every output-side debug_assert in decode_to_visible_text read 'registered codepoint in output => decode failed', but the #729 carrier-consumer audit shows every registered codepoint has a legitimate user-data path to that output: C0 bytes ride raw-byte pairs, registry-zone PUA chars ride the E400 escape, named ASCII markers are simply typeable. The asserts could only ever fire on well-formed user data; the scan arms (which consume/decode every bare marker in-pass) are the actual protocol enforcement, and the integration leak tests (marker-free inputs) are the actual leak gate. Fix: remove the assert block, document the per-family output contract, and record the two display entries (declare -p value rendering, xtrace word rendering) as whitelisted in the markers.rs 3.2 boundary table. The __RUBASH_CA1__ consume probe (#802) is untouched; non-debug bytes are unchanged (release rebuild re-diffed against GNU bash 5.3.0 via the WSL stdin oracle: byte-identical on every repro and lookalike shape, and post-fix debug output equals pre-fix release output hash-for-hash). Mechanism: no CI lane ran marker_leak_golden (the only suite feeding user-literal marker text to the decode boundaries) and the in-binary asserts self-disable under cfg!(test) — the panic family never met a gate. The rust CI job now runs marker_leak_golden plus the new issue824 repro suite as a hard gate. Regressions: tests/issue824_marker_decode_boundary_regressions.rs (8 end-to-end cases pinning GNU-oracle bytes: both sites, CSB1, C0 byte, PUA sentinels, HD1 lookalike, echo path, CA1 stance) and three decoder units in tests/decode_to_visible_text.rs.
Member
Author
CR 结论:APPROVE-WITH-NITS(PR #838,d41be1ff)独立评审代理实做复核(自建 worktree、自建 debug/release 双构建、逐字节比对、全量双向测试对比)。无 BLOCKER,可合并;NIT 均不阻塞,可随后续小提交处理。 逐验证点
NIT(非阻塞)
红线核查:评审全程未杀任何进程、未触碰 rubash-wt-830 / rubash-wt-824 / 824-base / 主检出。 |
…aims the removed golden assertion (drop output-side asserts per #824)
This was referenced Oct 19, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #824. Two commits' worth of scope in one: the shared-decoder fix, the #729 entry-inventory update, and the CI gate mechanism.
Site 1 - HD1 through declare -p value rendering
x=a__RUBASH_HD1__b; declare -p xpanicked a debug build:QUOTED_HEREDOC_MARKER leaked to output(src/locale.rs). Thedeclare -ppath feeds stored values throughdecode_to_visible_text(builtins/declare/storage.rsdisplay_text/quote_array_element_value), and__RUBASH_HD1__is plain typeable ASCII - the user's own data. The golden assert at the decoder's output read "named marker in output => decode failed", but a live HD1 tag is consumed at heredoc-body execution before anything is stored or displayed, so an occurrence on this boundary is user data by contract. Same entry firedCOMSUB_PAYLOAD_PREFIX leakedfor typedx='__RUBASH_CSB1_41;'. GNU bash 5.3.0 (WSL stdin oracle) prints both texts verbatim; so did rubash in release - only the debug assert was wrong.Site 2 - guard sentinel through xtrace
set -x; v=$'\uE314Z'; echo "$v"panicked a debug build:PARAM_WORD_BACKSLASH_GUARD leaked to output. The U+E314 char is the user's own data, E400 literal-char-escaped at entry (rubash#735) and restored verbatim by the decode's E400 arm - exactly what the existing (failing-on-base)xtrace_carries_no_markerschild asserts. A bare guard cannot survive the scan (the guard arm consumes each guard with its protected char), so a guard codepoint in the decoder's output is by construction restored user data, never a live guard. The issue'sv='a\$b'shorthand maps to this same pre-existing base failure (xtrace_carries_no_markers); the plaina\$bshape itself does not panic on current master.One class, one boundary - the #729 audit
Both sites are the same unsound pattern: sixteen output-side
debug_assert!s indecode_to_visible_textover codepoints every one of which has a legitimate user-data path to that output (C0 bytes ride raw-byte pairs per the registryuser_reachablecontract; registry-zone PUA chars ride the E400 escape, #735; named ASCII markers are typeable). The audit (ticket methodology: #729 inventory, #823 CA1 precedent) removed the whole block - consume/whitelist/guard decision per family:__RUBASH_HD1__/__RUBASH_CSB1_: whitelist (pass-through verbatim) - documented in the decoder carrier table.__RUBASH_CA1__: unchanged declare -A name=(...) through the line-editor path panics in debug builds: COMPOUND_ASSIGNMENT_MARKER debug_assert (locale.rs) #802 stance (consumed by the_-gated prefix probe; pinned by a test as a documented GNU divergence).#729 3.2 boundary table rows added (src/executor/markers.rs):
Display value rendering (#824 audit)andDisplay xtrace rendering (#824 audit), both whitelisted; the module golden rule is amended to "marker-FREE input" with leak detection at the integration boundary (tests/marker_leak_golden.rs).Why this class never met a CI gate - mechanism
Debug builds ARE in CI (cargo's dev profile is the default for every
cargo testlane), and the panics fire inside the spawned binary. The gaps were: (1) no CI lane ran--test marker_leak_golden- the only suite feeding user-literal marker text to the decode boundaries (rust job ran only--lib+ continue-on-errorcli_tests; regression runs a different target list); (2) the in-binary asserts self-disable undercfg!(test), so the--liblane could never arm them; (3) there was no in-repo repro of the two ticket shapes at all. Mechanism added: the rust CI job now runscargo nextest run --test marker_leak_golden --test issue824_marker_decode_boundary_regressions --profile cias a hard gate (hermetic, ~0.5s).Verification
tests/issue824_marker_decode_boundary_regressions.rs- 8 end-to-end cases spawning the binary (dev-profile build arms the asserts, so pre-fix code fails these): both ticket sites, CSB1, raw C0 byte via xtrace, E301/E30A/E401 PUA sentinels via declare -p, HD1 lookalike, echo path, CA1 stance. Plus 3 decoder units intests/decode_to_visible_text.rs(pass-through, E400-restored guard data, bare-guard consume).a__RUBASH_CA1__bliterally; pinned asabwith the rationale).--no-fail-fast --test-threads=1, base 992d5c5 vs this branch, bidirectionalcommof the failure sets: zero new failures. The one branch-only name (windows_listing_cache_finds_files_that_appear_but_not_ghosts) and its base-only sibling (windows_nohash_mode_memoizes_hits_but_not_misses) are the executor::path cache timing flake family - each passes 3/3 on rerun in its own tree.marker_leak_golden::xtrace_carries_no_markersfails on base and is fixed on the branch.cargo fmt --checkclean. Rebased on origin/master (992d5c5) - the delta's own suites (parameter_transform_tests etc.) re-verified green.Residuals observed during the audit (pre-existing, non-debug, out of scope - zero-non-debug-change mandate)
arr=($'\uE314Z'); declare -p arrrenders the E400 introducer in the array element (GNU prints the bare char): a double-escape/restore gap in the array-element storage path.__RUBASH_CSB1_41;through printf%sdecodes to its payload byte (aAwhere GNU prints the literal): the comsub-payload decode consumes user-typed prefix text.$'\uE30D'is eaten by the assignment-tail unescape (GNU prints the char).Each is a non-debug data-shape divergence of the same "marker vs user text indistinguishable" family and deserves its own ticket.