Repository navigation
net: send decoy transactions via private broadcast - #35252
andrewtoth wants to merge 3 commits into
Conversation
The private broadcast thread is currently only started when -privatebroadcast is set. Decouple thread startup from that configuration option so that the same connection machinery can be reused for decoys.
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. Code Coverage & BenchmarksFor details see: https://corecheck.dev/bitcoin/bitcoin/pulls/35252. ReviewsSee the guideline and AI policy for information on the review process.
If your review is incorrectly listed, please copy-paste ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Concept ACK Correct me if I'm wrong, but with this change, then that transaction will be forwarded twice from the same node, once via flood and another via private broadcast? Wouldn't this add additional network load for nodes, albeit small, considering it is one transaction every 6 hours? I like the idea, just worth considering if it does add more bandwidth usage. |
On average it would be once every 3 hours. |
It would be interesting to measure how well this works. If you are not well connected, for example because you only have 8 transaction relaying outbound connections (which receive invs slower than the inbounds you get) as a home node, you might pick decoys a large part of the network already knows about (especially if it's a high feerate transaction, as these propagate faster). Since the other side wouldn't request these if already in mempool, it's able to tell that these are decoys. This can be measured by running this PR and counting how many of the decoy transactions are actually requested from you. It might make sense to do this both for listening and non-listening nodes. For testing, a higher rate of decoys is probably useful: e.g. send a decoy every 5min. |
…dcast Randomly on average once every 3 hours, open one extra private broadcast connection and announce the most recent mempool transaction.
|
Wouldn't any attacker interested in the origin of txns so much that they would run a large-scale Sybil attack almost certainly also have a permanent connection to each reachable node (which is easier and cheaper) - so that the proposed solution would be ineffective because the attacker very likely would already know about the last mempool transaction? |
|
Also, I think it would be good to discuss the general issue this is addressing: Why is it bad if an attacker knows that private broadcast was used for a tx if they can't know the sender? |
@0xB10C @mzumsande addressing these comments together since they are essentially the same question. The way private broadcast works today is a user-submitted transaction immediately triggers 3 connections. These are opened sequentially, without waiting for the previous connection to complete. They are only stopped if we receive the transaction back from the network before they all get opened. What happens very often in practice is the first connection successfully transmits the tx, and the recipient node broadcasts it to all its peers. But, the sender has not yet received the tx back from one of its peers. The second connection now sends an inv to a node that has already received the tx from the first recipient node, and the second connection does not get a getdata in response and times out after 3 minutes. So today, the two cases for an observer are as follows:
For both scenarios 1 and 2, with decoys the observer can no longer be certain whether the tx was a user-submitted private broadcast or not. Both of these comments are describing scenario 2, which already occurs on the network today and fingerprints transactions that have already been received.
I ran with a small patch overnight that sent decoys every 5 minutes, with some small stat gathering. I ran it on one well connected listening node and a node running with just a single connection to a trusted peer. Interestingly, the singly connected node had more success with receiving getdata responses than the well connected node. So, I think there are a lot of variables in play. Well-connected listening peer:
Since private broadcast is an opt-in feature, any private broadcast transactions are fingerprinted. This is another vector for correlating transactions into common ownership.
I didn't consider this, but decoys effectively nullify this risk as well. There is also the angle of traffic analysis. If private broadcast connection patterns are discernable to a network observer, they can use timing analysis to figure out which node sent a tx. And finally, if a node's debug logs are leaked, the |
| void ReattemptPrivateBroadcast(CScheduler& scheduler); | ||
|
|
||
| /** Periodically open one extra private broadcast connection and send the most recent tx in the mempool */ | ||
| void InitiatePrivateBroadcastDecoy(CScheduler& scheduler); |
There was a problem hiding this comment.
Would it not be possible to implement this in a simpler way by pushing the tx to the already existent private broadcast pipeline, like non-decoys. I mean this:
[patch] Send decoy as a normal private broadcast
--- i/src/net_processing.cpp
+++ w/src/net_processing.cpp
@@ -4451,12 +4451,16 @@ void PeerManagerImpl::ProcessMessage(Peer& peer, CNode& pfrom, const std::string
const MempoolAcceptResult result = m_chainman.ProcessTransaction(ptx);
const TxValidationState& state = result.m_state;
if (result.m_result_type == MempoolAcceptResult::ResultType::VALID) {
ProcessValidTx(pfrom.GetId(), ptx, result.m_replaced_transactions);
pfrom.m_last_tx_time = GetTime<std::chrono::seconds>();
+
+ if (it is time for a new decoy, once in about 24h) {
+ InitiateTxBroadcastPrivate(ptx);
+ }
}
if (state.IsInvalid()) {
if (auto package_to_validate{ProcessInvalidTx(pfrom.GetId(), ptx, state, /*first_time_failure=*/true)}) {
const auto package_result{ProcessNewPackage(m_chainman.ActiveChainstate(), m_mempool, package_to_valid
LogDebug(BCLog::TXPACKAGES, "package evaluation for %s: %s\n", package_to_validate->ToString(),
package_result.m_state.IsValid() ? "package accepted" : "package rejected");that is quickly after we receive the NetMsgType::TX message. That should also be sooner than the current PR approach of picking from the mempool and will probably increase the rate where we do get GETDATA for the tx over the private broadcast connection.
Also, the current approach in this PR of scheduling just 1 connection per decoy could mess with a non-decoy private broadcast (which schedules 3 connections) - when we receive back the transaction we do assume 3 connections were fired and check how many times it was broadcasted, e.g. 1 and then reduce the connections by 3-1=2. So, after receiving back the decoy it will wrongly reduce by 2 and will hurt non-decoys.
There was a problem hiding this comment.
That should also be sooner than the current PR approach of picking from the mempool and will probably increase the rate where we do get GETDATA for the tx over the private broadcast connection.
I don't think so, because we would have to pick this tx before we make the private broadcast connection. With the current approach here, we make a private broadcast connection and complete the handshake before choosing the tx. Only right before we send the inv do we select the top mempool tx.
| /** Private broadcast connections must complete within this time. Disconnect the peer if it takes longer. */ | ||
| static constexpr auto PRIVATE_BROADCAST_MAX_CONNECTION_LIFETIME{3min}; | ||
| /** Average interval between private broadcast decoy attempts */ | ||
| static constexpr auto PRIVATE_BROADCAST_DECOY_INTERVAL{3h}; |
There was a problem hiding this comment.
I think 3h is too aggressive. If we have 10k nodes, each one decoying every 3 hours, then there will be a decoy on the network approximately every second.
| } | ||
|
|
||
| if (gArgs.GetBoolArg("-privatebroadcast", DEFAULT_PRIVATE_BROADCAST)) { | ||
| if (connOptions.m_start_private_broadcast_thread) { |
There was a problem hiding this comment.
The intention here I guess is to do the decoys even if -privatebroadcast=0.
The semantic of -privatebroadcast=1 is "send my transactions in a private way" and I think it is good to keep it that way.
Should the users be given the option to switch off the decoys?
|
🐙 This pull request conflicts with the target branch and needs rebase. |
Unfortunately I discovered a flaw with my methodology here. This was succeeding because there are many reachable nodes on the network with a different relay policy than what I was testing with. So sending a tx with a fee of <1 sat/vbyte to any node <30 would always succeed. When walking down the top of the mempool to pick the first tx with fee rate >= 1 sat/vbyte, the success rate of receiving a getdata dropped to < 10%. I suspect the remaining successful txs were due to connecting to nodes that reject the tx as non-standard due to some other policy difference. So, it seems this way of sending decoys is ineffective. Closing. |
The private broadcast feature removes the link between a transaction and its originating node IP or onion address. However, a passive observer with a large number of sybil nodes can still fingerprint transactions that are broadcast via private broadcast. Any recipient of a transaction via a private broadcast connection can be certain that it was deliberately sent via private broadcast.
This PR introduces private broadcast decoy connections. Randomly on average once every 3 hours, any node with Tor or I2P reachable opens an extra private broadcast connection. Instead of one of the node's own pending transactions, the connection announces the most recent transaction in the mempool. Because of normal transaction relay latency, the recipient may not have seen that transaction yet, and from its point of view the connection is indistinguishable from a user-submitted private broadcast. If the recipient already has the transaction, the private broadcast will timeout after 3 minutes. In this case there is still plausible deniability since this mimics user-submitted transactions. We open 3 connections for each submitted transaction. After the first successful connection the other connections may connect to nodes that have already received the transaction from the first recipient.
-blocksonlynodes are excluded. If the mempool is empty, no decoy is sent that round.Every user-submitted private broadcast now has plausible deniability of being a decoy.
This makes it more difficult for a network-level observer to distinguish the traffic pattern of a user-submitted broadcast from a decoy.
Log lines such as
still appear, but they no longer distinguish user-submitted transactions from decoys.