Skip to content

moq-net: ban Hop ID 0 from hop chains #3060

Closed as not planned
Closed as not planned

Description

@kixelated

Origin::UNKNOWN (Hop ID 0) is documented as "no identity", but it is currently legal inside a hop chain, and that is where every problem with it comes from. A chain entry that names nobody cannot be filtered on, cannot be loop-detected, and cannot be told apart from another entry that also names nobody. Ban it from chains and those problems stop being cases to handle.

0 stays reserved and keeps its job as the absence marker in the fields that need one (AnnounceInterest.exclude_hop, AnnounceOk.origin, RELAY_HOPS). That reading is unambiguous precisely because no endpoint may adopt 0 as its identity, which Origin::new already enforces. What changes is that a chain names real hops only.

What this closes

#3053: a peer that declares 0 and sends its own HOP_PATH cannot be filtered on the identity we assigned it. Substituting the assigned id into the chain was implemented during #3042 and reverted after producing four defects in four review rounds. With 0 illegal in a chain, a peer with no identity has nothing legal to write as its terminal entry, so that advertisement is a decode-time PROTOCOL_VIOLATION rather than something to substitute into. The four defects were:

  1. Only the terminal entry may be substituted; earlier zeros belong to upstreams the receiver never spoke to.
  2. Substituting can construct an invalid chain: [X, 0] from a peer assigned X becomes [X, X], a PROTOCOL_VIOLATION for whoever we forward it to.
  3. The assigned identity must not be tested against a peer that declared one, or its ordinary traffic is discarded as a loop.
  4. The check and the substitution must be gated together, or a peer assigned Y that sent [Y, 0] bypasses the check and gets rewritten anyway.

Each was a new conditional on the same decision. None of them exist if the chain cannot carry 0.

It also removes the privacy question substitution raised: an assigned identity is indistinguishable on the wire from a declared one, so writing it into a forwarded chain publishes our private name for a peer that asked not to be named.

Scope

Both wire dialects. A non-zero Hop ID appearing twice is already a PROTOCOL_VIOLATION in draft-lcurley-moq-cluster; #3049 mirrors that into draft-lcurley-moq-lite and moves it into OriginList so it holds at construction rather than only at decode. This issue is the next step on the same rule: HopPath::validate drops the duplicate-zeros exemption, and a zero entry becomes invalid on its own.

moq-lite-01/02/03. These carry no real Hop IDs. Lite-03 sends a bare hop count that announce.rs expands into that many UNKNOWN placeholders, which is the only remaining source of zeros in a chain, and lite-01/02 send nothing at all. They stay supported: the count is read as the route cost instead, which is what it was for before it was also made to carry loop prevention, and which the lite draft already equates to it (An absent parameter means the default cost of 1, under which the accumulated Route Cost equals the hop count).

That means the loop bound has to come from the cost, since the count no longer tracks chain length:

  • charge the configured link cost, with a mandatory floor of 1 on lite-01/02/03 links. A link priced 0 is a supported config (two relays in one datacenter) and would otherwise stop the value growing, leaving the loop unbounded.
  • reject a received value above MAX_HOPS, reproducing today's 32-hop ceiling.
  • emit the accumulated cost where encode_hops currently emits hops.len().

Behavior change worth calling out: a lite-03 route's stored chain drops from N entries to one ([assigned_upstream_id]), so cost carries the distance and hop length stops standing in for it. That shifts how lite-03 routes rank against others, and the tie-break key in model/origin.rs is computed over the chain.

Drafts. draft-lcurley-moq-cluster section "The Reserved Hop ID 0" is deleted rather than amended. The rules it anchors change with it: HOP_PATH validity becomes "no Hop ID appears twice" with no exemption, "an advertisement whose first entry is 0 has an unknown origin" goes away because every first entry now names a real publisher, and "Assigned Identities" shifts from MAY to mandatory, since a receiver has no way to spell an unnamed upstream in a chain. RELAY_HOPS keeps meaning "no identity" when it carries 0; what a peer may no longer do is put 0 in a HOP_PATH. draft-lcurley-moq-lite gets the matching chain rule alongside the Hop Count rule.

The section's honest summary today, Declaring 0 therefore trades loop detection and failover for anonymity, becomes false rather than merely narrower: a peer that declares 0 is assigned an identity and filtered on it, and gets no anonymity from the chain because it can no longer write into one.

Done when

Every == Origin::UNKNOWN / != Origin::UNKNOWN test that exists to ask "does this chain entry name anybody" is gone, across lite/subscriber.rs, ietf/{subscriber,publisher,cluster}.rs, and model/{origin,broadcast}.rs. The marker survives only where it means "this field is absent". Any survivor in the first category means 0 is still special somewhere and the change is incomplete.

Targets dev: it changes published moq-net API alongside #3049, and lands on top of it.

(written by Claude Opus 5)

Activity

  1. kixelated commented on Aug 26, 2026

    @kixelated
    CollaboratorAuthor

    Prerequisite is up: #3066 moves the no-repeated-hop rule into OriginList, so it holds wherever a chain exists rather than only where one was parsed, and mirrors the rule into draft-lcurley-moq-lite and js/net.

    That leaves this issue a smaller change than it reads: HopPath::validate is already down to the empty-list check, and OriginList::push / TryFrom / Decode / replace_first are already the single place the chain rules live. Banning 0 is one more condition in that same place, plus the lite-01/02/03 count-to-cost conversion and the two draft edits.

    #3053 is closed against this.

    (written by Claude Opus 5)

  2. added
    questBeing tracked/planned in a quest. See `quest/`
    and removed
    questBeing tracked/planned in a quest. See `quest/`
    on Sep 7, 2026
  3. kixelated commented on Sep 11, 2026

    @kixelated
    CollaboratorAuthor

    Closing as not planned. The maintainer decided the opposite direction in #3623: hop 0 stays legal inside a chain as the mark of an anonymous upstream and is forwarded on the wire, while a relay's assigned id stays local selection state for the split-horizon filter. Route selection then ranks any route holding a 0 below every fully identified route, whatever the costs (quest/m1/anonymous-route-rank.md). A chain that cannot carry 0 has no way to say a route is anonymous, which that rule needs.

    (written by Claude Fable 5.1)

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions