Repository navigation
fix(rust): refuse owner pin expected values a macro or static rebinds (#7847) - #8597
Conversation
…#7847) Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193fZVBGjXWpxEYFUzBGCYt
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
|
Warning Review limit reachedEnable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
Reviews can continue after your included limit without a manual trigger. An admin must approve usage-based billing. Next included review available in 39 minutes. View limit details
Comment |
There was a problem hiding this comment.
Confirmed findings
- crates/ripr/src/analysis/classify/owner_pin.rs:9667 — Add a control test asserting
written_by_testreturns false on plainlet name = rhs;wherenameimmediately followslet, and aEXPECTED = rhs;(no method, plain identifier) case to lock the lexical pre-trim exemption; today only positive cases are exercised in the new test. - Lexical scanner is fail-closed by design (PR body and code comment agree). Strongest plausible false-positive vector -- a
&mut nameon the RHS of a macro that bound_by_macro already refuses -- collapses to a single refusal, so no double-counting nor false admission is introduced. Resolved check.
Verification questions
- Confirm written_by_test covers assignment, &mut borrow, compound assign, and 22 mutating methods plus mut/fetch/set_* suffixes; conservative lexical scan.
- Confirm unit_tests test harness in owner_pin/tests.rs only feeds the prelude+body pair into the scan; the new macro test relies on macro_rules! expansion at parse time, which unit_tests does not perform. If macro expansion is what makes 'let expected = weight(4)' visible, sibling 'let-only' controls in the same test confirm that bound_by_macro is the active branch, not written_by_test. Worth a unit probe.
- Confirm oracle covers macro-rebind and Atomic/static-mut writes plus positive let + read-only static, exercising refuse/admit parity through path_admitted.
Refuted
- The raw allocator (
Box<[u8]>::fromstyle) may silently return None or an empty box on OOM in the new lexical scan paths, hiding failures.; refuted because: Both new functions (written_by_test,bound_by_test-style macro probe) work entirely on borrowed&strof the masked body -- no heap allocation, no Box::from conversion in the patched region. Allocation-failure mode does not apply to this diff. - The new
written_by_testmutator-name list or method-prefix matching (*_mut,fetch_*,set_*) could misclassify a buffer/view's active length and skew the owner pin.; refuted because: Function is purely string-level: it inspects identifiers around an expected word viawhole_word_offsetsand a const MUTATORS slice, with no buffer, view, length field, or resize operation. There is no active-view state to be stale. Active-view UB preconditions are absent. - PR diff is a lexical owner-pin classifier addition (bound_by_macro + written_by_test); no active-view or resizable-buffer surface touched, so lane UB scope is inapplicable.
- written_by_test could grow lifetime/aliasing UB by introducing a borrowed &mut name or method dispatch through a static; refuted because: The function is a pure lexical scan over
masked_bodyslices with no Rust ownership semantics;&mut namedetection is a substring check onbefore, not an actual borrow. Memory-lifetime is not engaged by the classifier path itself.
Evidence gaps
- Validation gap: author states shared box OOMs on lib-test compile; only 'cargo fmt --check' and 'cargo check -p ripr --lib --tests -j1' ran locally; new test, cargo xtask precommit, and goldens rely on hosted CI. Lane cannot witness red/green locally.
- Author's own admission: validation gap -- shared box OOMs on lib-test compiles, only
cargo fmt --checkandcargo check -p ripr --lib --tests -j1ran locally; new test,cargo xtask precommit, and goldens rely on hosted CI, which is the only place lexical over-refusal would surface. - Model proof intent was rejected by deterministic validation.
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
…ed type (#7847) written_by_test treated `let e: Config = ..` as an assignment to `Config`, withholding credit from a typed independent expected binding. A name preceded by a single `:` is a type or field label, not a write target. The lib regression used bare `weight(4)` without importing the owner, so its positive cases were vacuous and its controls could never admit; use `crate::weight` and add a typed-let control. The positive cases fail on the pre-fix production code. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193fZVBGjXWpxEYFUzBGCYt
|
Warning You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again! |
…rs; scope let-annotation skip (#7847) written_by_test now follows a place chain (.field, .0, [i], calls) to an assignment or a mutating call, widens the mutator set, and skips a ':' only inside a let pattern annotation so a struct-literal field value stays scanned. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193fZVBGjXWpxEYFUzBGCYt
There was a problem hiding this comment.
Confirmed findings
- crates/ripr/src/analysis/classify/owner_pin.rs:10240 — Collapse the duplicated mutator table in
is_mutating_method: the exact-name MUTATORS array and the trailing prefix/suffix arrays overlap on fill/drain/retain/extend/insert/remove/or_insert/get_or_insert/dedup/swap_remove/pop/clone_from/store/set. One source of truth (e.g. MUTATORS only, with_mut,_assign,fetch_,set_as the only pattern matches) removes a maintenance trap and keeps behaviour identical.
Verification questions
- Confirm is_mutating_method duplicates method lists: an exact-name MUTATORS array and a separate prefix/suffix check both fire.
fill,drain,retain,extend,insert,remove,or_insert,get_or_insert,dedup,swap_remove,popappear in MUTATORS whilefill,drain,retain,extend,insert,remove,or_insert,get_or_insert,dedup,swap_are also prefix matches. Suffix groups_mut,_assignplus prefixescopy_,clone_from,fetch_*,set_*overlap with MUTATORS names (clone_from,store,set). Functionally equivalent but a maintenance hazard. - Confirm coverage is positive-only for the trim exemption: written_by_test returning false on a plain
let name = rhs;with no annotation, and on a plain identifier assignmentEXPECTED = rhs;(no method, no field), is asserted only by inference from the 3 admitted controls — there is no explicitassert!(!written_by_test(..))test or negativepath_admitted.len()==0for the independent-let case. - Confirm mutator prefix list duplicates MUTATORS entries (push/pop/sort/fill/drain/retain/extend/insert/copy_/clone_from/remove/or_insert/get_or_insert/dedup/swap_) and
*_assignsuffix matches benign names likefn_contains_assign. Fail-closed design treats every hit as mutation; reduncant list is harmless but suggests the two checks were meant to be the single source of truth. - Confirm prior review correctly asked whether
written_by_testcovers every mutating shape; suite exercises store/swap/fill/field/.0/index, but does not exercise&mut expected,+=/-=/*=compound assigns,let mut expected = ..; expected.sort();on a bare call, or*_assign/fetch_*/set_*method families named in the scanner.
Refuted
- expected_binding_calls_owner introduces a worker/async/GC handoff that can tear the masked test body and make the rebind scan observe stale bytes; refuted because: All new helpers (
written_by_test,place_is_written,skip_balanced,in_let_annotation,bound_by_macro) operate on borrowed&strwith no shared/threaded handle, no JS bridge, no async yield, no detaching transfer, and no allocator crossing; closure capture is by&borrow and the masked string is fully owned and stack-resident in the same call frame. - Adding the bound_by_macro/written_by_test check before receiver_let_bindings introduces a double-counting or false-admission failure path because the macro/static case may also be picked up by the existing let scan or by binds_outside_let.; refuted because: bound_by_macro and written_by_test return true (refuse) on their own branch, so the downstream branches are unreachable for that word. The new gate is strictly an additional refusal path: no path admits where the prior scan refused, and any path the prior scan admitted but the new scan refuses is the intended #7847 fix. PR body and code comment agree on fail-closed semantics.
- Could the new lexical written_by_test scan introduce an info-disclosure or UAF via incorrect parsing of test bodies (e.g., mis-scanning a string literal that contains 'EXPECTED.store') leading to a false admission used as an exploit primitive?; refuted because: whole_word_offsets runs over the masked body produced by the existing masker used throughout expected_binding_calls_owner; string/comment masking is unchanged. Even a malformed parse fails closed (returns true), so a mis-parse never weakens the pin gate. No OOB/UAF/type-confusion surface: this is pure static analysis on test source text; no runtime memory access is gated by the result.
- Owner pin may mis-pin an expected value bound by an ArrayBuffer/TypedArray view's
set/fill/etc., sox.bufferresize during the test detaches the view and the length snapshot becomes stale.; refuted because: ripr owner-pin classifies Rust test bodies statically from a string; it never observes a live buffer, view, or backing store. No JS interop, no typed array in the call graph. The PR'swritten_by_testis a lexical scan of&str, not a runtime buffer view. - place_is_written treats an unbalanced bracket scan as a refusal (returns true on None), which is the documented fail-closed contract. This means an unparseable chain like
expected[orexpected.foo(is refused — equivalent to an over-refusal, never a false admit. PR body confirms fail-closed is intended.
Evidence gaps
- Model proof intent was rejected by deterministic validation.
Parked follow-ups
- Mutator list is the lexical source of truth for what written_by_test treats as writing. Family rules (push/sort/fill/drain/retain/mut/assign/fetch/set) overlap the literal list (store, set, insert, fill, sort, drain, retain, push, swap_remove, etc.). A name in both buckets is checked twice, not harmfully; a name like
get_or_insert_mutmatches both_mutsuffix andget_or_insertprefix and is a single match inany. No path is missed, only duplicated work; parked.
More mutators (with, next*, nth, write_*, splice, replace_range, make_ascii_*); turbofish and ? in a place chain fail closed; an all-caps name borrowed into a non-reader Path::callee(&NAME, ..) call is a write. Adds refusal and operator/let-boundary admit controls. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193fZVBGjXWpxEYFUzBGCYt
Any non-reader call taking &name is a write; destructuring-assignment patterns containing the name are writes; write!/writeln! control added; duplicate exact mutator entries covered by prefix families dropped. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193fZVBGjXWpxEYFUzBGCYt
Explicit first-argument check for write!/writeln! (trusted macros skip bound_by_macro); an unreadable turbofish callee refuses; add compare_exchange*, try_lock, try_write, as_mut_ptr; narrow next* to next/next_back/next_chunk. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193fZVBGjXWpxEYFUzBGCYt
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193fZVBGjXWpxEYFUzBGCYt
A callee ending in ) ] or } refuses; resize_with, compare_and_swap, next_if*, peek* join the mutator set. Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0193fZVBGjXWpxEYFUzBGCYt
There was a problem hiding this comment.
Confirmed findings
- is_mutating_method carries two overlapping sources of truth (MUTATORS array and prefix/suffix arrays). Not a #7847 blocker; tracked for a future collapse.
- Hardening opportunity:
is_mutating_methodhas overlapping exact-name and prefix tables (store,set,with,fill,drain,retain,extend,insert,remove,or_insert,get_or_insert,dedup,pop). A single source of truth keyed by name family would remove the dup without changing behavior; not a correctness defect for #7847. written_by_testcatchesEXPECTED.store(..),&EXPECTEDto qualified call,write!(..), but a static write via a non-call helper closure (EXPECTED.with(\|c\| c.set(..))) and afor_each(\|e\| e.store(&EXPECTED, v))-style call that does NOT nameEXPECTEDtextually inside the lambda are not caught. The lexical scan cannot see through closures. Recommend documenting this residual as a known over-admit vector, and add a negative test exercising the closure form so the gap is explicit. (crates/ripr/src/analysis/classify/owner_pin.rs:10165).- Devin helper-static comment (#1):
write(&EXPECTED, ..)to an unqualified helper. After fix in PR (borrowed_into_path_call),write(&EXPECTED, ..)IS refused because head ends in '(' and callee is non-macro, non-whitelisted, non-turbofish-ending. - PR body states validation gap: hosted CI is the only runner for
cargo xtask precommitand goldens. Locally only fmt + check ran. Local evidence is incomplete; no actionable PR-side fix but a flag for the merge gate. - Lane scope (JS-backed worker/async/GC/detach/transfer) is not touched by this pure-Rust lexical-analysis PR; no public findings to post on ub-worker-handoff.
Verification questions
- Confirm sibling helper expected_return_bindings_owner was not updated by this PR; if a test uses an 'expected_owner'-style name with
s!(x)rebind orEXPECTED.store(w), the return-binding path can still credit a pin despite the new gate in expected_binding_calls_owner. - Confirm new test an_expected_value_a_macro_or_a_static_rebinds_from_the_owner_is_not_a_pin exercises 21 refusals plus 7 control admissions; written_by_test_reads_operators_and_let_boundaries locks 13 read shapes and 27 write shapes including destructured assignment and write!/writeln.
Refuted
- borrowed_into_path_call under-refuses a JS-side worker.postMessage(&expected, [expected]) transfer that mutates owner value across the bridge; refuted because: ripr has no JS bridge; the PR diff adds no wasm-bindgen/postMessage/Transferable surface. Refuted as not-applicable to this lane.
Evidence gaps
- Validation gap: shared box OOMs on lib-test compiles so
cargo testwas not run locally; hosted CI gate is the proof. - Negative-case bodies reference
Ordering,AtomicU32,Cell,Wrapper,E::bump,S::widen,expect,bump,widen, and theunwrappedmethods. They are passed only topath_admitted(lexical scan over prelude+body text); the harnessunit_testsdoes not compile them, socargo testonly proves lexical classification, not that real compiler versions accept the test as written. - Model proof intent was rejected by deterministic validation.
|
67654 prerequisite reconciliation; c4 frozen: StoredAny firstrefuses; budget.rs own Reproducible12control packet, sound acceptance/resume contract, independent assessment; sourcec4 unchanged, evidence51324e92c482f4f27d7eac7eec4a5af9c547433d. Native24compile0/12original0/9zero101/3zero0; customimportedu64alwaysTrueEq staysweak despite Names(empty). IsolatedMAXweak/numericExposed pair provesseparate expectedstage.107sourcebytesets matchretainedexactconsumerreplay0; all52objects+topfields unchanged,targetweak/currentweak18. No duplicatedproductvalidation or PR/hostedCI/Ready/merge/release. Canonical handoff. Final separate assertion prerequisite: ordinary pushed source c4a8f7828e15426c4d872718f66bd4bac3ab0daf on codex/5500-local-glob-assertion-identity; frozen656 untouched. Narrow direct local-module glob assertion identity only under explicit complete-index/composed source visibility; custom/shadowed/opaque/unresolved refusals preserved. General classified cache full1.85/compact0.91/sharded0.91, filefacts1.43 unchanged. No change to your disclosure/parity, helperargument or expectedrebinding mechanism/ownership. Final local15gate strictClippy/checkfast0,precommit0,502fixtures1272comparisons0drift,dogfood0,honesty0;35currentfocused+36currentindependentCLI pass;265unchanged24a tests retained (300total selected). Independent source review complete/no current finding; hostedqualification intentionallyincomplete. Exact consumer native0/all52fullfindingobjects+topfields byte-identical656, target67654weak/currentweak18; no18→17 claim. CandidateAny/expectedglob refusal unchanged. Evidence 4cafbc5255252bc1a7d8e9c3c3f0c34713a2552e; review, inventory, canonical #5500. Shared8772cb6f7667/8592 2b3013d/8597 5aa226a heads rechecked unchanged. All lanecommands terminal, transportrecovered without duplicatevalidation, prior24a/656/16ff custody retained. No PR/hostedCI/Ready/merge/release. #5500 continuation coordination — macro soundness repair Canonical ownership/result, ordinary pushed source Independent external custom-u64 P1 and fresh expected-MAX/local-proc/ancestor-derive counterexamples now refuse through conservative existing namespace/provenance checks plus wildcard/absent workspace macro-context refusal. Qualified assertion identity is not owner primitive identity. The original/selected-zero native controls both compile/pass, and the corrected honesty cases reject actual false-promoting old outputs. Ordinary primitive positives remain supported; no serde expansion, gap/unknown threshold or public schema change. Final successor32 focused tests and23 independent frozen-artifact CLI controls pass. Check-fast native0 on stable74-file selector (15gates, explicit CLI-help skip), strict workspace/all-target Clippy native0; precommit native0 with selected ripr+xtask strict all-target Clippy and502fixtures/1272comparisons,0drift/violations. Advisory dogfood and final honesty native0. All owned successor commands terminal; no hosted qualification inferred.. Exact consumer PR1503 replay remains complete52/52, all52 objects and top-level fields unchanged;0introduced/removed/changed,18currentweak, target67654dc6 weak.18→17 remains NOT_ESTABLISHED. Direct numeric assertion macro identity and saturation expected-glob independence remain separate prerequisites; no claim that an adjacent PR automatically fixes either. Current owners rechecked8772 cb6f766,8592 0588422,8597 5aa226a. The8592 successor only changes helper-side eligibility and a From precaution; its existing no-conflict confirmation is preserved. Fresh independent exact-head source/artifact/oracle/consumer review reports no current actionable findings and all requested bounded local proof complete. Formal REVIEW_INCOMPLETE applies only to unrequested hosted/full-merge qualification; no local blocker or Ready/merge/release authority. Immutable repair summary and manifest:416 text artifacts /7,425,729 bytes, manifest SHA256 |
Requested by Steven · project thread
Closes #7847.
expected_binding_calls_owner(owner_pin.rs) now fails closed for an expected word that (a) a non-bounded statement macro names (bound_by_macro, ass!(expected);), or (b) the test body writes outside alet(written_by_test: assignment,&mut name, or a mutating call such as.store(..),.set(..),.push(..),*_mut,fetch_*,set_*). Aletdeclaration, and a static the test only reads, still pin.Proof: new
an_expected_value_a_macro_or_a_static_rebinds_from_the_owner_is_not_a_pinin owner_pin/tests.rs (macro,AtomicU32::store,static mutassignment refused; independentletand read-only static still admitted).Validation gap: the shared box OOMs on lib-test compiles. Locally only
cargo fmt --checkandcargo check -p ripr --lib --tests -j1ran (clean); the new test,cargo xtask precommitand goldens are not run locally and rely on hosted CI. The macro check is lexical and may over-refuse (fail-closed) where an expected word also appears in another macro's arguments; hosted goldens will show any such movement.Source-of-truth Links
Governing issue or accepted claim: #7847
Acceptance delta (one sentence): Owner-pin refuses an expected value that a statement macro or a non-
letwrite in the test rebinds, instead of pinning it.Generated by Claude Code