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

rar4 reader: protect copy_..._to_unp from too-big or too-small length (CVE-2024-20696) #2172

Merged
merged 1 commit into from
May 9, 2024

Conversation

DHowett
Copy link
Contributor

@DHowett DHowett commented May 7, 2024

copy_from_lzss_window_to_unp unnecessarily took an int parameter where both of its callers were holding a size_t.

A lzss opcode chain could be constructed that resulted in a negative copy length, which when passed into memcpy would result in a very, very large positive number.

Switching copy_from_lzss_window_to_unp to take a size_t allows it to properly bounds-check length.

In addition, this patch also ensures that length is not itself larger than the destination buffer.

copy_from_lzss_window_to_unp unnecessarily took an `int` parameter where
both of its callers were holding a `size_t`.

A lzss opcode chain could be cosntructed that resulted in a negative
copy length, which when passed into memcpy would result in a very, very
large positive number.

Switching copy_from_lzss_window_to_unp to take a `size_t` allows it to
properly bounds-check length.

In addition, this patch also ensures that `length` is not itself larger
than the destination buffer.
@DHowett DHowett changed the title rar4 reader: protect copy_..._to_unp from too-big or too-small length rar4 reader: protect copy_..._to_unp from too-big or too-small length (CVE-2024-20696) May 7, 2024
@DHowett
Copy link
Contributor Author

DHowett commented May 7, 2024

There's a test file for this, but I have as yet been unable to minimize it. It's currently attached to GHSA-266m-xmh8-88vf, and it is 117kb. I can check it in directly without trying to minimize it if that would be preferred!

@mmatuska mmatuska self-requested a review May 9, 2024 23:52
@mmatuska mmatuska merged commit eac15e2 into libarchive:master May 9, 2024
20 checks passed
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.

None yet

2 participants