ZmnSCPxj [ARCHIVE] on Nostr: š
Original date posted:2023-10-17 šļø Summary of this message: The summary of ...
š
Original date posted:2023-10-17
šļø Summary of this message: The summary of the text is that there is a vulnerability in the Lightning Network where a node can cheat and claim funds from an HTLC transaction.
š Original message:
Good morning Antoine et al.,
Let me try to rephrase the core of the attack.
There exists these nodes on the LN (letters `A`, `B`, and `C` are nodes, `==` are channels):
A ===== B ===== C
`A` routes `A->B->C`.
The timelocks, for example, could be:
A->B timeelock = 144
B->C timelock = 100
The above satisfies the LN BOLT requirements, as long as `B` has a `cltv_expiry_delta` of 44 or lower.
After `B` forwards the HTLC `B->C`, C suddenly goes offline, and all the signed transactions --- commitment transaction and HTLC-timeout transactions --- are "stuck" at the feerate at the time.
At block height 100, `B` notices the `B->C` HTLC timelock is expired without `C` having claimed it, so `B` forces the `B====C` channel onchain.
However, onchain feerates have risen and the commitment transaction and HTLC-timeout transaction do not confirm.
In the mean time, `A` is still online with `B` and updates the onchain fees of the `A====B` channel pre-signed transactions (commitment tx and HTLC-timeout tx) to the latest.
At block height 144, `B` is still not able to claim the `A->B` HTLC, so `A` drops the `A====B` channel onchain.
As the fees are up-to-date, this confirms immediately and `A` is able to recover the HTLC funds.
However, the feerates of the `B====C` pre-signed transactions remain at the old, uncompetitive feerates.
At this point, `C` broadcasts an HTLC-success transaction with high feerates that CPFPs the commitment tx.
However, it replaces the HTLC-timeout transaction, which is at the old, low feerate.
`C` is thus able to get the value of the HTLC, but `B` is now no longer able to use the knowledge of the preimage, as its own incoming HTLC was already confirmed as claimed by `A`.
Is the above restatement accurate?
----
Let me also explain to non-Lightning experts why HTLC-timeout is presigned in this case and why `B` cannot feebump it.
In the Poon-Dryja mechanism, the HTLCs are "infected" by the Poon-Dryja penalty case, and are not plain HTLCs.
A plain HTLC offerred by `B` to `C` would look like this:
(B && OP_CLTV) || (C && OP_HASH160)
However, on the commitment transaction held by `B`, it would be infected by the penalty case in this way:
(B && C && OP_CLTV) || (C && OP_HASH160) || (C && revocation)
There are two changes:
* The addition of a revocation branch `C && revocation`.
* The branch claimable by `B` in the "plain" HTLC (`B && OP_CLTV`) also includes `C`.
These are necessary in case `B` tries to cheat and this HTLC is on an old, revoked transaction.
If the revoked transaction is *really* old, the `OP_CLTV` would already impose a timelock far in the past.
This means that a plain `B && OP_CLTV` branch can be claimed by `B` if it retained this very old revoked transaction.
To prevent that, `C` is added to the `B && OP_CLTV` branch.
We also introduce an HTLC-timeout transaction, which spends the `B && C && OP_CLTV` branch, and outputs to:
(B && OP_CSV) || (C && revocation)
Thus, even if `B` held onto a very old revoked commitment transaction and attempts to spend the timelock branch (because the `OP_CLTV` is for an old blockheight), it still has to contend with a new output with a *relative* timelock.
Unfortunately, this means that the HTLC-timeout transaction is pre-signed, and has a specific feerate.
In order to change the feerate, both `B` and `C` have to agree to re-sign the HTLC-timeout transaction at the higher feerate.
However, the HTLC-success transaction in this case spends the plain `(C && OP_HASH160)` branch, which only involves `C`.
This allows `C` to feebump the HTLC-success transaction arbitrarily even if `B` does not cooperate.
While anchor outputs can be added to the HTLC-timeout transaction as well, `C` has a greater advantage here due to being able to RBF the HTLC-timeout out of the way (1 transaction), while `B` has to get both HTLC-timeout and a CPFP-RBF of the anchor output of the HTLC-timeout transaction (2 transactions).
`C` thus requires a smaller fee to achieve a particular feerate due to having to push a smaller number of bytes compared to `B`.
Regards,
ZmnSCPxj
Published at
2023-10-18 13:02:08Event JSON
{
"id": "0f6ddf492ad2ab98eec1f4d347701b4299e8dddb56fc81cccac04e1e10669ac1",
"pubkey": "4505072744a9d3e490af9262bfe38e6ee5338a77177b565b6b37730b63a7b861",
"created_at": 1697634128,
"kind": 1,
"tags": [
[
"e",
"328f78133e455c2e5e32e85f3616c28a6cd54f7e829a069856cc91cb02c46053",
"",
"root"
],
[
"e",
"1c0366f0e209eb2f1971c33224efe3043acdc3b2da2d94df034e01cbce6c604d",
"",
"reply"
],
[
"p",
"5f655379784e4823fd966b766f524a3e77b5e72ee29421bc76ab373d630ca5d1"
]
],
"content": "š
Original date posted:2023-10-17\nšļø Summary of this message: The summary of the text is that there is a vulnerability in the Lightning Network where a node can cheat and claim funds from an HTLC transaction.\nš Original message:\nGood morning Antoine et al.,\n\nLet me try to rephrase the core of the attack.\n\nThere exists these nodes on the LN (letters `A`, `B`, and `C` are nodes, `==` are channels):\n\n A ===== B ===== C\n\n`A` routes `A-\u003eB-\u003eC`.\n\nThe timelocks, for example, could be:\n\n A-\u003eB timeelock = 144\n B-\u003eC timelock = 100\n\nThe above satisfies the LN BOLT requirements, as long as `B` has a `cltv_expiry_delta` of 44 or lower.\n\nAfter `B` forwards the HTLC `B-\u003eC`, C suddenly goes offline, and all the signed transactions --- commitment transaction and HTLC-timeout transactions --- are \"stuck\" at the feerate at the time.\n\nAt block height 100, `B` notices the `B-\u003eC` HTLC timelock is expired without `C` having claimed it, so `B` forces the `B====C` channel onchain.\nHowever, onchain feerates have risen and the commitment transaction and HTLC-timeout transaction do not confirm.\n\nIn the mean time, `A` is still online with `B` and updates the onchain fees of the `A====B` channel pre-signed transactions (commitment tx and HTLC-timeout tx) to the latest.\n\nAt block height 144, `B` is still not able to claim the `A-\u003eB` HTLC, so `A` drops the `A====B` channel onchain.\nAs the fees are up-to-date, this confirms immediately and `A` is able to recover the HTLC funds.\nHowever, the feerates of the `B====C` pre-signed transactions remain at the old, uncompetitive feerates.\n\nAt this point, `C` broadcasts an HTLC-success transaction with high feerates that CPFPs the commitment tx.\nHowever, it replaces the HTLC-timeout transaction, which is at the old, low feerate.\n`C` is thus able to get the value of the HTLC, but `B` is now no longer able to use the knowledge of the preimage, as its own incoming HTLC was already confirmed as claimed by `A`.\n\nIs the above restatement accurate?\n\n----\n\nLet me also explain to non-Lightning experts why HTLC-timeout is presigned in this case and why `B` cannot feebump it.\n\nIn the Poon-Dryja mechanism, the HTLCs are \"infected\" by the Poon-Dryja penalty case, and are not plain HTLCs.\n\nA plain HTLC offerred by `B` to `C` would look like this:\n\n (B \u0026\u0026 OP_CLTV) || (C \u0026\u0026 OP_HASH160)\n\nHowever, on the commitment transaction held by `B`, it would be infected by the penalty case in this way:\n\n (B \u0026\u0026 C \u0026\u0026 OP_CLTV) || (C \u0026\u0026 OP_HASH160) || (C \u0026\u0026 revocation)\n\nThere are two changes:\n\n* The addition of a revocation branch `C \u0026\u0026 revocation`.\n* The branch claimable by `B` in the \"plain\" HTLC (`B \u0026\u0026 OP_CLTV`) also includes `C`.\n\nThese are necessary in case `B` tries to cheat and this HTLC is on an old, revoked transaction.\nIf the revoked transaction is *really* old, the `OP_CLTV` would already impose a timelock far in the past.\nThis means that a plain `B \u0026\u0026 OP_CLTV` branch can be claimed by `B` if it retained this very old revoked transaction.\n\nTo prevent that, `C` is added to the `B \u0026\u0026 OP_CLTV` branch.\nWe also introduce an HTLC-timeout transaction, which spends the `B \u0026\u0026 C \u0026\u0026 OP_CLTV` branch, and outputs to:\n\n (B \u0026\u0026 OP_CSV) || (C \u0026\u0026 revocation)\n\nThus, even if `B` held onto a very old revoked commitment transaction and attempts to spend the timelock branch (because the `OP_CLTV` is for an old blockheight), it still has to contend with a new output with a *relative* timelock.\n\nUnfortunately, this means that the HTLC-timeout transaction is pre-signed, and has a specific feerate.\nIn order to change the feerate, both `B` and `C` have to agree to re-sign the HTLC-timeout transaction at the higher feerate.\n\nHowever, the HTLC-success transaction in this case spends the plain `(C \u0026\u0026 OP_HASH160)` branch, which only involves `C`.\nThis allows `C` to feebump the HTLC-success transaction arbitrarily even if `B` does not cooperate.\n\nWhile anchor outputs can be added to the HTLC-timeout transaction as well, `C` has a greater advantage here due to being able to RBF the HTLC-timeout out of the way (1 transaction), while `B` has to get both HTLC-timeout and a CPFP-RBF of the anchor output of the HTLC-timeout transaction (2 transactions).\n`C` thus requires a smaller fee to achieve a particular feerate due to having to push a smaller number of bytes compared to `B`.\n\nRegards,\nZmnSCPxj",
"sig": "871a4b07d7a3a64dc8a2074d04a4832b1fd9e8a2228fdb18a3e1505d7756d33d67019a21174607a3e537c552dcadbaebc0ede90ff839abd597cc157331ed5b02"
}