Skip to content

dpp: bound the decoded size of typed array properties by their encoded size #6070

Closed

Description

@QuantumExplorer

Basic explanation

TypedArrayProperty::read_from (packages/rs-dpp/src/data_contract/document_type/property/array.rs) limits a typed array to its maxItems, at most max_typed_array_items (1024). It does not tie the decoded size to the encoded size: an element type that encodes in zero bytes lets a one-byte count decode into maxItems separate values. Every reader of document properties goes through this decoder, including document queries and the private document payload reader (decode_private_document_payload).

What to decide

Whether the decoder, or the schema rules for typed arrays, should keep the decoded size proportional to the encoded size. For example: refuse element types that encode in zero bytes, or cap decoded elements by the remaining input.

Context

Raised in the review of #6052, which reads private document entries in the wallet. The wallet holds each decoded entry of a read until it returns, within the caller's page budget. The review concluded that a bound belongs in the DPP decoder rather than in one caller.

🤖 Generated with Claude Code

Activity

  1. QuantumExplorer commented on Nov 22, 2026

    @QuantumExplorer
    MemberAuthor

    Another reader of the same decoder, from the review of #6056: moderator removal records keep field values through it (config/moderation/document_removal.rs). A page of up to 100 records can therefore decode far more values than its stored bytes suggest. A moderator's field change also merges into the stored document without a size check, so one record can hold more than a single 20 KiB write carries.

    Two options to weigh with the decoder fix:

    • from protocol version 15, refuse typed-array elements that encode to zero bytes at registration and update, beside validate_typed_array_max_items (try_from_schema/v3/mod.rs:1520);
    • a decoded-value budget in rs-sdk for documents and removal records, which every binding inherits, since protocol 14 contracts already registered stay readable.
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