Skip to content

Commit a1870e1

Browse files
ariardt-bast
andauthored
Add a max_dust_htlc_exposure_msat (#919)
* Bound exposure to trimmed in-flight HTLCs * Reject update_fee beyond max_dust_htlc_exposure_msat Co-authored-by: t-bast <[email protected]>
1 parent 8cb9b89 commit a1870e1

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

02-peer-protocol.md

+67
Original file line numberDiff line numberDiff line change
@@ -970,6 +970,52 @@ A fulfilling node:
970970
- SHOULD send an `error` to the offering peer (if connected).
971971
- MUST fail the channel.
972972

973+
### Bounding exposure to trimmed in-flight HTLCs: `max_dust_htlc_exposure_msat`
974+
975+
When an HTLC in a channel is below the "trimmed" threshold in [BOLT3 #3](03-transactions.md),
976+
the HTLC cannot be claimed on-chain, instead being turned into additional miner
977+
fees if either party unilaterally closes the channel. Because the threshold is
978+
per-HTLC, the total exposure to such HTLCs may be substantial if there are many
979+
dust HTLCs committed when the channel is force-closed.
980+
981+
This can be exploited in griefing attacks or even in miner-extractable-value attacks,
982+
if the malicious entity wins <sup>[mining capabilities](https://lists.linuxfoundation.org/pipermail/lightning-dev/2020-May/002714.html)</sup>.
983+
984+
The total exposure is given by the following back-of-the-envelope computation:
985+
986+
remote `max_accepted_htlcs` * (`HTLC-success-kiloweight` * `feerate_per_kw` + remote `dust_limit_satoshis`)
987+
+ local `max_accepted_htlcs` * (`HTLC-timeout-kiloweight` * `feerate_per_kw` + remote `dust_limit_satoshis`)
988+
989+
To mitigate this scenario, a `max_dust_htlc_exposure_msat` threshold can be
990+
applied when sending, forwarding and receiving HTLCs.
991+
992+
A node:
993+
- when receiving an HTLC:
994+
- if the HTLC's `amount_msat` is smaller than the remote `dust_limit_satoshis` plus the HTLC-timeout fee at `feerate_per_kw`:
995+
- if the `amount_msat` plus the dust balance of the remote transaction is greater than `max_dust_htlc_exposure_msat`:
996+
- SHOULD fail this HTLC once it's committed
997+
- SHOULD NOT reveal a preimage for this HTLC
998+
- if the HTLC's `amount_msat` is smaller than the local `dust_limit_satoshis` plus the HTLC-success fee at `feerate_per_kw`:
999+
- if the `amount_msat` plus the dust balance of the local transaction is greater than `max_dust_htlc_exposure_msat`:
1000+
- SHOULD fail this HTLC once it's committed
1001+
- SHOULD NOT reveal a preimage for this HTLC
1002+
- when offering an HTLC:
1003+
- if the HTLC's `amount_msat` is smaller than the remote `dust_limit_satoshis` plus the HTLC-success fee at `feerate_per_kw`:
1004+
- if the `amount_msat` plus the dust balance of the remote transaction is greater than `max_dust_htlc_exposure_msat`:
1005+
- SHOULD NOT send this HTLC
1006+
- SHOULD fail the corresponding incoming HTLC (if any)
1007+
- if the HTLC's `amount_msat` is inferior to the holder's `dust_limit_satoshis` plus the HTLC-timeout fee at the `feerate_per_kw`:
1008+
- if the `amount_msat` plus the dust balance of the local transaction is greater than `max_dust_htlc_exposure_msat`:
1009+
- SHOULD NOT send this HTLC
1010+
- SHOULD fail the corresponding incoming HTLC (if any)
1011+
1012+
The `max_dust_htlc_exposure_msat` is an upper bound on the trimmed balance from
1013+
dust exposure. The exact value used is a matter of node policy.
1014+
1015+
For channels that don't use `option_anchors_zero_fee_htlc_tx`, an increase of
1016+
the `feerate_per_kw` may trim multiple htlcs from commitment transactions,
1017+
which could create a large increase in dust exposure.
1018+
9731019
### Adding an HTLC: `update_add_htlc`
9741020

9751021
Either node can send `update_add_htlc` to offer an HTLC to the other,
@@ -1333,6 +1379,16 @@ The node _responsible_ for paying the Bitcoin fee:
13331379
The node _not responsible_ for paying the Bitcoin fee:
13341380
- MUST NOT send `update_fee`.
13351381

1382+
A sending node:
1383+
- if `option_anchors_zero_fee_htlc_tx` was not negotiated:
1384+
- if the `update_fee` increases `feerate_per_kw`:
1385+
- if the dust balance of the remote transaction at the updated `feerate_per_kw` is greater than `max_dust_htlc_exposure_msat`:
1386+
- MAY NOT send `update_fee`
1387+
- MAY fail the channel
1388+
- if the dust balance of the local transaction at the updated `feerate_per_kw` is greater than `max_dust_htlc_exposure_msat`:
1389+
- MAY NOT send `update_fee`
1390+
- MAY fail the channel
1391+
13361392
A receiving node:
13371393
- if the `update_fee` is too low for timely processing, OR is unreasonably large:
13381394
- MUST send a `warning` and close the connection, or send an
@@ -1345,6 +1401,12 @@ A receiving node:
13451401
- SHOULD send a `warning` and close the connection, or send an
13461402
`error` and fail the channel.
13471403
- but MAY delay this check until the `update_fee` is committed.
1404+
- if `option_anchors_zero_fee_htlc_tx` was not negotiated:
1405+
- if the `update_fee` increases `feerate_per_kw`:
1406+
- if the dust balance of the remote transaction at the updated `feerate_per_kw` is greater then `max_dust_htlc_exposure_msat`:
1407+
- MAY fail the channel
1408+
- if the dust balance of the local transaction at the updated `feerate_per_kw` is greater than `max_dust_htlc_exposure_msat`:
1409+
- MAY fail the channel
13481410

13491411
#### Rationale
13501412

@@ -1368,6 +1430,11 @@ it's simplest to only allow it to set fee levels; however, as the same
13681430
fee rate applies to HTLC transactions, the receiving node must also
13691431
care about the reasonableness of the fee.
13701432

1433+
If on-chain fees increase while commitments contain many HTLCs that will
1434+
be trimmed at the updated feerate, this could overflow the configured
1435+
`max_dust_htlc_exposure_msat`. Whether to close the channel preemptively
1436+
or not is left as a matter of node policy.
1437+
13711438
## Message Retransmission
13721439

13731440
Because communication transports are unreliable, and may need to be

0 commit comments

Comments
 (0)