From 2d35b3266edb4c7377e5c8283f097552c1ead4aa Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 28 Oct 2026 23:01:23 -0700 Subject: [PATCH 1/3] chore(quest): claim quest/m1/security-audit/fetch-backstop.md Quest-Claim: e80c5a9f84e37595 From fc660b3824597496aba1468868aa0d78e41e243a Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Wed, 28 Oct 2026 23:13:56 -0700 Subject: [PATCH 2/3] fix(net): bound legacy feed fills by shared demand Co-Authored-By: GPT-6.1 Sol --- quest/m1/security-audit/fetch-backstop.md | 26 ++++--- rs/moq-net/src/lite/subscriber.rs | 94 +++++++++-------------- 2 files changed, 53 insertions(+), 67 deletions(-) diff --git a/quest/m1/security-audit/fetch-backstop.md b/quest/m1/security-audit/fetch-backstop.md index 3d6ce1175cc..27162965711 100644 --- a/quest/m1/security-audit/fetch-backstop.md +++ b/quest/m1/security-audit/fetch-backstop.md @@ -8,15 +8,21 @@ session's configured limits, not by `Limits::default().announces`. ## Plan -From the 2026-10-27 audit (NET-2). `FeedFetches::new` sets `max` from -`crate::session::Limits::default().announces` (100,000), an unrelated field's -default that ignores a session configured with tighter limits for untrusted -peers. +The implementation removes the unrelated announcement backstop. `FeedFetches` +holds at most one entry per existing model fill; overlapping readers share +fills, range width does not allocate one entry per group, and cancellation +wakes the holder to release unused fills on its next poll. Network demand +belongs to downstream request streams and their transport credit or legacy +request window, while local callers own their demand handles. An upstream +track aggregates that demand, so its announcement allowance is not the bound. -Prefer deleting the backstop if the held fills are already bounded by what -the cache and ledger hold (the comment says wide fills cost that); a refusal -constant whose only effect is a runtime refusal is what AGENTS.md forbids. -Otherwise thread the session's `Limits` into `FeedFetches`. Show which in the -PR with the bound's derivation. +Remaining before completion: -Public API: none. Wire: none. +- Run the new shared-demand/wide-range test and the existing feed tests. + The attempted pre-fix reproduction could not start: `quest gate` waited + over ten minutes for host admission, then was stopped before compilation. +- Run `just ci`, resolve any findings, then delete this quest and its links + and mark the PR ready. Formatting and quest validation can run without + waiting for host admission. + +Public API: none. Wire format: none. The legacy-only runtime refusal is removed. diff --git a/rs/moq-net/src/lite/subscriber.rs b/rs/moq-net/src/lite/subscriber.rs index 8199a9ffbf5..6689ac12f4a 100644 --- a/rs/moq-net/src/lite/subscriber.rs +++ b/rs/moq-net/src/lite/subscriber.rs @@ -2529,25 +2529,45 @@ mod tests { ); } + /// Wide ranges cost one held entry per model fill, shared until the last reader leaves. #[moq_clock::test] - async fn the_feed_track_backstop_refuses_the_next_group() { + async fn held_feed_fills_follow_shared_demand() { + const WIDTH: u64 = 1 << 40; let start = crate::time::Instant::now(); let clock = crate::time::Deadlines::new(start); let tail = kio::Producer::new(Tail::default()); let sub = feed_sub(&tail).await; - let (track, mut callers, requests) = feed_batch([1, 2, 3]); + let info = track::Info::default().with_timescale(None); + let track = track::Producer::new(Arc::new(crate::broadcast::Info::default()), "video", info); + let dynamic = track.requests(); let mut fetches = FeedFetches::new(&clock); - fetches.max = 2; - for req in requests { - fetches.push(req, &track.consume()); + let mut callers = Vec::new(); + for span in [1..WIDTH, WIDTH..WIDTH * 2, WIDTH * 2..WIDTH * 3] { + callers.push(track.consume().fill_groups(span, 0)); + let fill = dynamic.requested_fill().now_or_never().expect("queued").unwrap(); + fetches.push(fill, &track.consume()); } - fetches.poll(&sub, start, &kio::Waiter::noop()); - assert_eq!(fetches.held.len(), 2); - assert!(matches!( - callers.pop().unwrap().now_or_never(), - Some(Err(Error::TooManyRequests)) - )); + let waiter = kio::Waiter::noop(); + fetches.poll(&sub, start, &waiter); + assert_eq!(fetches.held.len(), 3, "one entry per fill, independent of its width"); assert!(callers.iter_mut().all(|caller| caller.now_or_never().is_none())); + + let mut joined = track.consume().fill_groups(1..WIDTH * 3, 0); + assert!( + dynamic.requested_fill().now_or_never().is_none(), + "joins existing fills" + ); + drop(callers); + fetches.poll(&sub, start, &waiter); + assert_eq!(fetches.held.len(), 3, "the joined reader still owns the demand"); + assert!((&mut joined).now_or_never().is_none()); + + drop(joined); + fetches.poll(&sub, start, &waiter); + assert!(fetches.held.is_empty(), "last reader leaving releases every fill"); + assert!(fetches.ready.read().is_empty()); + assert_eq!(fetches.fold.deadline(), None); + assert!(dynamic.requested_fill().now_or_never().is_none()); } #[moq_clock::test] @@ -2576,37 +2596,6 @@ mod tests { assert!(next.now_or_never().unwrap().is_ok()); } - /// A replacement takes the place of the attempt it replaces under the limit, before any - /// poll releases that one. - #[moq_clock::test] - async fn a_feed_fetch_replaces_an_abandoned_attempt_at_the_limit() { - let start = crate::time::Instant::now(); - let clock = crate::time::Deadlines::new(start); - let tail = kio::Producer::new(Tail::default()); - let sub = feed_sub(&tail).await; - let (track, mut callers, requests) = feed_batch([1, 2]); - let dynamic = track.requests(); - let mut fetches = FeedFetches::new(&clock); - fetches.max = 2; - for req in requests { - fetches.push(req, &track.consume()); - } - fetches.poll(&sub, start, &kio::Waiter::noop()); - drop(callers.remove(0)); - let mut next = track.consume().fetch_group(1, None); - let req = dynamic - .requested_fill() - .now_or_never() - .expect("replacement queued") - .unwrap(); - fetches.push(req, &track.consume()); - assert!((&mut next).now_or_never().is_none(), "held, not refused"); - assert_eq!(fetches.held.len(), 2); - arrive(&track, &tail, 1, start); - fetches.poll(&sub, start, &kio::Waiter::noop()); - assert!(next.now_or_never().unwrap().is_ok()); - } - /// Sweep held fetches, unrelated tracks, and live arrival runs independently. #[moq_clock::test] #[ignore = "release benchmark, run by nightly"] @@ -7489,6 +7478,11 @@ enum ServeMode { /// A fill waits on one group at a time, the next it still owes. Each verdict on that group /// also settles, by run, every group of the fill the feed gave up on, so a fill a peer /// made wide costs what the cache and ledger hold rather than its width. +/// +/// There is at most one held entry per model fill, shared by its readers. Network readers +/// own request streams (bounded by their downstream transport's credit); local readers +/// own their demand. The last reader leaving wakes `poll` to release the fill, so holding +/// it adds state proportional to existing demand, not another allowance on this upstream. struct FeedFetches { /// Each fill, by the group it waits on. held: BTreeMap, @@ -7496,8 +7490,6 @@ struct FeedFetches { arrivals: Option, /// Only gaps containing a held group arm the earliest fold. fold: crate::time::Deadline, - /// An additional track backstop, above one peer's default FETCH allowance. - max: usize, #[cfg(test)] polled: usize, } @@ -7530,7 +7522,6 @@ impl FeedFetches { ready: Default::default(), arrivals: None, fold: crate::time::Deadline::new(clock), - max: crate::session::Limits::default().announces, #[cfg(test)] polled: 0, } @@ -7550,8 +7541,7 @@ impl FeedFetches { self.hold(fill, true); } - /// Wait on the next group `fill` still owes, if any. A fresh fill counts against the - /// limit, once what nobody waits on any more is released. + /// Wait on the next group `fill` still owes, if any. fn hold(&mut self, fill: track::Fill, fresh: bool) { let mut next = Some((fill, fresh)); while let Some((fill, fresh)) = next.take() { @@ -7565,16 +7555,6 @@ impl FeedFetches { { next = Some((previous.fill, false)); } - if fresh { - let moving = usize::from(next.is_some()); - if self.held.len() + moving >= self.max { - self.held.retain(|_, held| held.fill.is_used()); - } - if self.held.len() + moving >= self.max { - fill.refuse(Error::TooManyRequests); - continue; - } - } let waiter = kio::Waiter::new(std::task::Waker::from(Arc::new(FetchWake { sequence, ready: self.ready.clone(), From 4d7527f40afedf9e96af48855cb5ade75b034b24 Mon Sep 17 00:00:00 2001 From: Luke Curley Date: Fri, 30 Oct 2026 21:48:57 -0700 Subject: [PATCH 3/3] fix(net): port the shared-demand test and drop the unused refusal Main removed `fill_groups`, so the test shares one-group fills between two readers each instead; `a_wide_feed_fill_settles_by_run` covers width. The backstop was `Fill::refuse`'s last caller. The quest is finished. Co-Authored-By: Claude Opus 5.5 --- quest/m1/security-audit/README.md | 1 - quest/m1/security-audit/fetch-backstop.md | 28 ----------------------- rs/moq-net/src/lite/subscriber.rs | 25 +++++++++----------- rs/moq-net/src/model/track/fill.rs | 8 ------- 4 files changed, 11 insertions(+), 51 deletions(-) delete mode 100644 quest/m1/security-audit/fetch-backstop.md diff --git a/quest/m1/security-audit/README.md b/quest/m1/security-audit/README.md index d58614db22d..2fd918b5692 100644 --- a/quest/m1/security-audit/README.md +++ b/quest/m1/security-audit/README.md @@ -57,6 +57,5 @@ Dropped, with reasons: - [fMP4 import streams mdat](/quest/m1/security-audit/fmp4-stream-mdat.md) - a box header declaring a huge size cannot pin importer memory across segments - [MKV import streams blocks](/quest/m1/security-audit/mkv-stream-blocks.md) - a declared block, metadata master, or ignored element cannot pin importer memory - [Relay HTTP surface](/quest/m1/security-audit/relay-http.md) - `/fetch` cannot be sniffed as active content, and no web page can reach the ops listener -- [Lite fetch backstop](/quest/m1/security-audit/fetch-backstop.md) - the pre-lite-05 fetch backstop is bounded by design or by the session's limits, not an unrelated default - [Browser input checks](/quest/m1/security-audit/js-input.md) - room metadata is schema-validated and the http:// fingerprint fetch is aborted and length-checked - [CI tool pins](/quest/m1/security-audit/ci-pins.md) - binding generators are pinned by commit in one place, and the remaining unpinned installs and broad token grants are fixed diff --git a/quest/m1/security-audit/fetch-backstop.md b/quest/m1/security-audit/fetch-backstop.md deleted file mode 100644 index 27162965711..00000000000 --- a/quest/m1/security-audit/fetch-backstop.md +++ /dev/null @@ -1,28 +0,0 @@ -# [XS] Lite fetch backstop - -## Goal - -The pre-lite-05 fetch fills a lite subscriber holds (`FeedFetches` in -`rs/moq-net/src/lite/subscriber.rs`) are bounded by design, or by the -session's configured limits, not by `Limits::default().announces`. - -## Plan - -The implementation removes the unrelated announcement backstop. `FeedFetches` -holds at most one entry per existing model fill; overlapping readers share -fills, range width does not allocate one entry per group, and cancellation -wakes the holder to release unused fills on its next poll. Network demand -belongs to downstream request streams and their transport credit or legacy -request window, while local callers own their demand handles. An upstream -track aggregates that demand, so its announcement allowance is not the bound. - -Remaining before completion: - -- Run the new shared-demand/wide-range test and the existing feed tests. - The attempted pre-fix reproduction could not start: `quest gate` waited - over ten minutes for host admission, then was stopped before compilation. -- Run `just ci`, resolve any findings, then delete this quest and its links - and mark the PR ready. Formatting and quest validation can run without - waiting for host admission. - -Public API: none. Wire format: none. The legacy-only runtime refusal is removed. diff --git a/rs/moq-net/src/lite/subscriber.rs b/rs/moq-net/src/lite/subscriber.rs index b690aa88fac..2c4f9e401de 100644 --- a/rs/moq-net/src/lite/subscriber.rs +++ b/rs/moq-net/src/lite/subscriber.rs @@ -2442,42 +2442,39 @@ mod tests { ); } - /// Wide ranges cost one held entry per model fill, shared until the last reader leaves. + /// A held fill costs one entry, shared by every reader that joins it, until the last leaves. #[moq_clock::test] async fn held_feed_fills_follow_shared_demand() { - const WIDTH: u64 = 1 << 40; let start = crate::time::Instant::now(); let clock = crate::time::Deadlines::new(start); let tail = kio::Producer::new(Tail::default()); let sub = feed_sub(&tail).await; - let info = track::Info::default().with_timescale(None); - let track = track::Producer::new(Arc::new(crate::broadcast::Info::default()), "video", info); + let (track, mut callers, requests) = feed_batch([1, 2, 3]); let dynamic = track.requests(); let mut fetches = FeedFetches::new(&clock); - let mut callers = Vec::new(); - for span in [1..WIDTH, WIDTH..WIDTH * 2, WIDTH * 2..WIDTH * 3] { - callers.push(track.consume().fill_groups(span, 0)); - let fill = dynamic.requested_fill().now_or_never().expect("queued").unwrap(); - fetches.push(fill, &track.consume()); + for req in requests { + fetches.push(req, &track.consume()); } let waiter = kio::Waiter::noop(); fetches.poll(&sub, start, &waiter); - assert_eq!(fetches.held.len(), 3, "one entry per fill, independent of its width"); + assert_eq!(fetches.held.len(), 3, "one entry per fill"); assert!(callers.iter_mut().all(|caller| caller.now_or_never().is_none())); - let mut joined = track.consume().fill_groups(1..WIDTH * 3, 0); + let mut joined: Vec<_> = (1..=3) + .map(|sequence| track.consume().fetch_group(sequence, None)) + .collect(); assert!( dynamic.requested_fill().now_or_never().is_none(), "joins existing fills" ); drop(callers); fetches.poll(&sub, start, &waiter); - assert_eq!(fetches.held.len(), 3, "the joined reader still owns the demand"); - assert!((&mut joined).now_or_never().is_none()); + assert_eq!(fetches.held.len(), 3, "the joined readers still own the demand"); + assert!(joined.iter_mut().all(|caller| caller.now_or_never().is_none())); drop(joined); fetches.poll(&sub, start, &waiter); - assert!(fetches.held.is_empty(), "last reader leaving releases every fill"); + assert!(fetches.held.is_empty(), "the last reader leaving releases every fill"); assert!(fetches.ready.read().is_empty()); assert_eq!(fetches.fold.deadline(), None); assert!(dynamic.requested_fill().now_or_never().is_none()); diff --git a/rs/moq-net/src/model/track/fill.rs b/rs/moq-net/src/model/track/fill.rs index c529bd39465..9542b392864 100644 --- a/rs/moq-net/src/model/track/fill.rs +++ b/rs/moq-net/src/model/track/fill.rs @@ -807,14 +807,6 @@ impl Fill { } } - /// Refuse every group still owed with `err`, which says nothing about whether the source - /// has them, so nothing is recorded dropped. - #[cfg_attr(not(feature = "async"), allow(dead_code, reason = "async-only"))] - pub(crate) fn refuse(&self, err: Error) { - let unresolved = self.inner.unresolved(self.inner.start.group..self.inner.end); - self.inner.refuse(&unresolved, err, self.max_delay()); - } - /// The next run of groups still owed, in the fill's order: [`Self::next`]'s group, /// extended over the owed groups beside it up to the nearest one the cache holds, so a /// session asks its source for the whole run at once.