Skip to content

producers: refuse a message nested past MaxNestingDepth (protowire#502) #34

Closed

Description

@bfrancojr

trendvidia/protowire#502 (decided by the owner): a producer of PXF text or of PB must fail with an error on a message nested more deeply than MaxNestingDepth (default 100, configurable per call), counted as a decoder reading the output would count it. HARDENING.md § Recursion, draft -01 § Recursion.

Not measured: at main b8d7b7f the stock upb reader in pb-render refuses both 101-level rows (Exceeded upb_DecodeOptions_MaxDepth, exit 2).

The corpus pins the PXF producer with pb-render rows: pb/deep-submessage-{100,101} and pb/deep-map-{100,101}. For those rows check-decode's stock protobuf reader must allow deeper input than 100. Otherwise it refuses the bytes before the producer runs, and the reject row passes without testing anything. The reject rows list this port in skip until then.

Done when: the PXF and PB producers refuse past the limit (with a per-call option to raise it), pb-render raises the stock reader's limit, and the port is removed from the two reject rows' skip.

Activity

  1. bfrancojr commented on Nov 6, 2026

    @bfrancojr
    CollaboratorAuthor

    PXF producer side: #41 merged (1ccd1c5). The spec change that drops python from the two pb-render rows' skip is trendvidia/protowire#587. With it, cross_security_check.sh passes for Python on 128 pairs, up from 124.

    Still open after #587 merges: whether the PB-producer half applies to this port. Python writes PB only through google.protobuf's SerializeToString and has no PB encoder of its own. This issue stays open for that decision.

  2. bfrancojr commented on Nov 8, 2026

    @bfrancojr
    CollaboratorAuthor

    This issue's open half (the PB producer) and #36's PB rows turn out to be the same question: whether Python gets its own PB codec, as Go's encoding/pb. Options, Go comparison and a recommendation are in #36 (comment).

  3. bfrancojr commented on Nov 8, 2026

    @bfrancojr
    CollaboratorAuthor

    Decided by the owner (2026-11-07): port Go's encoding/pb to Python. Python gets its own PB codec, with Go's UnmarshalOptions limits and a Marshal that refuses past MaxNestingDepth. That closes this issue's PB half by implementation. An API proposal follows before the build.

  4. bfrancojr commented on Nov 8, 2026

    @bfrancojr
    CollaboratorAuthor

    The PB-producer half: pb.marshal and pb.Encoder refuse a value nested past max_nesting_depth, counted as pb.unmarshal counts it (Go's marshal_depth_test.go is ported in tests/test_pb_depth.py). In #53, which closes this issue.

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

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions