Skip to content
LearnBitcoin

ResearchBitcoin Dev Archive lightning-dev list

Miners Dust Inflation attacks on Lightning Network

4 messages, May 18 to 20, 2020. Started by Antoine Riard.

Antoine Riard (2), ZmnSCPxj (2)

Permalink First message in the Wayback Machine

Antoine Riard permalink original

Lightning protocol supports a floating dust output selection at channel creation, where each party declares a dust parameter applying to its local transactions. The current spec doesn't enforce or recommend any bound on this value, beyond the requirement of being lower that `channel_reserve_satoshis`. When a HTLC is routed through the channel but its value is under the local party dust limit, it's burned as fees and not added to the commitment transaction. This rule, which makes LN a good citizen of the Bitcoin blockchain comes at the price of more trust in your counterparty..

Let's consider the following scenario. Mallory announces a channel to Alice with dust-limit-satoshi set to 20% of channel value. Alice should accept incoming channels as long as its under her implementation-specific `max_dust_limit_satoshis`. Now Mallory can route 4 dust-HTLCs to Mallet through Alice claiming ~80% of channel value.

        Mallory --> Alice --> Mallet

Mallet, in collusion with Mallory, can claim the whole set of HTLCs by revealing the corresponding preimage for each. At the exact same time, Mallory broadcast her latest commitment transaction on which there is _no_ HTLCs because all of them are dust. Alice can't claim them onchain but has already paid Mallet forward.

At first-look, this attack doesn't seem economically rational because dust-HTLCs are all committed as fees. But if you assume that Mallory can collude with some mining pool, economics change completely because it's now a almost zero-cost to add Mallory commitment transaction in a block, hashrate won't be wasted. Fees are going back to the miner, and Alice is still robbed. Mallory commitment transaction may stay in miner pool as long block isn't found, without being announced to the rest of the network, and HTLCs timelocks don't expire. Attack may still stealth if block isn't signed. It's almost a zero-cost because if you assume block being full, commitment transaction is now competing for block space and there is an opportunity cost.

It's that kind of low-probability-and-hard-to-exploit-vulnerability but you would prefer not having to think about your big LSP hub being targeted by a rogue mining pool employee. Even if it's a really small mining pool, you may batch the attack on multiple channels at once for one block found.

Deployment of Stratum V2 may make the attack easier by giving more leverage to the local miner.

Mitigating may come by negotiating a new `max_dust_htlc_value_in_flight_msat` enforced by HTLC recipient, therefore expressing its maximum trust tolerance with regards to dust. Bearing a cost on a HTLC holder will also render the attack more expensive, even if for counter-measure efficiency you likely need a different order of magnitude that spam-protection.

Cheers,

Antoine

ZmnSCPxj in reply to Antoine Riard permalink original

Good morning Antoine,

Quoted text (1 line)
> Mitigating may come by negotiating a new `max_dust_htlc_value_in_flight_msat` enforced by HTLC recipient, therefore expressing its maximum trust tolerance with regards to dust. Bearing a cost on a HTLC holder will also render the attack more expensive, even if for counter-measure efficiency you likely need a different order of magnitude that spam-protection.

Even without a spec change, such a setting may be enforced by a forwarding node by the simple act of refusing to forward an HTLC once a certain level of incoming dust HTLCs are currently in-flight. That is, the forwarding node can simply accept the incoming new dusty HTLC, but instead of forwarding, claim a `temporary_channel_failure` on the next channel. The attack requires that the forwarding node actually forward the HTLC, after all.

This will of course lead to reduced reliability on micropayments.

Adding this to the spec does have the advantage that an honest forwarder can hold an HTLC for a while once it notices that the next hop has a bunch of dusty HTLCs in-flight that are beyond the negotiated `max_dust_htlc_value_in_flight_msat`, which might help reliability of micropayments slightly, but there is still the reduction of reliability. Not to mention that the easiest code change to respect such a limit would be simply to fail forwarding anyway.

Regards, ZmnSCPxj

Antoine Riard in reply to ZmnSCPxj permalink original

Hi ZmnSCPxj,

