Skip to content

Conversation

@morehouse
Copy link
Collaborator

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_updates currently can mutate the channel_update. See #6461 (comment).

No crashes found after 50+ CPU-hours of fuzzing for each target with #7665 patched in.

Copy link
Collaborator

@Crypt-iQ Crypt-iQ left a 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

@morehouse morehouse requested a review from Crypt-iQ June 19, 2023 17:16
Copy link
Contributor

@positiveblue positiveblue left a 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

Copy link
Contributor

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?

Copy link
Collaborator

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

Copy link
Collaborator Author

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.

@saubyk saubyk added this to the v0.18.0 milestone Oct 5, 2023
Copy link
Collaborator

@Crypt-iQ Crypt-iQ left a 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

@lightninglabs-deploy
Copy link

@morehouse, remember to re-request review from reviewers when ready

Comment on lines +881 to +707
Copy link
Collaborator

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.

Copy link
Collaborator Author

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.

Copy link
Collaborator

@ProofOfKeags ProofOfKeags left a 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!

@guggero
Copy link
Collaborator

guggero commented Oct 26, 2023

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.
@morehouse morehouse force-pushed the fuzz_lnwire_onion_errors branch from 1ec843f to 66d6a84 Compare October 27, 2023 20:12
@morehouse
Copy link
Collaborator Author

Rebased and addressed nits.

Copy link
Member

@yyforyongyu yyforyongyu left a 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.

@Crypt-iQ Crypt-iQ enabled auto-merge October 30, 2023 13:58
@Crypt-iQ Crypt-iQ added this pull request to the merge queue Oct 30, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Oct 30, 2023
@Roasbeef Roasbeef added this pull request to the merge queue Oct 30, 2023
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to Branch Protection failures Oct 30, 2023
You're not authorized to push to this branch. Visit "About protected branches" for more information.
@Roasbeef
Copy link
Member

Merge queue would've worked, but a new perm added was too heavy handed, have tweaked that now.

@Roasbeef Roasbeef merged commit 32c8b82 into lightningnetwork:master Oct 30, 2023
@morehouse morehouse deleted the fuzz_lnwire_onion_errors branch October 30, 2023 19:47
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

9 participants