Skip to content

fix(msf): bound catalog parsing before initRef expansion - #9288

Open
krsna1729 wants to merge 2 commits into
moq-dev:releasefrom
krsna1729:fix/msf-bound-catalog-release
Open

krsna1729 wants to merge 2 commits into
moq-dev:releasefrom
krsna1729:fix/msf-bound-catalog-release

Conversation

@krsna1729

@krsna1729 krsna1729 commented Nov 21, 2026 •

Copy link
Copy Markdown

Problem

On the release line, catalog deserialization copies referenced initialization data into each track. The newer Arc<str> model on main (#7949) changes a public field type, so this PR keeps the 0.5.x API intact.

Approach

  • Reject serialized catalogs over 32 MiB in Catalog::from_str before JSON parsing.
  • Check the total resolved initialization data against 32 MiB before cloning any referenced data. This bound applies to all serde entry points. Inline data counts once, including when paired with a matching reference.
  • Preserve normal serde sequence parsing. There is no separate count limit on tracks or init entries.

Impact

  • Adds moq_msf::MAX_CATALOG_BYTES.
  • Rejects serialized input or resolved initialization data above the byte limit. No wire format or track-count change.

Alternatives

Backporting #7949 would change the public field type. A separate entry-count cap would reject valid catalogs without being needed for the reference expansion bound.

Verification and follow-ups

The 65-entry compatibility test failed under the earlier count cap and passes now through both parsing paths. cargo nextest run --locked -p moq-msf: 36 passed. Scoped formatting and Clippy checks passed. Restream will check the published release against its own regressions before removing its vendor patch.

(Written by GPT-6.2 Sol)

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ℹ️ No critical issues — one scope question inline.

Approach: sound — the resolved-bytes preflight runs before any initRef clone, which closes the amplification at its cause in a non-breaking way that fits 0.5.x, since #7949's Arc<str> fix can't be backported.

Reviewed changes — the full single-commit diff to rs/moq-msf/src/lib.rs, plus its only consumer (moq-mux's MSF catalog consumer) and the existing hang rendition cap.

  • Raw-input cap — Catalog::from_str rejects input above MAX_CATALOG_BYTES before parsing.
  • Bounded sequences — tracks and initDataList deserialize through a visitor that errors on the 65th element without parsing it.
  • Resolved-bytes preflight — the init bytes each track resolves to are summed with checked_sub against 32 MiB before resolution, so a shared initDataList entry referenced by many tracks can no longer expand without bound.
  • Tests — cover both the from_str and serde_json::from_value paths, including exact-limit acceptance.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using claude-opus-5-5 | 𝕏

Comment thread rs/moq-msf/src/lib.rs Resolved
Keep the serialized and resolved init data byte limits. Restore ordinary Serde sequence deserialization so the patch release does not add a separate track or init data entry count limit.
The 65-entry compatibility test failed with the old count limit and now passes through both public parsing paths. All 36 moq-msf nextest cases pass, and scoped formatting and Clippy checks pass.

Co-Authored-By: GPT-6.2 Sol <noreply@openai.com>

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ No new issues found.

Reviewed changes — the single commit since the prior review, which drops the entry-count cap and keeps only the two byte bounds.

  • Removed MAX_TRACKS — deleted the constant, the custom deserialize_bounded_entries / deserialize_bounded_init_data_list visitors, and their attributes on Wire, so tracks and initDataList go back to stock serde sequence parsing. The only new public API is now MAX_CATALOG_BYTES.
  • Replaced the count-limit tests — swapped the 65th-entry rejection tests for one that checks a 65-track, 65-entry catalog passes through both from_str and from_value. The exact-limit byte test now uses a local TRACKS constant.

The memory bound still holds without the count cap. The 32 MiB check on raw input and the resolved-bytes preflight both stay in place, and serde's cautious size hint keeps the stock Vec visitor from over-reserving on the Value path.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants