Skip to content

Fuzz minizip #1940

Closed
Closed

Description

@Dor1s

Hi @nmoinvaz,

@akmistry has been doing awesome work to fuzz minizip in Chromium. AFAIK, you might've already received some bug reports. However, to fully leverage our fuzzing capabilities, we would like to invite you to integrate minizip with OSS-Fuzz.

Main advantages of integrating with OSS-Fuzz:

  1. We always fuzz tip-of-tree revision here, while in Chromium we use a fixed revision which needs to be manually updated from time to time

  2. OSS-Fuzz integration would allow you and other contributors to reproduce crashes in a more convenient way than you might have to do it right now

  3. Everything is automated on our end, including bug reporting and fixes verification, which also would make things more convenient for the upstream developers

Also, we offer rewards for open source projects who integrate with OSS-Fuzz, here are some details and links: https://security.googleblog.com/2018/11/a-new-chapter-for-oss-fuzz.html

Please take a look at the New Project Guide and let us know if you have any questions!

Activity

  1. nmoinvaz commented on Nov 10, 2018

    @nmoinvaz
    Contributor

    I have seen @akmistry work's to fuzz minizip in Chromium and it looks great. I have also tried to fix some of the bugs that I've seen come through.

    I am always interested in rewards. What would you want me to do beyond what @akmistry has done? Are you looking for me to move all his fuzzer tests into the minizip repository and expand the seed corpus or something more?

  2. Dor1s commented on Nov 12, 2018

    @Dor1s
    ContributorAuthor

    Yes, as @inferno-chromium said over email, "all you need is just move those fuzz targets files to your repo and add < 50 line build/integration instructions in OSS-Fuzz github repo (example)". That would be sufficient to get fuzzing coverage on tip-of-tree revision and convenient bug reporting / verification pipeline.

    Later on, you can follow more steps from the Ideal Integration in order to improve testing of minizip and apply for a higher reward :)

  3. added a commit that references this issue on Nov 12, 2018
  4. nmoinvaz commented on Nov 12, 2018

    @nmoinvaz
    Contributor

    @Dor1s - I spent sometime this weekend figuring out libFuzzer and how to integrate. Here are my changes. Please take a look and let me know if this is correct or if anything is missing. See pull request #1945.

  5. added a commit that references this issue on Nov 12, 2018
  6. Dor1s commented on Nov 13, 2018

    @Dor1s
    ContributorAuthor

    @nmoinvaz looks like linking doesn't work properly, the binaries are linked against the standalone driver, rather than against -lFuzzingEngine: https://github.com/nmoinvaz/minizip/blob/dev/CMakeLists.txt#L671

        if (NOT CMAKE_COMPILER_IS_CLANG)
            set(FUZZER_SRC "test/fuzz/standalone.c")
        endif()

    Do we need to set CMAKE_COMPILER_IS_CLANG in https://github.com/google/oss-fuzz/blob/master/projects/minizip/build.sh#L19 ?

  7. nmoinvaz commented on Nov 13, 2018

    @nmoinvaz
    Contributor

    @Dor1s - I have updated the cmake clang detection, let me know if that works for you.

  8. Dor1s commented on Nov 13, 2018

    @Dor1s
    ContributorAuthor

    Cool, thanks! Now there is a bunch of link failures:

    [ 96%] Building C object CMakeFiles/zip_fuzzer.dir/test/fuzz/zip_fuzzer.c.o
    [ 98%] Linking C executable unzip_fuzzer
    [100%] Linking C executable zip_fuzzer
    /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../libFuzzingEngine.a(FuzzerDriver.o)/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../libFuzzingEngine.a(FuzzerDriver.o): In function `: In function `appendappend':
    ':
    /usr/local/bin/../include/c++/v1/string:/usr/local/bin/../include/c++/v1/string:25172517: undefined reference to `: undefined reference to `std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*, unsigned long)std::__1::basic_string<char, std::__1::char_traits<char>, std::__1::allocator<char> >::append(char const*, unsigned long)'
    '
    /usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../libFuzzingEngine.a(FuzzerDriver.o)/usr/lib/gcc/x86_64-linux-gnu/5.4.0/../../../libFuzzingEngine.a(FuzzerDriver.o): In function `: In function `__do_call':
    __do_call/usr/local/bin/../include/c++/v1/new:':
    340/usr/local/bin/../include/c++/v1/new:: undefined reference to `340: undefined reference to `operator delete(void*)operator delete(void*)'
    '
    

    I think the reason is that we should link using clang++ even though the project is written in C, because libFuzzer is written in C++.

  9. nmoinvaz commented on Nov 13, 2018

    @nmoinvaz
    Contributor

    Is there any way I can reproduce those results? I had tested through docker and also used infra.py script initially during my testing.

  10. nmoinvaz commented on Nov 13, 2018

    @nmoinvaz
    Contributor

    I have modified my cmake script to use CXX when linking. Give that a shot.

  11. Dor1s commented on Nov 13, 2018

    @Dor1s
    ContributorAuthor
    $ python infra/helper.py build_image --no-pull minizip \
        && python infra/helper.py build_fuzzers minizip
    
    ...
    
    -- Performing Test check_opt_aes - Success
    -- Configuring done
    CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
    Missing variable is:
    CMAKE_CXX_LINK_EXECUTABLE
    CMake Error: Error required internal CMake variable not set, cmake may be not be built correctly.
    Missing variable is:
    CMAKE_CXX_LINK_EXECUTABLE
    -- Generating done
    -- Build files have been written to: /src/minizip
    Fuzzers build failed.
  12. nmoinvaz commented on Nov 13, 2018

    @nmoinvaz
    Contributor

    Thanks for the command. Should be fixed now.

  13. nmoinvaz commented on Nov 13, 2018

    @nmoinvaz
    Contributor

    You may require pull request #1948.

  14. Dor1s commented on Nov 13, 2018

    @Dor1s
    ContributorAuthor

    Good job, the latest build succeeded! Woohoo!

  15. inferno-chromium commented on Dec 17, 2018

    @inferno-chromium
    Contributor

    For rewards, @nmoinvaz - please fill out the form at https://goo.gl/YMLfG2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions