uriparser / uriparser

:hocho: Strictly RFC 3986 compliant URI parsing and handling library written in C89; moved from SourceForge to GitHub

Home Page:https://uriparser.github.io/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[CVE-2021-46141] .hostText memory is not properly duped/freed in uriNormalizeSyntax*, uriMakeOwner*, uriFreeUriMembers* for some URIs

autofuzzoss opened this issue · comments

A bug was found within the uriparser. Though it might not be an intended use of the relevant API, the bug can still produce critical issues within a program using uriparser. It would be best if the affected logic is checked beforehand.
The bug was found with a fuzzer based on the test-code"TestNormalizeSyntaxMaskRequired"

_crash log

==2151==ERROR: AddressSanitizer: SEGV on unknown address 0x0000004d9be0 (pc 0x00000041ca94 bp 0x000000000000 sp 0x7fff34437d00 T0)
==2151==The signal is caused by a WRITE memory access.
    #0 0x41ca94 in __asan::Allocator::Deallocate(void*, unsigned long, unsigned long, __sanitizer::BufferedStackTrace*, __asan::AllocType)
    #1 0x493d41 in free 
    #2 0x4c6892 in (anonymous namespace)::countingFree(UriMemoryManagerStruct*, void*)
    #3 0x7fca1c05a4b2 in uriNormalizeSyntaxExMmA_ 

Steps to reproduce:

  1. git clone https://github.com/uriparser/uriparser.git
  2. cd uriparser & mkdir build & cd build
  3. Build
    cmake -DCMAKE_BUILD_TYPE=Release -DURIPARSER_BUILD_DOCS:BOOL=OFF -DBUILD_SHARED_LIBS:BOOL=ON ..
    make -j8
  4. Download the attached file(1.cpp)
  5. Build TEST CODE (1.cpp)
    clang++ -g -fsanitize=address,fuzzer-no-link -o 1 1.cpp -I uriparser/include/ -Luriparser/build -luriparser
  6. Run
    LD_LIBRARY_PATH=uriparser/build/ ./1

OS:ubuntu 18.04
uriparser_poc1.tar.gz

@afosscontact thanks for the detailed report, I will have a closer look.

@afosscontact confirming as a bug, fixed by pull request #124 (along with issue #122). Thanks for the report again! 🙏

Thank you for the fix
Is it possible to issue CVE ID?
If you are not possible, should you ask MITRE?

@junsik-kim0 I'm in the process of making a new release (see #128 and #129). Regarding the two issues you reported, my best knowledge so far is that they can be can cause denial of service. Are you aware of any other potential impact? Also, have you decided if you want to share your name with me and/or Mitre for the CVE finding credits? A soon reply would be great, and I would then request two CVEs, ideally before making the release. Thanks in advance! 🙏

Hello, I agree to share a name
My name is "Autofuzz"
Because I am getting CVE in the name AutoFuzz.
If the CVE number is issued, please let me know.
If you have any information you need, please let me know.
Thanks in advance! :)

Hello, I agree to share a name My name is "Autofuzz" Because I am getting CVE in the name AutoFuzz.

I had a real name in mind, but okay, I can put "Autofuzz" in the Mitre form for discovery credits.

If the CVE number is issued, please let me know. If you have any information you need, please let me know. Thanks in advance! :)

I'm still in the dark about the worst that could be done with an exploit on #121 and #122. Anything beyond a crash-caused denial-of-service? Are you aware of anything more? CWE-590: Free of Memory not on the Heap mentions "potential for arbitrary code execution" (emphasis mine) but I'm unsure if that's realistic for our case here. There is mention of "undefined behavior" elsewhere.

I can not be sure that this remort exploit(potential for arbitrary code execution) is possible
But this is a potential danger that is a matter of memory logic, and many applications that use libraries can cause denial of service.
I can not know the Public API of Uriparser, I can not know how dangerous this is.
thank you

Is CVE ID Issuance Are Is Isuable?
I would appreciate if you share your progress.

Hi @junsik-kim0, I requested two CVEs from Mitre about four hours ago today at https://cveform.mitre.org/ . With some luck I hear back tomorrow.

@junsik-kim0 I have received two CVEs now:

I would like to thank you again for your whitehat security work on uriparser 🙏