Skip to content

fuzz: Fix RPC internal bug detection - #23707

Merged
maflcko merged 1 commit into
bitcoin:masterfrom
maflcko:2112-fuzzBugRpc
Dec 8, 2021
Merged

maflcko merged 1 commit into
bitcoin:masterfrom
maflcko:2112-fuzzBugRpc

Conversation

@maflcko

@maflcko maflcko commented Dec 8, 2021

Copy link
Copy Markdown
Member

Previously the fuzz test considered any exception which contains the string Internal bug detected (magic string) as a bug. This is not true when the user (fuzzer) passes in the magic string from outside.

Fix that by:

  1. Changing the format the string in NonFatalCheckError to start with the magic string.
  2. Only treat exceptions that start with the magic string as internal bugs.

This should fix the bug because any other exception shouldn't start with the magic string.

To test:

echo 'bG9nZ2luZ1y+bUludGVybmFsIGJ1ZyBkZXRlY3RlZAAXCqNcjqNcjuYjeg==' | base64 --decode > /tmp/a
FUZZ=rpc ./src/test/fuzz/fuzz /tmp/a

Before:

fuzz: test/fuzz/rpc.cpp:365: void rpc_fuzz_target(FuzzBufferType): Assertion `error_msg.find("trigger_internal_bug") != std::string::npos' failed.

After:

Executed /tmp/a in 0 ms

@maflcko maflcko added the Tests label Dec 8, 2021

@shaavan shaavan left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

crACK fa77f95

@maflcko
maflcko merged commit 926fc2a into bitcoin:master Dec 8, 2021
@maflcko
maflcko deleted the 2112-fuzzBugRpc branch December 8, 2021 15:52
RandyMcMillan pushed a commit to RandyMcMillan/mempool-tab that referenced this pull request Dec 23, 2021
ca75ffd fuzz: Fix RPC internal bug detection (MarcoFalke)

Pull request description:

  Previously the fuzz test considered any exception which contains the string `Internal bug detected` (magic string) as a bug. This is not true when the user (fuzzer) passes in the magic string from outside.

  Fix that by:

  1. Changing the format the string in `NonFatalCheckError` to start with the magic string.
  2. Only treat exceptions that start with the magic string as internal bugs.

  This should fix the bug because any other exception shouldn't start with the magic string.

  To test:

  ```
  echo 'bG9nZ2luZ1y+bUludGVybmFsIGJ1ZyBkZXRlY3RlZAAXCqNcjqNcjuYjeg==' | base64 --decode > /tmp/a
  FUZZ=rpc ./src/test/fuzz/fuzz /tmp/a
  ```

  Before:
  ```
  fuzz: test/fuzz/rpc.cpp:365: void rpc_fuzz_target(FuzzBufferType): Assertion `error_msg.find("trigger_internal_bug") != std::string::npos' failed.
  ```

  After:
  ```
  Executed /tmp/a in 0 ms

ACKs for top commit:
  shaavan:
    crACK ca75ffd

Tree-SHA512: 079bc97b6ce0cbad8603c7b577cc1ac0fd19e884ccbaba317588b91d98b36afeaa8cb398344b52bf12c9fd1737b3fdd8452b4e833a3b06cb3c789651955f78b8
@bitcoin bitcoin locked and limited conversation to collaborators Dec 8, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants