rust-fuzz / cargo-fuzz

Command line helpers for fuzzing
https://rust-fuzz.github.io/book/cargo-fuzz.html
Apache License 2.0
1.55k stars 110 forks source link

Support Honggfuzz #140

Open PaulGrandperrin opened 6 years ago

PaulGrandperrin commented 6 years ago

Honggfuzz looks to be a great competitor to libFuzzer and AFL.

Also, the instrumentalization procedure seems to be very similar to libFuzzer so it might be quite easy to add support ;-)

A copy-paste of the description:


A security oriented, feedback-driven, evolutionary, easy-to-use fuzzer with interesting analysis options. See USAGE for the description of command-line options.

PaulGrandperrin commented 6 years ago

I just successfully made honggfuzz work with Rust code :-) I would be happy to implement myself honggfuzz support if you want.

frewsxcv commented 6 years ago

I would be happy to implement myself honggfuzz support if you want.

🤩🤩🤩 this would be amazing! how much work was it to get it working? i haven't tried out honggfuzz yet, but i've been meaning to! looks like a great fuzzing utility

PaulGrandperrin commented 6 years ago

I just got it working on a simple test very easily. I don't remember exactly the steps but it was something quick and dirty like that:

It does not, however, work with bigger projects. For example on a project, the dependancy backtrace-sys will fail to compile with sancov enabled because of missing symbols (it's trying to build a binary, but does not link it to libhfuzz.a). However, I guess it's unrelated to compiling with honggfuzz. I'm curious about how cargo-fuzz/libfuzzer solve this problem.

PaulGrandperrin commented 6 years ago

Hi, I've been working hard this week on building the honggfuzz crate. I'm pretty happy with what it looks like now, it's pretty minimal (does not handle the creation of boilerplate code), but I think the API is easy to understand and use.

https://crates.io/crates/honggfuzz https://github.com/PaulGrandperrin/honggfuzz-rs

I made a recording of how it works: asciicast

Don't hesitate to give me feedback :-)

frewsxcv commented 6 years ago

this is all very cool @PaulGrandperrin, nice work! so now we have both afl.rs and honggfuzz-rs which work great as standalone fuzzing tools, but do you think we should try to incorporate one or both into cargo-fuzz as well? i'd be very interested in seeing that happen with afl.rs, but i haven't had much time to think about how that'd work, or what changes would need to be made to cargo-fuzz

also, i don't want this to sound like i'm pressuring you to do so, but if you did have interest in moving the honggfuzz repo to the rust-fuzz github organization, let me know and we can make that happen

PaulGrandperrin commented 6 years ago

Hi @frewsxcv ! While working on porting Honggfuzz to Rust I first worked on the cargo-fuzz codebase but then I thought it would be better to first build an independent project instead. Here is my reasoning:

Also, I want to gain some experience with honggfuzz and building crates in general before thinking too much about the next steps.

However, I want to confirm that it also was my objective from the beginning to build something that could eventually be integrated into something like cargo-fuzz. I would also be happy to move the project under the "rust-fuzz" umbrella.

frewsxcv commented 6 years ago

all sounds great, thanks for writing it out!

I would also be happy to move the project under the "rust-fuzz" umbrella.

again, no pressure, but if you did want to do this, you should be an admin for the rust-fuzz org and should be able to migrate the repository over

PaulGrandperrin commented 6 years ago

Awesome! Done. Should we close this issue now or when honggfuzz is available from cargo-fuzz itself?

killercup commented 6 years ago

Given that @PaulGrandperrin did such an awesome job of generalizing the rust-fuzz/targets to three fuzzers in https://github.com/rust-fuzz/targets/pull/102 I'm wondering what it would take to do the same for cargo-fuzz.

Is it possible to have users put all their fuzz code into a fuzz_target! macro call, and then have cargo-fuzz generate fuzzer-specific code? We already require nightly for some fuzzers IIRC, so we could totally use proc macros if we wanted to.

PaulGrandperrin commented 6 years ago

I think it will be difficult to really have something API compatible in the short term, even using proc macros. I started an RFC to start to lay down a path toward that goal but I think it will take time to get there. For example, libfuzzer requires #[no_main] but I don't think you can generate that from a macro because of macro hygiene (I might be wrong).

However, in the mean time, cargo-fuzz could instantiate templates just like in https://github.com/rust-fuzz/targets, and then compile thoses.

0xalpharush commented 1 month ago

What is the status of https://github.com/rust-fuzz/cargo-fuzz/issues/1 and this issue? I see the RFC but wondering if there has been further work or discussion