As of today, you can setup a `htlc_minimum_msat` higher than remote's `dust_limit_satoshis`, but you don't necessarily know it before announcing your channel parameters if you're initiator. In practice, assuming you can do so, with fees going higher and HTLC outputs being encumbered, their cost-to-spend will increase so forbidding dust HTLC will outlaw low-value payments, which them are a constant.

Quoted text (5 lines)
> Adding this to the spec does have the advantage that an honest forwarder
can hold an HTLC for a while once it notices that the next hop has a bunch
of dusty HTLCs in-flight that are beyond the negotiated
`max_dust_htlc_value_in_flight_msat`, which might help reliability of
micropayments slightly, but there is still the reduction of reliability.

I agree you can already fail HTLC as a local forwarding policy, which is not great for reliability. So you may have either a negotiated `max_dust_htlc_value_in_flight_msat` or refuse an `open_channel`/`accept_channel` by receiver considering remote's `dust_limit_satoshi` too high.

I do think that's a pretty low-risk scenario but that would be better if implementations somehow bound in-flight dust to lower attack incentive.

Antoine

Le lun. 18 mai 2020 à 20:52, ZmnSCPxj <ZmnSCPxj at protonmail.com> a écrit :

Quoted text (32 lines)
> Good morning Antoine,
>
>
> > Mitigating may come by negotiating a new
> `max_dust_htlc_value_in_flight_msat` enforced by HTLC recipient, therefore
> expressing its maximum trust tolerance with regards to dust. Bearing a cost
> on a HTLC holder will also render the attack more expensive, even if for
> counter-measure efficiency you likely need a different order of magnitude
> that spam-protection.
>
> Even without a spec change, such a setting may be enforced by a forwarding
> node by the simple act of refusing to forward an HTLC once a certain level
> of incoming dust HTLCs are currently in-flight.
> That is, the forwarding node can simply accept the incoming new dusty
> HTLC, but instead of forwarding, claim a `temporary_channel_failure` on the
> next channel.
> The attack requires that the forwarding node actually forward the HTLC,
> after all.
>
> This will of course lead to reduced reliability on micropayments.
>
> Adding this to the spec does have the advantage that an honest forwarder
> can hold an HTLC for a while once it notices that the next hop has a bunch
> of dusty HTLCs in-flight that are beyond the negotiated
> `max_dust_htlc_value_in_flight_msat`, which might help reliability of
> micropayments slightly, but there is still the reduction of reliability.
> Not to mention that the easiest code change to respect such a limit would
> be simply to fail forwarding anyway.
>
> Regards,
> ZmnSCPxj
>
ZmnSCPxj in reply to Antoine Riard permalink original

Good morning Antoine,

As well, I considered doing state machine shenanigans for this (do not sign for removal of HTLC in your outgoing channel until you have irrevocable removal of HTLC in your incoming channel) but this does not work since if you already have a miner willing to cooperate with you and which you can plausibly believe will share the amount with you, the miner can recover the funds by simply closing the outgoing channel as well.

Quoted text (8 lines)
> Hi ZmnSCPxj,
> As of today, you can setup a `htlc_minimum_msat` higher than remote's `dust_limit_satoshis`, but you don't necessarily know it before announcing your channel parameters if you're initiator.
> In practice, assuming you can do so, with fees going higher and HTLC outputs being encumbered, their cost-to-spend will increase so forbidding dust HTLC will outlaw low-value payments, which them are a constant.
>
> > Adding this to the spec does have the advantage that an honest forwarder can hold an HTLC for a while once it notices that the next hop has a bunch of dusty HTLCs in-flight that are beyond the negotiated `max_dust_htlc_value_in_flight_msat`, which might help reliability of micropayments slightly, but there is still the reduction of reliability.
>
> I agree you can already fail HTLC as a local forwarding policy, which is not great for reliability. So you may have either a negotiated `max_dust_htlc_value_in_flight_msat` or refuse an `open_channel`/`accept_channel` by receiver considering remote's  `dust_limit_satoshi` too high.
> I do think that's a pretty low-risk scenario but that would be better if implementations somehow bound in-flight dust to lower attack incentive.

Even if such a limit is negotiated it seems reliability is still reduced --- if the limit is too low in practice then it would be easy for the micropayment bandwidth to be saturated anyway and such tiny payments will not push through. It is still slightly better though.

Regards, ZmnSCPxj