-
Notifications
You must be signed in to change notification settings - Fork 107
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
Running cargo afl fuzz
does not interpret panics as crashes
#499
Comments
You can easily clone and try my current setup by visiting the following GitHub repository: rust-aflPlusPlus |
Hi, @BowTiedRadone. Thank you very much for providing the repo and for making the issue easy to reproduce! The easiest way to get your target working would be to use the There appear to be at least two problems with the provided example. First, when AFL++ fuzzes a target that doesn't use persistent mode, it writes the data that it generates to the target's standard input. Thus, rather than read a file named on the command line, the example should be made to look something like: std::io::stdin().read_to_end(&mut buffer)?; Second, a target binary must contain certain strings for AFL++ to handle it properly: Lines 49 to 52 in 462eff5
The lack of those strings was causing AFL++ to mishandle the binary Most of what follows is ruminations on this second point. It used to be one could simply add the following to get those strings into their binary: #[allow(unused_imports)]
use afl::fuzz; However, this no longer seems to work. It also used to be that when AFL++ was given a binary without those strings, it would produce a "Looks like the target binary is not instrumented!" error message (see #470 (comment)). However, this also seems to no longer be the case. Regardless, you are not the first to want to fuzz non-persistently. Hence, afl.rs should provide an easy way to get those strings into a binary. One final note: since you included the crash file in the corpus, I would expect AFL++ to produce an error message like this:
In other words, AFL++ expects corpus files to not cause the target to crash. So if you see that above, that's a sign that things are working! |
Hi @smoelius, thanks for the thorough response. Perhaps, all that's needed is setting the export RUSTFLAGS="-C panic=abort"
cargo afl build Coming from Haskell/GHC and .NET/CLR, this was initially surprising to me since the default behavior when a program crashes due to an unhandled exception is typically to abort the program and exit with a non-zero exit code. It appears that the default behavior in Rust is to unwind the stack, which allows resources to be cleaned up. This does not typically result in a non-zero exit code. From the book, the
|
Building with the panic flag was successful, and I can now detect crashes while fuzzing the resulting binary of the Rust app. Thank you, @smoelius and @moodmosaic, for your helpful responses! |
+1 Thank you, @moodmosaic! |
I am working on a
Rust
+afl++
PoC to start using theafl++
fuzzer against Rust binaries. My basic Rust program has a potentialout-of-bounds
error. It reads text from a file, and if the string is longer than 100 chars, it crashes intentionally.I test the cases manually, and it behaves as it should. However, when fuzzing with
cargo afl fuzz
the panic is neither detected nor saved in the crashes folder.Issue
The panic is not caught. Maybe I am missing something (the way of building the Rust project, the way of returning, the way of starting the fuzzing process - maybe I need some particular flags added to the cargo afl fuzz command).
Use Case
The place in the Rust code where the
out-of-bounds
error is generatedManually testing the binary
Passing test case
Crashing test case
Building the Rust project
Starting the fuzzing process
Thank you in advance!
The text was updated successfully, but these errors were encountered: