-
Notifications
You must be signed in to change notification settings - Fork 2.2k
lnwire: fuzz onion failure messages #7669
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
lnwire: fuzz onion failure messages #7669
Conversation
Crypt-iQ
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
will do a more in-depth pass later and run the fuzz harnesses, 2 minor comments
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 💯 Thank you very much for this. Just a couple of questions, but no blocking changes.
Needs rebase
lnwire/fuzz_test.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess we should fail here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure, it seems like a precondition for the rest of the test that we have a valid message
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not every sequence of bytes is decodable as an onion error, so we don't want to report a bug when we encounter such a byte sequence. If the sequence is decodable, we do the further tests below.
Crypt-iQ
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think that this should use testify instead of t.Fatal. Otherwise, looks good
|
@morehouse, remember to re-request review from reviewers when ready |
lnwire/fuzz_test.go
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why wait for an encode failure to check this condition? Seems like something you can check immediately.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Waiting to check this condition avoids some false negatives.
Suppose len(data) == FailureMessageLength and data contains the channel_update type prefix. In this case, encoding will succeed, but we wouldn't even try if this condition was checked earlier.
ProofOfKeags
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. I had one comment but it's small and non-blocking. Three cheers for randomized testing!
|
Needs a rebase. |
Fuzz tests for decoding and encoding of onion failure messages, based on the fuzz harness for other lnwire messages. The onion failure messages were uncovered by existing fuzz tests.
The test is identical to other onion failure fuzz tests, except that it
uses a custom equality function to get around the nil != []byte{} issue
with reflect.DeepEqual.
1ec843f to
66d6a84
Compare
|
Rebased and addressed nits. |
yyforyongyu
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like linter timed out. Re-running the job now.
|
Merge queue would've worked, but a new perm added was too heavy handed, have tweaked that now. |
Fuzz tests for decoding and encoding of onion failure messages, based on the fuzz harness for other lnwire messages. The onion failure messages were not covered by existing fuzz tests.
Some of these fuzz tests will fail until #7665 is merged, since the decode-encode-decode of messages with
channel_updatescurrently can mutate thechannel_update. See #6461 (comment).No crashes found after 50+ CPU-hours of fuzzing for each target with #7665 patched in.