Repository navigation
net: reimplement private broadcast as jobs isolated from the node - #36628
instagibbs wants to merge 16 commits into
Conversation
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. External sites
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. LLM Linter (✨ experimental)Possible internal implementation names in log messages:
2026-10-28 16:16:48 |
2963fb9 to
1e77d86
Compare
1e77d86 to
d55fafe
Compare
a63525b to
19f9cd7
Compare
|
This PR's tests do not check that each attempt gets its own VERSION nonce, PING nonce and BIP324 key (A4 in On 19f9cd7 I made each of these values a constant for the whole process, one line in Your follow-up branch already checks all three, in |
|
@fametrano willing to be convinced to move particular items to this PR, but I'm really focusing on IP address level leaks for the first PR. Preventing cross-attempt or cross-tx fingerprinting is a secondary goal, and hard to achieve arbitrary level of assurances, hence its deferral. edit: changed my mind and brought it forward |
19f9cd7 to
22590cf
Compare
|
I find the following not acceptable: Relying on DNS seedsCurrently DNS seeds are used only to bootstrap a new node. That happens once in its lifetime and there is a fallback mechanism if the DNS seeds do not work. We never rely solely only on DNS seeds for something. They are centralized services.
I do not think that it is reasonable to start relying on a few servers permanently (not just once in a lifetime, but every time a node wants to privately broadcast a transaction). This means that if a few operators decide to switch off (or misbehave) their services then everybody on the network is obstructed from privately broadcasting their transactions. That resembles more a client-server architecture than a decentralized P2P network. Not broadcasting to Tor or I2P peersOnly broadcasting to IP peers via the Tor network would make the feature too fragile - it would rely on the Tor network and the Tor exit nodes working properly. The Tor network has been down in the past. I think it is important to have a fallback mechanism which currently is the I2P network. Also, right now we do not rely on the Tor exit nodes. We could broadcast a transaction within the Tor network to an Even moderate adoption of private broadcast in its current form improves the privacy of everybody because everybody could be a recipient. Privacy is improved even for nodes that broadcast-to-all. That would be spoiled if we only send to IP peers. Note that a private broadcast recipient would further broadcast-to-all the newly received transaction in a way that is indistinguishable from them being the transaction originator. So an observer can no longer tell whether a node is the original sender or was a recipient of a private broadcast. For this to work everybody must be a potential private broadcast recipient. |
8816dd5 to
26ef29f
Compare
If the seeds go offline, private broadcast stops; it doesn't leak. If they misbehave, the most they can do is pick recipients that drop the transaction. They can't learn who is sending. The alternative of picking Tor/i2p peers from addrman as master does, is not an answer anyone should be happy with. Today we give attackers significant influence over choices being made by victim. Peers can be influenced, by design, into dialing to peers that are unique fingerprints, with the attacker writing to their addrman. Tor isn't decentralized either, but we accept utility in terms of privacy.
Currently in master, it makes sybiling victims much easier, which results in an IP address leak, which is an unfortunate side-effect of the current architecture. Assuming we adopted something like this PR, then we would have to introduce a "just in time" gathering of addresses, which would still be going through seeder nodes, or again, reintroducing fundamental leaks via local addrman usage. No free lunch here.
The attacks it resists are quite limited today, and therefore it's sort of in purgatory where we can't make any promises about it. That's quite sad, and completely avoidable. |
26ef29f to
f547e5e
Compare
ajtowns
left a comment
There was a problem hiding this comment.
The design doc looks AI written; is it meant for human or agentic consumption? Shouldn't it be a BIP, or at least posted to the mailing list for broader discussion on exactly the sort of tradeoffs vasild raises above?
+6k lines (+3.5k -1k under src excluding test) seems like a lot. Presumably also AI written with light human review?
If the idea is to separate this from the node, it seems like having a separate binary interacting lightly with the node might be a better structure. Something like: a "bitcoin-privbcast" binary, connects only over i2p/tor, keeps it own addrman independent from the node, initially populated from dns seeds, perhaps updated in some way (again, independent of the node), bitcoind wallet sends private broadcast txs via bitcoin-privbcast's stdin, and then just monitors for them to appear in the mempool (and sends a cancel message to privbcast's stdin when that occurs), and bitcoin-privbcast rate limits, retries, expires them itself to avoid send bursts correlating with the node restarting.
That approach would allow people with higher or different tx privacy goals to replace the privbcast binary with something custom if desired (eg to make different tradeoffs about addr handling, or using tor exit nodes, etc), without needing to modify bitcoind source.
| * relay false. | ||
| */ | ||
| inline constexpr int PROFILE_VERSION{70017}; | ||
| static_assert(PROFILE_VERSION == PROTOCOL_VERSION, "the profile's version tracks the release"); |
There was a problem hiding this comment.
70016 is what current private broadcast versions track, and avoiding varying these things across releases is exactly why we have a special profile.
There was a problem hiding this comment.
yeah this is a bad comment and probably not needed, it should not update as a profile break which is what the static assert is for.... will change. Tests would have failed on change.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
The PR text is AI written, curated a number of times under my direction as the primary document. I think there's great value for both humans and AI. It doesn't have to be in the merged branch.
I think there's definitely value increasing anonymity set if nothing else. By the same token, the current implementation should have gone through a BIP process, for exactly the same reasons.
Originally I designed it as a separate tool, but I was hoping for a like-for-like replacement. However the architecture lends itself just fine to it, as the only coupled code in this PR to the node is the queue portion. An "addrman but not node's addrman" is another design quest, because resisting cross-tx correlation, while a secondary goal, is worth trying to preserve under adversaries.
This is a leak. I prefer bounded tries. We could have it do retries based on block non-inclusion or some other criteria that isn't a clear fingerprint, e.g., not enough peers asking for the tx itself. |
|
Concept ACK. |
Definitely worth putting in a hand-written design doc that's not targeting reimplementation and I had one before (that suffered rot due to churn). But I think the crux of the current arguments currently don't rest on that document, |
|
To be perfectly clear I believe separating the node state as much as possible from private broadcast is the correct goal. However, I shared some concerns about this approach in an earlier draft here instagibbs#7 (comment), and the same concerns were raised independently by vasild here #36628 (comment). I don't think using the built-in DNS seeds to source addresses for private broadcast is the right approach, and I don't think we should drop i2p or direct tor onion connections. The latter concern doesn't seem to continue to make sense if we successfully execute separating the rest of the state. Regarding the former concern: as of today that would require us to continue using addrman. Since this is an experimental feature, I don't think we need to rush to a solution. I don't think this needs to be done by v33, and we can brainstorm for other ways to better source addresses. IMO supplying addresses is also a better interface for a tool, since other consumers could source addresses how they wish (say just give the tool mempool.space's node IPs) without dependence on the built-in seeds. Are these two tradeoffs acceptable, while taking the rest of the patch? I'm not sure. I understand the security team needs to use discretion when discussing possible vulnerabilities, but the status quo here is quite frustrating I'm sure for both sides. How can we know if the issue with only addrman or tor onions or i2p are realistically exploitable?
From the attacks I've seen, the only ones that have not been patched require an attacker to eclipse the node and swallow all addr messages to be effective. If that's the case, this would be very expensive and the user would have bigger problems. Again, is this tradeoff acceptable, or are there now other attacks that have been discovered?
I don't think this is an acceptable stance if we want to collaborate on improving this feature. AI will continue to insist there are bugs and leaks that are not realistically possible to exploit.
I think the status quo for most users is just using default broadcast, and everyone desires privacy (but they don't know they desire it until someone reveals to them they've violated it). I think making even the current version default behavior if we detect access to a privacy network (and warning if we can't) would be a vast improvement over the status quo. So I think improving the UX of private broadcast (by adding it to wallet, package relay, synchronous, etc.) on the way to making it default behavior is the correct path forward. That way a sybil attacker will spend a lot more resources to find out transactions that are just the default. Of course we should continue to harden the privacy against these attacks as well, but I don't think the status quo makes this feature less valuable or somehow dangerous to users.
Indeed but this is an optional feature that has only been available since last release. I wouldn't expect it to have lots of usage until node-in-a-box implementations start turning it on by default at least. |
Implements the private broadcast specification of bitcoin/bitcoin#36628 (doc/design/private-broadcast.md) without the node integration: discovery through Tor's SOCKS5 RESOLVE, the fixed plan and assignment, BIP324 attempts with the constant profile, and the JSON report. Tests include BIP324 test vectors, randomized peers, cancellation of whole jobs, an end-to-end run against regtest bitcoind, and a wire comparison harness against Core's job.
Implements the private broadcast specification of bitcoin/bitcoin#36628 (doc/design/private-broadcast.md) without the node integration: discovery through Tor's SOCKS5 RESOLVE, the fixed plan and assignment, BIP324 attempts with the constant profile, and the JSON report. Tests include BIP324 test vectors, randomized peers, cancellation of whole jobs, an end-to-end run against regtest bitcoind, and a wire comparison harness against Core's job.
I think what we have is better than nothing, but I believe the argument you're making is that the relevant alternative isn't nothing, but rather people using an independent tool like https://github.com/alfred-hodler/pushtx and that doing so is better than what we have now (because, being independent, it doesn't risk leaks due to node state contamination). A quick AI analysis suggests that pushtx has its own failings: if tor isn't available it will just drop to clearnet, it gets the peers to connect to via clearnet DNS, and it allows its connections to be correlated to each other by listening for and reacting to the INV for its own transaction. The alternative approach of using tor to connect to a block explorer's push-tx api endpoint works for privacy, but is obviously pretty terrible for censorship resistance. So I think I'm not really convinced that what we have, even with its flaws, isn't better than the actual alternatives. (I think I am convinced that improving those alternatives is a better path than trying to have an in-node solution that's not contaminated by in-node state though)
I think it's a mistake in both theory and practice for people to assume Core developers are infallible with regard to crypto or privacy concerns. Getting things right is a matter of correcting mistakes when they occur, not never making mistakes. Trying to satisfy people who expect us never to make mistakes isn't going to work -- the best we can possibly do is satisfy people who expect that we'll tell them when we make mistakes and that we'll do our best to fix those mistakes. I think you might want to review #35858 as the recommendations there seem stronger than is justified ("The transaction reaches the wider network only once a recipient relays it, which prevents linking the submission to the node's IP address.") In any event, it sounds to me like a better approach to this feature would be:
I don't have a strong preference as to order; but deprecating the feature shouldn't be delayed pending other steps if our feature either is not something we can recommend as fit for purpose and/or is worse than using alternative third party tools. (Even in this scenario, there's a potential linkage between node and tx: the wallet will likely only rebroadcast once the tx in question exits your mempool) Apart from "include an in-repo implementation of a spec" I think all of those should be relatively small or negative-LOC PRs as far as the bitcoin core repo is concerned, so relatively easy to review. (To clarify maybe: this is my opinion on an approach would most easily meet everyone's goals here; it's not meant to be an ultimatum, or a "your ideas are bad and should be thrown away" against anyone) |
I think an extreme attack scenario worth thinking about here is:
Hopefully that exact attack is unrealistic, given the expectation that the attacker has to provide perhaps ~650M unique addresses in total (18k addresses for each of 18k public nodes to be 50% of reachable addresses, but unique for each node?) all with a reachable bitcoin node answering them, ready to spy on relayed transactions. It's meant to be a thought-experiment, not an attack recipe, after all. In that scenario, addrman, block relay and transaction relay all continue to work as specced and the node is not eclipsed, because you do have at least one honest outbound connection, but a pervasive group attempting to do tx linking still immediately succeeds in identifying 4-out-of-5 private broadcast txs.
I don't think you can reasonably say "this is an experimental feature" and "it should be default and enabled by node-in-a-box implementations" at the same time. |
|
🐙 This pull request conflicts with the target branch and needs rebase. |
But I think it's important to note that the attacker does not know which addresses were not successfully relayed to an honest outbound. The attacker cannot know that the address has not been shared with anyone else, so the attack falls apart since the connections could come from anyone.
I am not saying it "should be default and enabled" today while it is still experimental. I was describing the vision I have for this feature, which I hope we can get to at some point in the future. |
|
Thank you, @ajtowns for actually trying to analyze an attack scenario in details. I think all this talking that private broadcast is broken, flawed, foot gun, a failure, worse than send-to-all or harmful, without explaining why in details have not been constructive. Now about this:
Right, further note that whenever we receive a new inbound connection we would send 1000 addresses from our addrman to the peer. So those 42% unique addresses in our addrman will soon stop to be unique and the attacker cannot make any reliable conclusions. There is unpredictable spill out from our addrman into the addrmans of other nodes.
I agree, for more than one reason. |
Could you explain why? I disagree, and i tried to explain why in my previous message.
Yes but that's only part of my argument. Shipping something that is worse (privacy wise, which i think is the relevant dimension here) than existing alternatives, certainly isn't better. But also, shipping a privacy branded feature with known architectural defects which permit breaching the promised privacy under a very reasonable threat model, is worse than shipping nothing.
However for that part, no, this is not the argument i was making. What i had in mind was simply broadcasting the transaction through Tor to one of the many available broadcast API out there. A simple It is indeed less reliable as it's limited to a few single points of failures, and if we can offer a more decentralized option i'm all in, but i don't think this should compromise on privacy, which is the desired property in the first place. That said i am skeptical we could realistically achieve this. I think that would merely shift the single point of failures from explorer APIs towards DNS seeds, and while there may be reasons why the latter may be reasonable, that does not seem like a particularly interesting goal. Instead, the value i see in private broadcast is to make this limited tool, which allows one to trade-off reliability for substantially improved privacy, available to more people. If we can implement it properly, i think it could have some pretty interesting properties at scale: some turnkey node solutions could start defaulting to using it by default for broadcasting the transactions from wallet commonly associated with these boxes, and if a few % of transactions on the network start being broadcast this way it might create enough false positives to defeat spies' transaction origin analysis. This perspective is why i'm supporting this attempt to salvage the feature rather than stripping it off entirely.
Fair enough for those alternatives, but i don't think this should be our baseline for comparison.
Ok, i can agree with that list. I would rather we don't deprecate the feature and instead fix it with this PR, but i may be too optimistic. It also seems to me that the threat model / design document for that feature can be discussed internally to Bitcoin Core, and does not need to go through the BIP process, but that's of secondary importance.
To be clear: this is unrelated to the security team. As far as i'm aware, no embargo on any of the remaining leaks was requested. Not discussing those in details publicly while users may be affected is just a matter of judgement on the part of the discoverer.
Again, this is backward. How can we be reasonably convinced this feature is robust enough that it is reasonable to ship?
I'm sorry, but this is a deeply unserious approach to developing security-critical software. By that standard, should reviewers identifying a memory safety vulnerability be expected to demonstrate a working RCE before the issue is taken seriously? And even then, should we merely address the specific exploit demonstrated, which has been the approach for private broadcast leaks, rather than the underlying vulnerability? This would turn security review into an endless game of whack-a-mole, with the burden falling on reviewers to keep finding new ways to exploit the same fundamental flaws. The bit about AI is also concerning. It reads as if you suggested AI tools are hallucinating unreasonable privacy breaches against an otherwise sound implementation of the feature. Yet you've not given a single threat model by which we could judge whether a breach can be considered reasonable, the implementation has repeatedly been shown to be unsound, and AI tools have been pretty effective at poking holes in it. |
Again, onus is backwards here. Where's this invariant promised in the code or docs? How did you verify this? Is there existing test for this supposed invariant? Blind assertions forcing me to do more work is not appropriate. To actually circle back to the PR at hand: I'm currently putting DNS seeds as a liveness requirement for a privacy tool. This is something I have to defend, but given that, neatly slots into what I consider a reasonable security model, from which flows invariants that can be stated clearly, tested, and audited as heavily as we'd like. The alternative is to continue arguing about what is what is "unrealistic" under no defined model at all. |
That is captured in the "80% success rate" -- they have up to a 20% false-positive rate in this scenario, but that's hardly meeting the "private" goal of this feature.
The addresses we send are cached in order to avoid an attacker being able to poll all the addresses in our addrman.
And yes, I realise that (hopefully) wasn't a sufficient recipe to form a practical attack -- if it were, I wouldn't have posted it publicly. You should be able to conceive of the possibility of a theoretical attack being made both more more impactful and more practical and work to defend against that possibility, not dismiss it out of hand. |
Don't really think it matters enough to be worth arguing about?
Replacing the DNS seed with your own custom variant is perhaps possible to do in a way that avoids addrman's problems (ie offers additional/different guarantees/properties/invariants than today's addrman) so that individuals can avoid the single point of failure, but "setting up your own tx announcing API that only you use" just gives you the exact same problem. If it's not realistically achievable, that doesn't matter, but if it is, that's a useful reduction of failure points, I think. Also, that's three different preferred approaches to private broadcast just from people in this thread though, so that seems like a good reason for providing a hook rather than picking a winner, so that different people can have their node adopt the approach they prefer.
I think there's a fairly strong argument that the feature as implemented and released (in 31.x and 32.x) doesn't do the job it's meant to or that people would reasonably expect it to do; if so, I think that's a good reason to deprecate a feature. Deprecation doesn't mean giving up on the goal -- we can still implement it properly and do it right in a future release. It also doesn't take the feature away from anyone, just gives them what seems to be an appropriate warning that it's not as good an idea to use as it might have seemed at first glance. I don't think this PR as-is is really back-portable (and it doesn't sound like you fully support its exact approach anyway), and I think both deprecating the existing feature and backporting a "hook and external tool" approach would be fairly reasonable. Anyway, that's my view. Mostly sum it up as "i don't want to review 9k lines of changes for this, and hope there's alternatives". |
|
In addition to my concerns above about relying on centralized services and not sending to all types of peers I have the following thoughts: No addrmanThis boils down to the problem of bootstrapping a node in a decentralized P2P network without central servers. How to find the addresses of the other peers? This problem is already solved with addrman. If we would avoid addrman and still need addresses of other peers, then we would end up reinventing addrman or making some gross compromises (like ditching the decentralized-P2P-network idea and leaning towards the client-server architecture). Addrman's purpose is to collect a diverse set of addresses, from many different sources, minimizing the percentage of the addresses acquired from one source. That suits well the private broadcast because it needs at least one non-adversary node for the broadcast to succeed. Note that the addresses in addrman are shared with other nodes which means that even if we end up sending to an adversary they cannot know whether the sender is the node they originally gave that address to or another node with which that address was shared. No retriesFrom #36608:
IMO that would make the broadcast less reliable for no reason. What needs to happen for the adversary to control whether the transaction comes back? It seems that for this to happen the originator must have all their connections opened with the adversary (be fully sybiled). In this case the adversary already knows the identity of the sender.
And what will the user do? They will end up using the same logic - retry if it didn't come back. Concept NACK |
I was hoping that my message two weeks ago would have led you to validate this claim rather than repeat it. It is not true.
Knowledge of the node's identity shouldn't be at risk even if a clearnet node is sybiled. Offering "privacy features" that fall apart upon sybil is dangerous, both for the users who thought they were being given privacy, and the network at large who now has to deal with sybil incentives beyond what we already have. This PR is designed to protect the user's IP address, even if completely sybiled. |
Are you saying that it is not true that addresses in addrman are shared with other nodes?
Lets see, with this PR, with completely sybiled node all connections end up with the attacker. So the attacker receives the broadcast attempts. The user does not see the transaction echoed back so he retries. The attacker keeps receiving also the retries, then gives the transaction to the clearnet node of the user and the retries stop. This is a confirmation to the attacker that the clearnet node they have sybiled is indeed the transaction originator. If the burden of the retries is moved from the code to the user that does not make the whole system better. It only makes it more cumbersome. |
What's the invariant you're asserting? What steps have you taken to validate it, if any?
|
|
From a project PoV, I don't see this succeeding. I hope it's been made clear what I think the current Willing to discuss security models, but code is likely |

Split out of #36608, the overall private broadcast rework to support ease of review for like-for-like feature.
Differences from #36608 :
With
-privatebroadcast,sendrawtransactionqueues a job instead of handing the transaction tothe connection manager. Each job runs on its own thread, shares no state with the node, and
reaches the network only through the Tor proxy: it resolves the chain's DNS seeds, then announces
over BIP324 to recipients on a schedule drawn up front, each connection with fresh isolation
credentials. Nothing a recipient does, and nothing the node sees of the transaction coming back,
changes the plan, and the transaction enters the node's mempool only when it returns from the
network. The old private broadcast connections and relay are removed.
The invariants are specified in
doc/design/private-broadcast.md.The rest of the tests are in a follow-up to be considered later:
https://github.com/instagibbs/bitcoin/tree/2026-10-pb_reimpl_followup