Skip to content

Add a fuzzing host #1166

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

Merged
merged 19 commits into from
Apr 17, 2025
Merged

Add a fuzzing host #1166

merged 19 commits into from
Apr 17, 2025

Conversation

kevin-montrose
Copy link
Contributor

Makes some small changes to Garnet, and adds a new executable project for fuzzing purposes.

For MS employees, the intended fuzzer is OneFuzz which is (again) an internal tool.

However, this change should enable integration with any fuzzer and for non-MS employees to reproduce reports generated via OneFuzz.


For Garnet.fuzz, options are:

  -t, --fuzz-target        Required. Class name to run fuzz input against. Valid
                           values: RespCommandParsing, LuaScriptCompilation,
                           GarnetEndToEnd

  -f, --input-file         (Group: input) Read fuzz input from given file.

  -d, --input-directory    (Group: input) Read fuzz inputs from files in given
                           directory.

  -i, --stdin              (Group: input) Read fuzz input from standard input.

  -c, --run-count          Number of times to run fuzzer for input (default=1)

  -q, --quiet              Suppress output.

  --help                   Display this help screen.

  --version                Display version information.

For the three initial targets:

  • RespCommandParsing focuses on RespServerSession.ParseCommand
  • LuaScriptCompilation focuses on LuaRunner.CompileForRunner and LuaRunner.RunForRunner
  • GarnetEndToEnd shoves commands at EmbeddedRespServer, and has some logic to nudge the fuzzer in the direction of RESP requests

Any arbitrary fuzzer can run using either standard input or files. OneFuzz would be invoked like onefuzz template libfuzzer dotnet Garnet.fuzz Garnet.fuzz.dll <version> default bin\Release\net8.0 bin\Release\net8.0\Garnet.fuzz.dll Garnet.fuzz.Targets.<target> Fuzz.

Reproducing reports would use either --input-file or --input-directory, depending on how they are provided. --run-count is intended for cases where crashes do not reproduce on every invocation.

@kevin-montrose kevin-montrose marked this pull request as ready for review April 15, 2025 16:23
@Copilot Copilot AI review requested due to automatic review settings April 15, 2025 16:23
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot reviewed 13 out of 15 changed files in this pull request and generated no comments.

Files not reviewed (2)
  • Garnet.sln: Language not supported
  • test/Garnet.fuzz/Garnet.fuzz.csproj: Language not supported
Comments suppressed due to low confidence (2)

libs/server/Auth/GarnetNoAuthAuthenticator.cs:9

  • [nitpick] Changing the access modifier to public may expose the no-authenticator functionality more broadly than intended; please confirm if this is deliberate or if it should remain internal.
public class GarnetNoAuthAuthenticator : IGarnetAuthenticator

libs/server/Resp/Parser/RespCommand.cs:2640

  • Ensure that assigning the pointer from the input buffer does not lead to unsafe memory access outside the intended bounds; consider adding additional validation or a safer abstraction around pointer manipulation.
recvBufferPtr = (byte*)Unsafe.AsPointer(ref MemoryMarshal.GetReference(buffer));

@kevin-montrose kevin-montrose requested a review from badrishc April 15, 2025 17:27
@kevin-montrose kevin-montrose merged commit c30f10c into main Apr 17, 2025
26 checks passed
@kevin-montrose kevin-montrose deleted the oneFuzz branch April 17, 2025 14:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants