You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
dpp: bound the decoded size of typed array properties by their encoded size #6070
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.
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.
Activity
QuantumExplorer commentedon Nov 22, 2026
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:
validate_typed_array_max_items(try_from_schema/v3/mod.rs:1520);