Skip to content

decdn-bao-range: encode_verified_range should reject overlong range_data #1055

Closed

Description

@yigitdot

Spun out of CodeRabbit review on #1052.

encode_verified_range (pre-existing #823 origin-range-import code, moved verbatim into the new decdn-bao-range leaf crate) wraps range_data in an OffsetReadAt that only exposes [aligned.fetch_start, aligned.fetch_end). If a caller passes range_data longer than aligned.fetch_len() (e.g. an origin 206 with a corrupt/extra tail), the extra bytes are silently ignored.

No integrity impact — the bytes that are imported are still bao-verified against the root, and the extra tail is never imported — but a defensive guard would surface malformed input instead of silently dropping it:

if u64::try_from(range_data.len()).ok() != Some(aligned.fetch_len()) {
    return Err(RangeVerifyError::RangeDataSize { expected: aligned.fetch_len(), got: range_data.len(), blob_size });
}

Deferred from #1052 (out of #915 scope; pre-existing behavior, no integrity impact).

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

Metadata

Metadata

Assignees

Labels

prio:low

Type

No type

Fields

Priority

None yet

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions