Subject: Re: [bitcoindev] A "Free" Relay Attack Taking Advantage of The Lack of Full-RBF In Core

From: Peter Todd <[email-masked]>
Date: Mon, 22 Jul 2024 15:10:16 +0000

On Sat, Jul 20, 2024 at 07:10:53PM -0700, Antoine Riard wrote:
> 
> Hi Dave,
> 
> Thanks for your thoughtful answer (even if its wasn't addressed to me 
> primarly).
> 
> > I cannot imagine what would make you think that protocol developers are
> > not concerned about attacks that could drive large numbers of relay
> > nodes off the network for a cost easily affordable to any well-funded
> > adversary.
> 
> From my experience code reviewing the wallet / mempool re-broadcast of few
> years ago, free tx-relay / bandwidth waste attacks were far to be 
> understood 
> or plainly weighted by some contributors of a newer generations, including 
> by
> the own champion of the proposal. The proposal was finally abandonned when a
> more senior dev came up with quantitative analysis of code changes [0].
> 
> [0] https://github.com/bitcoin/bitcoin/pull/21061#issuecomment-851563105

An irony here is that rebroadcasting makes most "free" relay attacks *more*
expensive, not less. sdaftuar had some correct points, like avoiding bandwidth
spikes. But for any "free" relay attack based on broadcasting conflicting
transactions at different fee-rates, where the higher fee-rate transaction is
not mined, you get a better attack if the higher fee-rate transaction falls out
of node mempools, allowing the lower fee-rate conflict to be broadcast again.

If rebroadcasters ensure that nodes have the higher fee-rate tx, all you can do
to "reset" the attack is either get your UTXO(s) mined. Or use an even higher
fee-rate. Without rebroadcasting, you can wait for the expiry period to be
reached.

> > In this case, you've found a specific instance (full-RBF vs signaled
> > RBF) of a well-known general problem (optional policies leading to
> > mempool inconsistencies, allowing free relay) and appear to be arguing
> > that devs don't care about free relay because they refused to reverse a
> > previous decision (to not change the RBF configuration default) that has
> > been hotly debated multiple times.
> 
> I think what is more interesting and noteworhty in the whole line of 
> reaosning
> of Peter with the present disclosure is how much the adversial effect is 
> favor
> by the supermajority of miners running `mempoolfullrbf` [1].
> 
> [1] https://github.com/bitcoin/bitcoin/pull/28132#issue-1817178316

Not just miners: any node running with mempoolfullrbf=1 is going to waste less
bandwidth if someone actually does this attack. 

> Under those conditions, where it took 9 years for the bitcoin core project 
> to disclosre
> some vulnerabilitires, personally I'm more likely to understand that the 
> bitcoin core project
> is under-staffed is competent experts to keep public disclosure in 
> reasonable timeframe (-- at
> least equivalent to the kernel world), and as corollorary to fully evaluate 
> technical proposal
> with all its strength and weaknesses.
> 
> Saying an "already overdiscussed issues that gets nobody closer to 
> fundamental solutions" is
> insulting for Peter, honestly.

Indeed. You'd think solid evidence, trivially verifiable by anyone, that almost
all miners had adopted full-rbf would be enough. Instead that evidence doesn't
even receive any acknowledgement.

> As an offchain protocol developers which has been involved in the majority 
> of technical conversations,
> implementations and deployment of the "anchor output" upgrade, I believe on 
> the long-term CPFP-style fee-bumping
> of contract protocol, including lighting, is not the most robust technical 
> solutions. I think anyone can check
> in the bitcoin optech anchor output glossary the numerous vulnerabilities 
> that have plagued this fee-bumping 
> solutions over the past years.

RBF is way underused in protocols in general. And there have probably been
literally millions of dollars wasted on fees spent by inefficient CPFP
solutions when RBF (via pre-signed transactions) could have been used instead.
This financial figure will only get higher as Lightning gets more adoption. It
also limits Lightning in mass failure scenarios: every byte saved while force
closing a channel is room that could be used to force close another channel.

> I already reviewed some parts of cluster mempool. Fundamentally, economical 
> mempool pinnings for second-layers (bip125 absolute
> fee) with pre-signed time-sensitive transactions arises from a world where 
> there is (a) an asynchronicity of mempools and (b) one
> cannot guess feerates at block + 1 (-- let's say in a deterministic fashion 
> as understood by traditional cryptographic litterature
> when doing cryptanalysis). Better RBF policies won't solve that, including 
> RBFr.

I have to disagree here. The nature of protocols like Lightning is there is a
maximum amount that it's worth attempting to pay to get a transaction mined to
perform some action. There also a deadline to perform that action.

For example, an HTLC has a clear expiry time and value. *Even if* you have no
idea what fee-rates are needed to get a transaction mined, you can simply do
repeated RBF bumps at higher and higher fee-rates, ending at a fee-rate that
spends the entire value of the HTLC. As long as you do in fact have uncensored
access to miner mempools - as long as you haven't been sybil attacked - this
approach will do about as well as is possible, modulo pinning attacks. So our
job is now to simply fix the pinning attacks with better RBF policy.

IIUC, this RBF fee-bumping approach is exactly what the RBF sweeper introduced
in LND v0.18 does. Face with, eg, high blockspace demand the sum total of LND
RBF sweepers will result in the most valuable HTLCs and similar things being
mined, while less valuable transactions don't (ignoring pinning of course).
That's fine! That's the best we can do given a limited blockspace.

Traditional cryptography literature is not relevant here, as it's based on the
difficulty of mathematical problems, not economics; the security of L2
protocols is based on economics.

-- 
https://petertodd.org 'peter'[:-1]@petertodd.org

-- 
You received this message because you are subscribed to the Google Groups "Bitcoin Development Mailing List" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [email-masked].
To view this discussion on the web visit https://groups.google.com/d/msgid/bitcoindev/Zp52WDL4hV16CbKV%40petertodd.org.