Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix B aux tag length check in cram_encode_aux #1725

Merged
merged 2 commits into from
Jan 3, 2024

Conversation

daviesrob
Copy link
Member

B tags need eight bytes. Previously this only checked for at least seven, which could lead to a single byte out of bounds read. The impact of this is mostly limited by a later check on blen; however it was also possible that blen could overflow, allowing the check to incorrectly pass. A second commit expands blen so it can't overflow, and ensures it has an acceptable value before passing it to the encode function.

B tags need eight bytes:
  2 for key
  1 for type (B)
  1 for sub-type
  4 for count

Previously this only checked for at least seven bytes, which
could lead to a single byte out of bounds read.

Credit to OSS-Fuzz
Fixes oss-fuzz 65383
Ensure that large B aux item counts are caught in cram_encode_aux()
so that the check to ensure that all the data is present works,
and it can't attempt to make a block with negative length.
@jkbonfield jkbonfield merged commit 67f3ab0 into samtools:develop Jan 3, 2024
9 checks passed
@daviesrob daviesrob deleted the B_tag_check branch January 4, 2024 10:22
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