Skip to content

Validate length-delimited sizes before allocation #76

@peter-jerry-ye

Description

@peter-jerry-ye

read_bytes/read_string/read_message use read_int32 to obtain the length without validating for negative or overflow values. Negative lengths or very large values can cause invalid allocations or stream desync.

Suggested fix: reject negative sizes, and validate against any remaining LimitedReader limit before allocating/reading. Mirror in async paths.

Refs: lib/reader.mbt, lib/async_reader.mbt.

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