-fuzzmessagestest=N : randomly corrupt 1-of-N sent messages #3173

pull gavinandresen wants to merge 2 commits into bitcoin:master from gavinandresen:fuzzmessages changing 4 files +94 −3
  1. gavinandresen commented at 6:32 AM on October 28, 2013: contributor

    I needed this to test the new "reject" p2p message, but it should be generally useful for fuzz-testing network message handling code.

    Note: you'll quickly trigger the DoS-and-ban code if you connect to random peers, this is most useful in a two-nodes-on-your-development-machine testnet-in-a-box or -regtest setup.

  2. laanwj commented at 6:56 AM on October 28, 2013: member

    I agree that this is useful. However I'm not sure whether we should include test/fuzzing/stresstest code in the core.

    If we want this we should put it in #ifdefs, add a configure option to enable it and not ship it in gitian builds (IMO).

  3. Diapolo commented at 7:18 AM on October 28, 2013: none

    I tend to agree, I remember I wanted to include an GCC stack smashing protection test via a switch, which seemed not like a good idea in the end. A guard via #ifdef ALLOW_FUZZTEST and a compiler option would be good IMO.

  4. gmaxwell commented at 7:49 AM on October 28, 2013: contributor

    make it only fuzz localhost peers? :)

  5. petertodd commented at 11:13 AM on October 28, 2013: contributor

    ACK

    Lets not make barriers to this kind of testing like having to compile it in; implementations should be robust enough to handle junk getting sent at them from the occasional buggy peer. If they aren't that robust, they need to be improved frankly.

    edit: been running this for a few hours, and it looks like Bitcoin itself can be crashed due to the fuzz-tester...

  6. in src/net.h:None in dafb96925b outdated
     442 | @@ -440,6 +443,8 @@ class CNode
     443 |              AbortMessage();
     444 |              return;
     445 |          }
     446 | +        if (mapArgs.count("-fuzzmessagestest"))
     447 | +            Fuzz(atoi(mapArgs["-fuzzmessagestest"]));
    


    Diapolo commented at 11:28 AM on October 28, 2013:

    Fuzz(GetArg("-fuzzmessagestest", 0));?

  7. jgarzik commented at 12:52 PM on October 28, 2013: contributor

    ACK.. no objection to it being a runtime feature.

  8. laanwj commented at 1:03 PM on October 28, 2013: member

    At least keep it undocumented in -help then. There is already such a huge list of command line options, let's not add options that are not useful for 99.9% users and will cause them to be banned if they add it by accident.

  9. gavinandresen commented at 11:20 PM on October 28, 2013: contributor

    Added a comment to make it clear the -*messagestest options are not documented on purpose, since they are for implementors, not end-users.

    I do think this should be a built-in run-time feature, it should be very helpful to re-implementors who are likely to be programming in a different language and might not want to bother setting up a dev environment to build themselves.

    Tweaked with @Diapolo's suggestion to use GetArg instead of atoi (made it default to 1-of-10 messages fuzzed because that seems about right). @petertodd: please file a bug or send an email to bitcoin-security@lists.sourceforge.net if you found a bug or a vulnerability.

  10. Bug fix: CDataStream::GetAndClear() when nReadPos > 0
    Changed CDataStream::GetAndClear() to use the most obvious
    get get and clear instead of a tricky swap().
    
    Added a unit test for CDataStream insert/erase/GetAndClear.
    
    Note: GetAndClear() is not performance critical, it is used only
    by the send-a-message-to-the-network code. Bug was not noticed
    before now because the send-a-message code never erased from the
    stream.
    d5d1425657
  11. -fuzzmessagestest=N : randomly corrupt 1-of-N sent messages
    I needed this to test the new "reject" p2p message, but it should be generally
    useful for fuzz-testing network message handling code.
    9038b18f46
  12. gavinandresen commented at 1:31 AM on October 29, 2013: contributor

    Rebased; fixed a crashing (assertion failed) bug caused by the fuzz-tester deleting at the beginning of the CDataStream (normal bitcoin usage never does that).

  13. BitcoinPullTester commented at 2:14 AM on October 29, 2013: none

    Automatic sanity-testing: PASSED, see http://jenkins.bluematt.me/pull-tester/9038b18f4655a5b8ad119d768decd1c693ebd7dd for binaries and test log. This test script verifies pulls every time they are updated. It, however, dies sometimes and fails to test properly. If you are waiting on a test, please check timestamps to verify that the test.log is moving at http://jenkins.bluematt.me/pull-tester/current/ Contact BlueMatt on freenode if something looks broken.

  14. petertodd commented at 6:15 AM on October 30, 2013: contributor

    @gavinandresen Been running this for about a day with the crash fix and -fuzzmessagestest=100 No problems found.

  15. gavinandresen referenced this in commit 951ed190fb on Oct 30, 2013
  16. gavinandresen merged this on Oct 30, 2013
  17. gavinandresen closed this on Oct 30, 2013

  18. gavinandresen deleted the branch on Nov 4, 2013
  19. Bushstar referenced this in commit 883fcbe8bd on Apr 8, 2020
  20. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-05-02 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me