You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.1 KiB

  1. # fuzz
  2. Fuzzing for various packages in Tendermint using [go-fuzz](https://github.com/dvyukov/go-fuzz) library.
  3. Inputs:
  4. - mempool `CheckTx` (using kvstore in-process ABCI app)
  5. - p2p `Addrbook#AddAddress`
  6. - p2p `pex.Reactor#Receive`
  7. - p2p `SecretConnection#Read` and `SecretConnection#Write`
  8. - rpc jsonrpc server
  9. ## Directory structure
  10. ```
  11. | test
  12. | |- corpus/
  13. | |- crashers/
  14. | |- init-corpus/
  15. | |- suppressions/
  16. | |- testdata/
  17. | |- <testname>.go
  18. ```
  19. `/corpus` directory contains corpus data. The idea is to help the fuzzier to
  20. understand what bytes sequences are semantically valid (e.g. if we're testing
  21. PNG decoder, then we would put black-white PNG into corpus directory; with
  22. blockchain reactor - we would put blockchain messages into corpus).
  23. `/init-corpus` (if present) contains a script for generating corpus data.
  24. `/testdata` directory may contain an additional data (like `addrbook.json`).
  25. Upon running the fuzzier, `/crashers` and `/suppressions` dirs will be created,
  26. along with <testname>.zip archive. `/crashers` will show any inputs, which have
  27. lead to panics (plus a trace). `/suppressions` will show any suppressed inputs.
  28. ## Running
  29. ```sh
  30. make fuzz-mempool
  31. make fuzz-p2p-addrbook
  32. make fuzz-p2p-pex
  33. make fuzz-p2p-sc
  34. make fuzz-rpc-server
  35. ```
  36. Each command will create corpus data (if needed), generate a fuzz archive and
  37. call `go-fuzz` executable.
  38. Then watch out for the respective outputs in the fuzzer output to announce new
  39. crashers which can be found in the directory `crashers`.
  40. For example if we find
  41. ```sh
  42. ls crashers/
  43. 61bde465f47c93254d64d643c3b2480e0a54666e
  44. 61bde465f47c93254d64d643c3b2480e0a54666e.output
  45. 61bde465f47c93254d64d643c3b2480e0a54666e.quoted
  46. da39a3ee5e6b4b0d3255bfef95601890afd80709
  47. da39a3ee5e6b4b0d3255bfef95601890afd80709.output
  48. da39a3ee5e6b4b0d3255bfef95601890afd80709.quoted
  49. ```
  50. the crashing bytes generated by the fuzzer will be in
  51. `61bde465f47c93254d64d643c3b2480e0a54666e` the respective crash report in
  52. `61bde465f47c93254d64d643c3b2480e0a54666e.output`
  53. and the bug report can be created by retrieving the bytes in
  54. `61bde465f47c93254d64d643c3b2480e0a54666e` and feeding those back into the
  55. `Fuzz` function.