Research/Bitcoin Dev Archive / lightning-dev list
RBF Pinning with Counterparties and Competing Interest
3 messages, Apr 22 to 23, 2020. Started by Matt Corallo.
Matt Corallo, David A. Harding, ZmnSCPxj
Hmm, that's an interesting suggestion, it definitely raises the bar for attack execution rather significantly. Because lightning (and other second-layer systems) already relies heavily on uncensored access to blockchain data, its reasonable to extend the "if you don't have enough blocks, aggressively query various sources to find new blocks, or, really just do it always" solution to "also send relevant transactions while we're at it".
Sadly, unlike for block data, there is no consensus mechanism for nodes to ensure the transactions in their mempools are the same as others. Thus, if you focus on sending the pinning transaction to miner nodes directly (which isn't trivial, but also not nearly as hard as it sounds), you could still pull off the attack. However, to do it now, you'd need to wait for your counterparty to broadcast the corresponding timeout transaction (once it is confirmable, and can thus get into mempools), turning the whole thing into a mempool-acceptance race. Luckily there isn’t much cost to *trying*, though it’s less likely you’ll succeed.
There are also practical design issues - if you’re claiming multiple HTLC output in a single transaction the node would need to provide reject messages for each input which is conflicted, something which we’d need to think hard about the DoS implications of.
In any case, while it’s definitely better than nothing, it’s unclear if it’s really the kind of thing I’d want to rely on for my own funds.
Matt
Quoted text (31 lines)
> On 4/22/20 2:24 PM, David A. Harding wrote:
>> On Mon, Apr 20, 2020 at 10:43:14PM -0400, Matt Corallo via Lightning-dev wrote:
>> A lightning counterparty (C, who received the HTLC from B, who
>> received it from A) today could, if B broadcasts the commitment
>> transaction, spend an HTLC using the preimage with a low-fee,
>> RBF-disabled transaction. After a few blocks, A could claim the HTLC
>> from B via the timeout mechanism, and then after a few days, C could
>> get the HTLC-claiming transaction mined via some out-of-band agreement
>> with a small miner. This leaves B short the HTLC value.
>
> IIUC, the main problem is honest Bob will broadcast a transaction
> without realizing it conflicts with a pinned transaction that's already
> in most node's mempools. If Bob knew about the pinned transaction and
> could get a copy of it, he'd be fine.
>
> In that case, would it be worth re-implementing something like a BIP61
> reject message but with an extension that returns the txids of any
> conflicts? For example, when Bob connects to a bunch of Bitcoin nodes
> and sends his conflicting transaction, the nodes would reply with
> something like "rejected: code 123: conflicts with txid 0123...cdef".
> Bob could then reply with a a getdata('tx', '0123...cdef') to get the
> pinned transaction, parse out its preimage, and resolve the HTLC.
>
> This approach isn't perfect (if it even makes sense at all---I could be
> misunderstanding the problem) because one of the problems that caused
> BIP61 to be disabled in Bitcoin Core was its unreliability, but I think
> if Bob had at least one honest peer that had the pinned transaction in
> its mempool and which implemented reject-with-conflicting-txid, Bob
> might be ok.
>
> -DaveOn Wed, Apr 22, 2020 at 03:53:37PM -0700, Matt Corallo wrote:
Quoted text (3 lines)
> if you focus on sending the pinning transaction to miner nodes > directly (which isn't trivial, but also not nearly as hard as it > sounds), you could still pull off the attack.
If the problem is that miners might have information not available to the network in general, you could just bribe them for that knowledge. E.g. as Bob's refund deadline approaches and he begins to suspect that mempool shenanigans are preventing his refund transaction from confirming, he takes a confirmed P2WPKH UTXO he's been saving for use in CPFP fee bumps and spends part of its value (say 1 mBTC) to the following scriptPubKey[1],
OP_SHA256 <hash_whose_preimage_bob_wants> OP_EQUAL
Assuming the feerate and the bribe amount are reasonable, any miner who knows the preimage is incentivized to include Bob's transaction and a child transation spending from it in their next block. That child transaction will include the preimage, which Bob will see when he processes the block.
If any non-miner knows the preimage, they can also create that child transaction. The non-miner probably can't profit from this---miners can just rewrite the child transaction to pay themselves since there's no key-based security---but the non-miner can at least pat themselves on the back for being a good Summaritan. Again Bob will learn the preimage once the child transaction is included in a block, or earlier if his wallet is monitoring for relays of spends from his parent transaction.
Moreover, Bob can first create a bribe via LN and, in that case, things are even better. As Bob's deadline approaches, he uses one of his still-working channels to send a bunch of max-length (20 hops?) probes that reuse the earlier HTLC's <hash>. If any hop along the path knows the preimage, they can immediately claim the probe amount (and any routing fees that were allocated to subsequent hops). This not only gives smaller miners with LN nodes an equal chance of claiming the probe-bribe as larger miners, but it also allows non-miners to profit from learning the preimage from miners.
That last part is useful because even if, as in your example, the adversary is able to send one version of the transaction just to miners (with the preimage) and another conflicting version to all relay nodes (without the preimage), miners will naturally attempt to relay the preimage version of the transaction to other users; if some of those users run modified nodes that write all 32-byte witness data blobs to a database---even if the transaction is ultimately rejected as a conflict---then targetted relay to miners may not be effective at preventing Bob from learning the preimage.
Obviously all of the above requires people run additional software to keep track of potential preimages[2] and then compare them to hash candidates, plus it requires additional complexity in LN clients, so I can easily understand why it might be less desirable than the protocol changes under discussion in other parts of this thread. Still, with lots of effort already being put into watchtowers and other enforcement-assistance services, I wonder if this problem can be largely addressed in the same general way.
-Dave
[1] Requires a change to standard relay and mining policy. [2] Pretty easy, e.g.
bitcoin-cli getrawmempool \
| jq -r .[] \
| while read txid ; do
bitcoin-cli getrawtransaction $txid true | jq .vout[].scriptPubKey.asm
done \
| grep -o '\<[0-9a-f]\{64\}\>'Good morning David,
Unfortunately this technique does not look like it is compatible to payment points rather than hashes, and we would really like to upgrade to payment points sooner rather than later. Nobody but B can recognize the signature as revealing the scalar behind a particular point (the main privacy advantage of using points). Even variations on this are not useable with payment points.
Regards, ZmnSCPxj
Quoted text (74 lines)
> On Wed, Apr 22, 2020 at 03:53:37PM -0700, Matt Corallo wrote:
>
> > if you focus on sending the pinning transaction to miner nodes
> > directly (which isn't trivial, but also not nearly as hard as it
> > sounds), you could still pull off the attack.
>
> If the problem is that miners might have information not available to
> the network in general, you could just bribe them for that knowledge.
> E.g. as Bob's refund deadline approaches and he begins to suspect that
> mempool shenanigans are preventing his refund transaction from
> confirming, he takes a confirmed P2WPKH UTXO he's been saving for use in
> CPFP fee bumps and spends part of its value (say 1 mBTC) to the
> following scriptPubKey[1],
>
> OP_SHA256 <hash_whose_preimage_bob_wants> OP_EQUAL
>
> Assuming the feerate and the bribe amount are reasonable, any miner who
> knows the preimage is incentivized to include Bob's transaction and a
> child transation spending from it in their next block. That child
> transaction will include the preimage, which Bob will see when he
> processes the block.
>
> If any non-miner knows the preimage, they can also create that child
> transaction. The non-miner probably can't profit from this---miners can
> just rewrite the child transaction to pay themselves since there's no
> key-based security---but the non-miner can at least pat themselves on
> the back for being a good Summaritan. Again Bob will learn the preimage
> once the child transaction is included in a block, or earlier if his
> wallet is monitoring for relays of spends from his parent transaction.
>
> Moreover, Bob can first create a bribe via LN and, in that case, things
> are even better. As Bob's deadline approaches, he uses one of his
> still-working channels to send a bunch of max-length (20 hops?) probes
> that reuse the earlier HTLC's <hash>. If any hop along the path knows
> the preimage, they can immediately claim the probe amount (and any
> routing fees that were allocated to subsequent hops). This not only
> gives smaller miners with LN nodes an equal chance of claiming the
> probe-bribe as larger miners, but it also allows non-miners to profit
> from learning the preimage from miners.
>
> That last part is useful because even if, as in your example, the
> adversary is able to send one version of the transaction just to miners
> (with the preimage) and another conflicting version to all relay nodes
> (without the preimage), miners will naturally attempt to relay the
> preimage version of the transaction to other users; if some of those
> users run modified nodes that write all 32-byte witness data blobs to a
> database---even if the transaction is ultimately rejected as a
> conflict---then targetted relay to miners may not be effective at
> preventing Bob from learning the preimage.
>
> Obviously all of the above requires people run additional software to
> keep track of potential preimages[2] and then compare them to hash
> candidates, plus it requires additional complexity in LN clients, so I
> can easily understand why it might be less desirable than the protocol
> changes under discussion in other parts of this thread. Still, with
> lots of effort already being put into watchtowers and other
> enforcement-assistance services, I wonder if this problem can be largely
> addressed in the same general way.
>
> -Dave
>
> [1] Requires a change to standard relay and mining policy.
> [2] Pretty easy, e.g.
>
> bitcoin-cli getrawmempool \
> | jq -r .[] \
> | while read txid ; do
> bitcoin-cli getrawtransaction $txid true | jq .vout[].scriptPubKey.asm
> done \
> | grep -o '\<[0-9a-f]\{64\}\>'
>
> Lightning-dev mailing list
> Lightning-dev at lists.linuxfoundation.org
> https://www.learnbitcoin.com/archive/lists/lightning-dev