Skip to content
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

Fuzz testing with cargo fuzz #642

Open
LegNeato opened this issue Apr 29, 2020 · 7 comments
Open

Fuzz testing with cargo fuzz #642

LegNeato opened this issue Apr 29, 2020 · 7 comments
Labels
enhancement Improvement of existing features or bugfix help wanted

Comments

@LegNeato
Copy link
Member

We should fuzz test execute and execute_async to make sure no external input can cause the library to panic or crash.

@LegNeato LegNeato added enhancement Improvement of existing features or bugfix help wanted labels Apr 29, 2020
@trevyn
Copy link
Contributor

trevyn commented Feb 18, 2021

I set up a basic cargo fuzz for execute_sync here: trevyn/juniper@master...trevyn:fuzz

It got up to 1.8M executions (~20 minutes) and then segfaulted:

#1842766        REDUCE cov: 2716 ft: 10646 corp: 1777/747Kb lim: 3205 exec/s: 1360 rss: 830Mb L: 17/3073 MS: 1 EraseBytes-
────────────────────────────────────────────────────────────────────────────────

Error: Fuzz target exited with signal: 11

Apparently there is a known bug in cargo fuzz where it doesn't save the test case, and one way to find it is to use afl.rs🤪: rust-fuzz/cargo-fuzz#235 (comment)

At any rate, it seems like what's really getting exercised is parse_document_source here: https://docs.rs/juniper/0.15.3/src/juniper/lib.rs.html#231

@LegNeato is that as intended? Also, I'm not sure if the async-flavored execute function is exercising anything different, and I'd have to figure out how to scaffold that.

@trevyn
Copy link
Contributor

trevyn commented Feb 18, 2021

Ok, here's the AFL version: trevyn/juniper@master...trevyn:fuzz-afl

Ran it for 30 minutes with no issues, will leave it running and report back later.

@trevyn
Copy link
Contributor

trevyn commented Feb 18, 2021

1 crash found: crash-0000.min

I added a (failing) test to the trevyn:fuzz-afl branch.

@trevyn
Copy link
Contributor

trevyn commented Mar 9, 2021

In addition to the stack overflow crash above, it's also easy to hit a Type not found in schema panic. That file has a lot of expect()s that look easy to hit, though, so I'm not sure what the intended behavior is.

@LegNeato
Copy link
Member Author

Woah, totally missed this, great work! Is it ready to be integrated?

@LegNeato
Copy link
Member Author

@trevyn , FWIW I was thinking about this due to 17d474e.

I wonder if there is a way to give a schema and have a bunch of valid and invalid permutations thrown at us. Would be useful for all GraphQL servers to have a corpus of graphql queries with corresponding schema and if they should pass / not pass.

@trevyn
Copy link
Contributor

trevyn commented Jan 27, 2022

@LegNeato Thanks! I’m not working with Juniper or GraphQL anymore, but feel free to use anything here!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement Improvement of existing features or bugfix help wanted
Projects
None yet
Development

No branches or pull requests

2 participants