lnd
lnd copied to clipboard
Bad route hint sends sender node into infinite payment loop
Your environment
- lnd master 2682ca3e22ded37aa75ba40b5dd826bcd5cdd20a
- linux
- bitcoind
Steps to reproduce
- Nodes A and B with a channel between them
- Patch node B to generate invoices that include a hop hint from A via a non-existent channel id
- Create invoice on B
- Pay invoice from A
Expected behaviour
Payment fails immediately.
Actual behaviour
Node A goes into an infinite payment loop where each iteration the outcome is the same UNKNOWN_NEXT_PEER @ 0.
Is this a new behavior?
I don't know. Also, maybe B can do this to any node, not just the ones that they have a channel with.
The infinite loop is still bounded by the pathfinding timeout though right?
Didn't actually wait for that, but very likely that it is still bounded.
@joostjager Me and a friend (@andreihod) were able to reproduce this bug reliably and we think we know how to fix it. Is it okay for us to work on it? I'm asking in case someone is already looking into this.
I did find something, not sure if it's related.
Is it okay for us to work on it? I'm asking in case someone is already looking into this.
@lsunsi if it's a small fix then I'd say go for it! What's the cause you guys found?
@yyforyongyu Nice! We think it's unrelated to your findings: it seems that the processPaymentOutcomeIntermediate was treating the resulting error from this bug while the processPaymentOutcomeSelf was not, leading to the infinite loop because the failure is not marked as final by the handler.
We could verify this because we were able to reproduce the bug easily with a payment where the broken hint is the first hop, but could not reproduce with a payment where the broken hint is the second hop. This different behaviour is what lead us to look into the aforementioned functions.
Does that make sense?
@lsunsi Thanks for the detailed explanation! Yeah in this case I'd say please go ahead and make a PR!
@saubyk This is a P2 bug with a 3-line (ex tests) fix in https://github.com/lightningnetwork/lnd/pull/6766. Move to 0.16 milestone?
Thanks @joostjager for bubbling this up. Tagged for 0.16.0