Skip to content
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

[bug]: blinded forwarding: hop encoding / payload decoding inconsistency #8137

Closed
morehouse opened this issue Oct 31, 2023 · 1 comment · Fixed by #8142
Closed

[bug]: blinded forwarding: hop encoding / payload decoding inconsistency #8137

morehouse opened this issue Oct 31, 2023 · 1 comment · Fixed by #8142
Assignees

Comments

@morehouse
Copy link
Collaborator

To support blinded forwarding in the future, 940b491 started omitting the amount and timelock TLVs in Hop.PackHopPayload when those values are 0. However, no matching change was made to the payload decoding logic in NewPayloadFromReader and ValidateParsedPayloadTypes. As a result, onion payloads along a blinded route will fail to decode due to missing amount or timelock TLVs.

Although blinded forwarding is still a WIP, it would be good to fix this inconsistency at least for the sake of our FuzzPayload test, which currently fails with the following input:

$ cd htlcswitch/hop
$ cat testdata/fuzz/FuzzPayload/2892b85ab66a5aec6ae8f500e357b887f37b1041fd71186d4e541127e01e49b0
go test fuzz v1
[]byte("\x02\x00\x04\x0200")

$ go test -run=FuzzPayload/2892b85ab66a5aec6ae8f500e357b887f37b1041fd71186d4e541127e01e49b0
--- FAIL: FuzzPayload (0.00s)
    --- FAIL: FuzzPayload/2892b85ab66a5aec6ae8f500e357b887f37b1041fd71186d4e541127e01e49b0 (0.00s)
        fuzz_test.go:122: 
                Error Trace:    htlcswitch/hop/fuzz_test.go:122

                Error:          Received unexpected error:
                                onion payload for final hop omitted record with type 2
                Test:           FuzzPayload/2892b85ab66a5aec6ae8f500e357b887f37b1041fd71186d4e541127e01e49b0
FAIL
exit status 1
FAIL    github.com/lightningnetwork/lnd/htlcswitch/hop  0.007s

CC: @carlaKC

@carlaKC
Copy link
Collaborator

carlaKC commented Oct 31, 2023

However, no matching change was made to the payload decoding logic in NewPayloadFromReader and ValidateParsedPayloadTypes

Oo, nice fuzzer catch! Since we're only making those payloads (not receiving them yet) the validation hasn't been updated.

Although blinded forwarding is still a #7298, it would be good to fix this inconsistency at least for the sake of our FuzzPayload test, which currently fails with the following input:

I'll lift a commit out of #7298 to allow these payloads in the meantime!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants