-
Notifications
You must be signed in to change notification settings - Fork 190
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
heap buffer overflow on convert_utf16_to_utf32() #469
Comments
Thanks for reporting. If you could add the data (e.g., the ICC profile) used by the fuzzer to obtain the crash, that would be very useful. I can't spot any defect in the code by just inspecting it, the len16=0 case is covered by a previous "if" and should not reach this function. |
Hi . Attached zip file contains the crashing testcase. |
Thank you so much. Unfortunately, running your code and this sample results in a "corrupted tag" error with no flaw at all. The "convert_utf16_to_utf32()" routine you report as buggy is never executed, so, I wonder if you just mismatched the sample or perhaps you are using outdated sources? |
Did you checked out to the lcms commit as mentioned in the first post ?
Are you able to reproduce the bug with the ASAN ? |
The commit c75a823 was on Oct-27, 2024, going back to the 2.16 official release, which is dated Dec 2023 and running this program, the reported routine is never reached, and the profile is discarded because malformed. You can see I call your fuzzer code. On actual code happens exactly same.
|
@mm2 Can you please send the output of the ASAN here ? Thanks. |
Finally I have been able to reproduce it. It is very elusive as only happens on linux and only if sizeof(wchar_t) > sizeof(uint16_t). A commit is following. This will automatically close the issue. |
Many thanks to @GPTFuzzx for pointing out the issue.
It is not exploitable. This tag is used only in reference function "_cmsReadProfileSequence()" which is not used nor accessible from API. Instead, the library computes the sequence by its own. You can do a search in sources if wish so. *According CVE vulnerability implies exploits https://www.cve.org/ResourcesSupport/Glossary?activeTerm=glossaryVulnerability |
@mm2 Apologize, I wanted to ask for CVE for another bug in another project that I reported and it's exploitable, so you can ignore my previous comment and thank you! |
Hi .
The libfuzzer harness code :
Caused the ASAN to complain :
This is likely caused by improper bounds checking during UTF string conversion.
lcms commit :
c75a82336eeaa19c2632193c63d52c9435542182
The root cause :
Root Cause:
The library allocates a buffer for (len16 + 1) UTF-32 code points (where len16 is the number of UTF-16 code units read from the input ICC profile).
When len16 = 0 (e.g., an empty string), the allocation becomes 1 * sizeof(cmsUInt32Number) = 4 bytes (enough for 1 UTF-32 code point + null terminator).
The code then writes a null terminator to dst[len16 + 1] (i.e., dst[1]), which is out-of-bounds for the 4-byte buffer. This is a classic "off-by-one" error in the library’s string termination logic.
We didn't check the latest lcms against this bug, but if present, should be fixed .
Thanks.
The text was updated successfully, but these errors were encountered: