diff --git a/quest/m1/security-audit/README.md b/quest/m1/security-audit/README.md index d610666eacd..818f6a2088c 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 3d6ce1175cc..00000000000 --- a/quest/m1/security-audit/fetch-backstop.md +++ /dev/null @@ -1,22 +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 - -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. - -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. - -Public API: none. Wire: none. diff --git a/rs/moq-net/src/lite/subscriber.rs b/rs/moq-net/src/lite/subscriber.rs index df50ec77974..ee9c9fdb7b3 100644 --- a/rs/moq-net/src/lite/subscriber.rs +++ b/rs/moq-net/src/lite/subscriber.rs @@ -2560,25 +2560,42 @@ mod tests { ); } + /// A held fill costs one entry, shared by every reader that joins it, until the last leaves. #[moq_clock::test] - async fn the_feed_track_backstop_refuses_the_next_group() { + async fn held_feed_fills_follow_shared_demand() { 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 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()); - 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"); assert!(callers.iter_mut().all(|caller| caller.now_or_never().is_none())); + + 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 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(), "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()); } #[moq_clock::test] @@ -2607,37 +2624,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"] @@ -7681,6 +7667,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, @@ -7688,8 +7679,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, } @@ -7722,7 +7711,6 @@ impl FeedFetches { ready: Default::default(), arrivals: None, fold: crate::time::Deadline::new(clock), - max: crate::session::Limits::default().announces, #[cfg(test)] polled: 0, } @@ -7742,8 +7730,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() { @@ -7757,16 +7744,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.wanted().is_some()); - } - 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(), diff --git a/rs/moq-net/src/model/track/fill.rs b/rs/moq-net/src/model/track/fill.rs index 7fde2bf3fee..5a044a018a0 100644 --- a/rs/moq-net/src/model/track/fill.rs +++ b/rs/moq-net/src/model/track/fill.rs @@ -845,14 +845,6 @@ impl Fill { Poll::Ready(wanted) } - /// 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::wanted`]'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.