<oembed><type>rich</type><version>1.0</version><author_name>npub19helcfnqgk2jrwzjex2aflq6jwfc8zd9uzzkwlgwhve7lykv23mq5zkvn4</author_name><author_url>https://nostr.ae/npub19helcfnqgk2jrwzjex2aflq6jwfc8zd9uzzkwlgwhve7lykv23mq5zkvn4</author_url><provider_name>njump</provider_name><provider_url>https://nostr.ae</provider_url><html>📅 Original date posted:2020-04-22&#xA;📝 Original message:&#xA;&gt; So what is needed is to allow B to add fees to HTLC-Timeout:&#xA;&#xA;Indeed, anchors as defined in #lightning-rfc/688 allows this.&#xA;&#xA;&gt;  * With `SIGHASH_NOINPUT` we can make the C-side signature&#xA;&gt;  `SIGHASH_NOINPUT|SIGHASH_SINGLE` and allow B to re-sign the B-side&#xA;&gt;  signature for a higher-fee version of HTLC-Timeout (assuming my cached&#xA;&gt;  understanding of `SIGHASH_NOINPUT` still holds).&#xA;&#xA;no_input isn&#39;t needed. With simply single+anyone can pay, then B can attach&#xA;a new input+output pair to increase the fees on their HTLC redemption&#xA;transaction. As you mention, they now enter into a race against this&#xA;malicious ndoe to bump up their fees in order to win over the other party.&#xA;&#xA;If the malicious node uses a non-RBF signalled transaction to sweep their&#xA;HTLC, then we enter into another level of race, but this time on the mempool&#xA;propagation level. However, if there exists a relay path to a miner running&#xA;full RBF, then B&#39;s higher fee rate spend will win over.&#xA;&#xA;-- Laolu&#xA;&#xA;On Tue, Apr 21, 2020 at 9:13 PM ZmnSCPxj via bitcoin-dev &lt;&#xA;bitcoin-dev at lists.linuxfoundation.org&gt; wrote:&#xA;&#xA;&gt; Good morning Matt, and list,&#xA;&gt;&#xA;&gt;&#xA;&gt;&#xA;&gt; &gt;     RBF Pinning HTLC Transactions (aka &#34;Oh, wait, I can steal funds,&#xA;&gt; how, now?&#34;)&#xA;&gt; &gt;     =============================&#xA;&gt; &gt;&#xA;&gt; &gt;     You&#39;ll note that in the discussion of RBF pinning we were pretty&#xA;&gt; broad, and that that discussion seems to in fact cover&#xA;&gt; &gt;     our HTLC outputs, at least when spent via (3) or (4). It does, and&#xA;&gt; in fact this is a pretty severe issue in today&#39;s&#xA;&gt; &gt;     lightning protocol [2]. A lightning counterparty (C, who received&#xA;&gt; the HTLC from B, who received it from A) today could,&#xA;&gt; &gt;     if B broadcasts the commitment transaction, spend an HTLC using the&#xA;&gt; preimage with a low-fee, RBF-disabled transaction.&#xA;&gt; &gt;     After a few blocks, A could claim the HTLC from B via the timeout&#xA;&gt; mechanism, and then after a few days, C could get the&#xA;&gt; &gt;     HTLC-claiming transaction mined via some out-of-band agreement with&#xA;&gt; a small miner. This leaves B short the HTLC value.&#xA;&gt;&#xA;&gt; My (cached) understanding is that, since RBF is signalled using&#xA;&gt; `nSequence`, any `OP_CHECKSEQUENCEVERIFY` also automatically imposes the&#xA;&gt; requirement &#34;must be RBF-enabled&#34;, including `&lt;0&gt; OP_CHECKSEQUENCEVERIFY`.&#xA;&gt; Adding that clause (2 bytes in witness if my math is correct) to the&#xA;&gt; hashlock branch may be sufficient to prevent C from making an RBF-disabled&#xA;&gt; transaction.&#xA;&gt;&#xA;&gt; But then you mention out-of-band agreements with miners, which basically&#xA;&gt; means the transaction might not be in the mempool at all, in which case the&#xA;&gt; vulnerability is not really about RBF or relay, but sheer economics.&#xA;&gt;&#xA;&gt; The payment is A-&gt;B-&gt;C, and the HTLC A-&gt;B must have a larger timeout (L +&#xA;&gt; 1) than the HTLC B-&gt;C (L), in abstract non-block units.&#xA;&gt; The vulnerability you are describing means that the current time must now&#xA;&gt; be L + 1 or greater (&#34;A could claim the HTLC from B via the timeout&#xA;&gt; mechanism&#34;, meaning the A-&gt;B HTLC has timed out already).&#xA;&gt;&#xA;&gt; If so, then the B-&gt;C transaction has already timed out in the past and can&#xA;&gt; be claimed in two ways, either via B timeout branch or C hashlock branch.&#xA;&gt; This sets up a game where B and C bid to miners to get their version of&#xA;&gt; reality committed onchain.&#xA;&gt; (We can neglect out-of-band agreements here; miners have the incentive to&#xA;&gt; publicly leak such agreements so that other potential bidders can offer&#xA;&gt; even higher fees for their versions of that transaction.)&#xA;&gt;&#xA;&gt; Before L+1, C has no incentive to bid, since placing any bid at all will&#xA;&gt; leak the preimage, which B can then turn around and use to spend from A,&#xA;&gt; and A and C cannot steal from B.&#xA;&gt;&#xA;&gt; Thus, B should ensure that *before* L+1, the HTLC-Timeout has been&#xA;&gt; committed onchain, which outright prevents this bidding war from even&#xA;&gt; starting.&#xA;&gt;&#xA;&gt; The issue then is that B is using a pre-signed HTLC-timeout, which is&#xA;&gt; needed since it is its commitment tx that was broadcast.&#xA;&gt; This prevents B from RBF-ing the HTLC-Timeout transaction.&#xA;&gt;&#xA;&gt; So what is needed is to allow B to add fees to HTLC-Timeout:&#xA;&gt;&#xA;&gt; * We can add an RBF carve-out output to HTLC-Timeout, at the cost of more&#xA;&gt; blockspace.&#xA;&gt; * With `SIGHASH_NOINPUT` we can make the C-side signature&#xA;&gt; `SIGHASH_NOINPUT|SIGHASH_SINGLE` and allow B to re-sign the B-side&#xA;&gt; signature for a higher-fee version of HTLC-Timeout (assuming my cached&#xA;&gt; understanding of `SIGHASH_NOINPUT` still holds).&#xA;&gt;&#xA;&gt; With this, B can exponentially increase the fee as L+1 approaches.&#xA;&gt; If B can get HTLC-Timeout confirmed before L+1, then C cannot steal the&#xA;&gt; HTLC value at all, since the UTXO it could steal from has already been&#xA;&gt; spent.&#xA;&gt;&#xA;&gt; In particular, it does not seem to me that it is necessary to change the&#xA;&gt; hashlock-branch transaction of C at all, since this mechanism is enough to&#xA;&gt; sidestep the issue (as I understand it).&#xA;&gt; But it does point to a need to make HTLC-Timeout (and possibly&#xA;&gt; symmetrically, HTLC-Success) also fee-bumpable.&#xA;&gt;&#xA;&gt; Note as well that this does not require a mempool: B can run in&#xA;&gt; `blocksonly` mode and as each block comes in from L to L+1, if HTLC-Timeout&#xA;&gt; is not confirmed, feebump HTLC-Timeout.&#xA;&gt; In particular, HTLC-Timeout comes into play only if B broadcast its own&#xA;&gt; commitment transaction, and B *should* be aware that it did so --- there is&#xA;&gt; still no need for mempool monitoring here.&#xA;&gt;&#xA;&gt;&#xA;&gt; Now, of course this only delays the war.&#xA;&gt; Let us now consider what C can do to ensure that the bidding war will&#xA;&gt; happen eventually.&#xA;&gt;&#xA;&gt; * C can bribe a miner to prevent HTLC-Timeout from confirming between L&#xA;&gt; and L+1.&#xA;&gt;   * Or in other words, this is a censorship attack.&#xA;&gt;     * The Bitcoin censorship-resistance model is that censored&#xA;&gt; transactions can be fee-bumped, which attracts non-censoring miners to try&#xA;&gt; their luck at mining and evict the censoring miner.&#xA;&gt;       * Thus, letting B bump the fee on HTLC-Timeout is precisely the&#xA;&gt; mechanism we need.&#xA;&gt;       * This sets up a bidding war between C requesting miners to censor,&#xA;&gt; vs. B requesting miners to confirm, but that only sets the stage for a&#xA;&gt; second bidding war later between C and B, thus C is at a disadvantage: it&#xA;&gt; has to bribe miners to censor continuously from L to L+1 *and* additional&#xA;&gt; bribe miners to confirm its transaction after L+1, whereas B can offer its&#xA;&gt; bribe as being something that miners can claim now without waiting after&#xA;&gt; L+1.&#xA;&gt;&#xA;&gt;&#xA;&gt;&#xA;&gt; The issue of course is the additional output that bloats the UTXO set and&#xA;&gt; requires another transaction to claim later.&#xA;&gt; And if we have `SIGHASH_NOINPUT`, it seems to me that&#xA;&gt; Decker-Russell-Osuntokun sidesteps this issue as well, as any timed-out&#xA;&gt; HTLC can be claimed with a fee-bumpable transaction directly without&#xA;&gt; RBF-carve-out.&#xA;&gt; (As well, it seems to me that, if both nodes support doing so, a&#xA;&gt; Poon-Dryja channel can be upgraded, without onchain activity, to a&#xA;&gt; Decker-Russell-Osuntokun channel: sign a transaction spending the funding&#xA;&gt; tx to a txo that has been set up as Decker-Russell-Osuntokun, do not&#xA;&gt; broadcast that transaction, then revoke the latest Poon-Dryja commitment&#xA;&gt; transactions, then switch the mechanism over to Decker-Russell-Osuntokun;&#xA;&gt; you still need to monitor for previous Poon-Dryja commitment transactions,&#xA;&gt; but HTLCs now sidestep the issue under discussion here.)&#xA;&gt;&#xA;&gt; Regards,&#xA;&gt; ZmnSCPxj&#xA;&gt; _______________________________________________&#xA;&gt; bitcoin-dev mailing list&#xA;&gt; bitcoin-dev at lists.linuxfoundation.org&#xA;&gt; https://lists.linuxfoundation.org/mailman/listinfo/bitcoin-dev&#xA;&gt;&#xA;-------------- next part --------------&#xA;An HTML attachment was scrubbed...&#xA;URL: &lt;http://lists.linuxfoundation.org/pipermail/lightning-dev/attachments/20200421/fd98ca19/attachment-0001.html&gt;</html></oembed>