Skip to content

fix: Fixed-schema decode allocates attacker-chosen size with no budget check - #640

Merged
martin-g merged 3 commits into
track-allocated-bytes-during-decodingfrom
bound-allocated-bytes-for-fixed-schema-size
Aug 26, 2026
Merged

martin-g merged 3 commits into
track-allocated-bytes-during-decodingfrom
bound-allocated-bytes-for-fixed-schema-size

Conversation

@martin-g

Copy link
Copy Markdown
Member

Cap allocations to max_allocation_bytes when decoding OCF / deserializing schemas

Reported-by: Security scans

Comment thread avro/src/decode.rs Resolved
@martin-g martin-g added this to the 0.23.0 milestone Aug 25, 2026
@martin-g
martin-g requested a review from Kriskras99 August 25, 2026 11:58
@martin-g
martin-g force-pushed the bound-allocated-bytes-for-fixed-schema-size branch from e51c6d7 to 08c5625 Compare August 25, 2026 12:02
@martin-g
martin-g changed the base branch from main to track-allocated-bytes-during-decoding August 25, 2026 12:02
@martin-g
martin-g marked this pull request as ready for review August 25, 2026 12:04
Comment thread avro/src/schema/parser.rs Outdated
Comment on lines +775 to +779
// A fixed schema's size directs decoders to allocate that many bytes,
// and the schema itself may be attacker-supplied (e.g. an OCF header).
// Always bound it before allocating.
let size = usize::try_from(size).map_err(|e| Details::ConvertU64ToUsize(e, size))?;
let size = safe_len(size)?;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think the schema parser is the right place to do this. This should only be done in de reader/decoder.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Agreed!
Reverted the check!

…t check

Cap allocations to max_allocation_bytes when decoding OCF / deserializing schemas

Reported-by: Security scans
@martin-g
martin-g force-pushed the bound-allocated-bytes-for-fixed-schema-size branch from 616fa6b to 11013a3 Compare August 26, 2026 09:55
@martin-g
martin-g merged commit 03e3785 into main Aug 26, 2026
16 checks passed
@martin-g
martin-g deleted the bound-allocated-bytes-for-fixed-schema-size branch August 26, 2026 15:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants