-
Notifications
You must be signed in to change notification settings - Fork 266
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
Allow nodes to overshoot final htlc amount and expiry #2468
Conversation
When nodes receive HTLCs, they verify that the contents of those HTLCs match the intructions that the sender provided in the onion. It is important to ensure that intermediate nodes and final nodes have similar requirements, otherwise a malicious intermediate node could easily probe whether the next node is the final recipient or not. Unfortunately, the requirements for intermediate nodes were more lenient than the requirements for final nodes. Intermediate nodes allowed overpaying and increasing the CLTV expiry, whereas final nodes required a perfect equality between the HTLC values and the onion values. This provided a trivial way of probing: when relaying an HTLC, nodes could relay 1 msat more than what the onion instructed (or increase the outgoing expiry by 1). If the next node was an intermediate node, they would accept this HTLC, but if the next node was the recipient, they would reject it. We update those requirements to fix this probing attack vector. See lightning/bolts#1032
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'm struggling to understand how this plays with this previous provision from BOLT 4:
if the invoice specifies an amount:
MUST set total_msat to at least that amount, and less than or equal to twice amount.
This is completely unrelated. The requirement you quote defines how you should set What this PR does is about the relationship between the HTLC amount (from |
Okay, this change applies to htlcs, not payments, it's a different layer. The original sender can overpay up to 2x, but intermediate nodes may overpay as much as they want. Receiver won't even see it, as it should only look at the final payload. But in practice it is a bit weird in our current code though, since in the following validation we consider the onion amount but we print the htlc amount : eclair/eclair-core/src/main/scala/fr/acinq/eclair/payment/receive/MultiPartHandler.scala Lines 382 to 388 in a8389a0
|
Codecov Report
@@ Coverage Diff @@
## master #2468 +/- ##
==========================================
+ Coverage 84.92% 84.97% +0.04%
==========================================
Files 198 198
Lines 15783 15812 +29
Branches 637 711 +74
==========================================
+ Hits 13404 13436 +32
+ Misses 2379 2376 -3
|
Yes, that is a good way of looking at it, this change is for the HTLC layer.
This code snippet only verifies the spec quote from before: the onion The |
I guess before this PR we could (should for consistency?) have used |
The way I think about this is that if you count using
We verify This is also a very far-fetched example: it would only happen if the previous node decides to just throw money at you (this is a net loss for them). We already let them do it if we're not the final node, so we definitely should let them do it if we're the final node! |
Fair enough, I get it now. |
When nodes receive HTLCs, they verify that the contents of those HTLCs match the intructions that the sender provided in the onion. It is important to ensure that intermediate nodes and final nodes have similar requirements, otherwise a malicious intermediate node could easily probe whether the next node is the final recipient or not.
Unfortunately, the requirements for intermediate nodes were more lenient than the requirements for final nodes. Intermediate nodes allowed overpaying and increasing the CLTV expiry, whereas final nodes required a perfect equality between the HTLC values and the onion values.
This provided a trivial way of probing: when relaying an HTLC, nodes could relay 1 msat more than what the onion instructed (or increase the outgoing expiry by 1). If the next node was an intermediate node, they would accept this HTLC, but if the next node was the recipient, they would reject it.
We update those requirements to fix this probing attack vector.
See lightning/bolts#1032