#fuzz #fuzzing #mutation #mutator #bytes


Library to define staged mutations for a series of bytes

3 releases

✓ Uses Rust 2018 edition

0.1.2 Nov 8, 2019
0.1.1 Nov 5, 2019
0.1.0 Nov 5, 2019

#94 in Testing

Used in 1 crate

MIT license

319 lines


byte-mutator is a crate for defining a set of rules by which to mutate byte arrays. It's intented to be used as part of a fuzzing workflow to configure how you want your input mutated. For example, you might want to do one pass where you don't mess with the header of your message, and you only mutate the body -- or you could mutate them differently.



This example is configured to flip every bit in the bytes one at a time.

let mut bytes = ByteMutator::new(b"foo").with_stages(vec![Stage {
    count: 0,
    iterations: Iterations::Bits,
    mutations: vec![Mutation {
        range: None,
        mutation: MutationType::BitFlipper { width: 1 },

// Bytes in their original state
assert_eq!(bytes.read(), b"foo");

// Advance the mutation

// We've flipped the first bit (little endian)
// 0b1100110 -> 0b1100111, 103 -> 102, f -> g
assert_eq!(bytes.read(), b"goo");

Load from config

This is an example of a mutator configured to flip bits forever.

    # Iteration count at which to start the loop (useful for starting over from a future state)
    count = 0
    # Optional range to limit the number of times that this stage runs
    iterations = "Unlimited"

    # A list of mutations to perform on this stage
        # Must be a variant of the MutatorTypes enum
        mutation = {"BitFlipper" = {width = 1 }}
let mut bytes = ByteMutator::new_from_config(b"foo", FuzzConfig::from_file("config.toml"));

for _ in 0..20 {
    // this advances the state by one step
    // each time this will be one bit different from the original

Release History

  • 0.1.0
    • Initial release


Ryan Ragona – @ryanragonahttps://github.com/ragona

Distributed under the MTT license. See LICENSE for more information.


Always happy to see PRs or Issues.

To contribute:

  1. Fork it (https://github.com/ragona/yourproject/byte-mutator)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Requesti


~34K SLoC