wallet: only rebroadcast transactions originating from the wallet #36398

Open
mzumsande wants to merge 2 commits from 202620_wallet_restric_rebroadcast into master AGit
mzumsande commented 2026-10-01 14:25:46 +00:00 (Migrated from github.com)

As explained in #3828, rebroadcast of transactions paying the wallet (but not spending any wallet inputs) is a privacy leak, since anyone can generate these, choose a low fee, and observe who rebroadcasts them.
While it is somewhat intuitive that submitting transactions has privacy implications - at least until confirmation - this is manageable by various strategies (switching to privacy networks for a while, using private broadcast, making sure it confirms before rebroadcast). However, I find it rather unexpected that just passively running a node with a wallet loaded can lead to a loss of privacy as well.

This PR stops rebroadcasting transactions that don't spend any wallet inputs. For the same reason, they are also no longer re-added to the mempool on startup or after an import: otherwise our node might be the only one still having a transaction the rest of the network has dropped, which can be detected with active probing (e.g. by submitting a child).

This does have the trade-off that receivers (who have an incentive to get paid) will now need to manually resubmit transactions if the transaction doesn't confirm and the sender doesn't rebroadcast, but I think it is worth the privacy benefit.

An alternative approach is https://github.com/bitcoin/bitcoin/pull/36380, although these could also be combined (make rebroadcast optional, but never rebroadcast non-originating transactions)

Fixes #3828

As explained in #3828, rebroadcast of transactions paying the wallet (but not spending any wallet inputs) is a privacy leak, since anyone can generate these, choose a low fee, and observe who rebroadcasts them. While it is somewhat intuitive that submitting transactions has privacy implications - at least until confirmation - this is manageable by various strategies (switching to privacy networks for a while, using private broadcast, making sure it confirms before rebroadcast). However, I find it rather unexpected that just passively running a node with a wallet loaded can lead to a loss of privacy as well. This PR stops rebroadcasting transactions that don't spend any wallet inputs. For the same reason, they are also no longer re-added to the mempool on startup or after an import: otherwise our node might be the only one still having a transaction the rest of the network has dropped, which can be detected with active probing (e.g. by submitting a child). This does have the trade-off that receivers (who have an incentive to get paid) will now need to manually resubmit transactions if the transaction doesn't confirm and the sender doesn't rebroadcast, but I think it is worth the privacy benefit. An alternative approach is https://github.com/bitcoin/bitcoin/pull/36380, although these could also be combined (make rebroadcast optional, but never rebroadcast non-originating transactions) Fixes #3828
DrahtBot commented 2026-10-01 14:25:54 +00:00 (Migrated from github.com)

The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

External sites

Reviews

See the guideline and AI policy for information on the review process.

Type Reviewers
Concept NACK achow101
Concept ACK vasild

If your review is incorrectly listed, please copy-paste <!--meta-tag:bot-skip--> into the comment that the bot should ignore.

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #36540 (mempool: remove time-based transaction expiry by ismaelsadeeq)
  • #36482 (wallet: Only broadcast resubmitted transactions that were added to the mempool by achow101)
  • #36380 (wallet: extend -walletbroadcast to allow initial send only by vasild)

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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/36398 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/36398.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/36398#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. | Type | Reviewers | | ---- | --------- | | Concept NACK | [achow101](https://github.com/bitcoin/bitcoin/pull/36398#issuecomment-5936779475) | | Concept ACK | [vasild](https://github.com/bitcoin/bitcoin/pull/36398#issuecomment-6012406070) | If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#36540](https://github.com/bitcoin/bitcoin/pull/36540) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36540.svg"></sub> (mempool: remove time-based transaction expiry by ismaelsadeeq) * [#36482](https://github.com/bitcoin/bitcoin/pull/36482) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36482.svg"></sub> (wallet: Only broadcast resubmitted transactions that were added to the mempool by achow101) * [#36380](https://github.com/bitcoin/bitcoin/pull/36380) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36380.svg"></sub> (wallet: extend -walletbroadcast to allow initial send only by vasild) 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. <!--5faf32d7da4f0f540f40219e4f7537a3-->
First-time contributor

Base: a773e1e33b349dc819b5a0edc1c7a4839dc73b48
Head: f63a38f781ad91c2047a1bdf5112477e87b6531d

No verified findings are available from this review.

Review coverage was incomplete.

Review limitations
  • adversarial_deepseek: Stage reported incomplete evidence without identifying the missing evidence.

Full review report

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:1e40d4c29146a38cb238a037edaa35c22b13996a5383ed7a85e089a15d569009:c9412d948811529792d161d97aa6951829440e3d548b7c576bb8d4df4183e0d0 --> Base: `a773e1e33b349dc819b5a0edc1c7a4839dc73b48` Head: `f63a38f781ad91c2047a1bdf5112477e87b6531d` No verified findings are available from this review. Review coverage was incomplete. <details> <summary>Review limitations</summary> - adversarial_deepseek: Stage reported incomplete evidence without identifying the missing evidence. </details> [Full review report](<https://review.fish.foo/traces/36398-f63a38f781ad91c2047a1bdf5112477e87b6531d-1329-3.html>)
achow101 commented 2026-10-01 17:25:00 +00:00 (Migrated from github.com)

Concept NACK-ish

Rebroadcasting transactions that are not ours is useful as rebroadcasting does have an effect on getting such transactions confirmed. Furthermore, if we want to CPFP a transaction, it needs to be in our mempool first, otherwise the wallet will be unable to broadcast the child.

Instead of trying to delete rebroadcasting in the name of privacy, we should consider other ways to enable rebroadcasting in a privacy preserving manner, such as a rebroadcast pool in the node.

Concept NACK-ish Rebroadcasting transactions that are not ours is useful as rebroadcasting does have an effect on getting such transactions confirmed. Furthermore, if we want to CPFP a transaction, it needs to be in our mempool first, otherwise the wallet will be unable to broadcast the child. Instead of trying to delete rebroadcasting in the name of privacy, we should consider other ways to enable rebroadcasting in a privacy preserving manner, such as a rebroadcast pool in the node.
instagibbs commented 2026-10-01 17:51:09 +00:00 (Migrated from github.com)
rebroadcast pool histories: https://github.com/bitcoin/bitcoin/pull/16698 and https://github.com/bitcoin/bitcoin/pull/21061 in case its helpful I think we need to start a fresh issue on the topic and lay down alternatives side by side
achow101 commented 2026-10-01 19:49:35 +00:00 (Migrated from github.com)

I've opened #36403 where we can have more high level discussion about transaction rebroadcast in general.

I've opened #36403 where we can have more high level discussion about transaction rebroadcast in general.
vasild commented 2026-10-06 08:27:45 +00:00 (Migrated from github.com)

Concept ACK, but make this configurable somehow.

Like somebody said "there is no one size fits all" and from above - rebroadcasting by the recipient has some positive sides.

In such cases I think it is best if we let the users decide what is best for them - give them the tools to configure it according to their environment and priorities.

If you decide to make this configurable, one possibility would be to extend -walletbroadcast=<0|1> with a new value, similarly to https://github.com/bitcoin/bitcoin/pull/36380.

Concept ACK, but make this configurable somehow. Like somebody said "there is no one size fits all" and from [above](https://github.com/bitcoin/bitcoin/pull/36398#issuecomment-5936779475) - rebroadcasting by the recipient has some positive sides. In such cases I think it is best if we let the users decide what is best for them - give them the tools to configure it according to their environment and priorities. If you decide to make this configurable, one possibility would be to extend `-walletbroadcast=<0|1>` with a new value, similarly to https://github.com/bitcoin/bitcoin/pull/36380.
fametrano commented 2026-10-25 11:23:34 +00:00 (Migrated from github.com)

After a restart without mempool.dat, or after mempool expiry, a CPFP child that the wallet itself created for an incoming payment stays out of the mempool on this branch, and no resend timer brings it back.

The child spends our output of the incoming parent, so IsFromMe() still selects it, but the parent is now skipped, and without the parent the child cannot enter the mempool. I measured this on regtest at f63a38f781 and at its base d4b0e1e4b0: one node pays the wallet at 1 sat/vB and is disconnected, then the wallet spends that unconfirmed output at 50 sat/vB. After a restart with -persistmempool=0, the base re-adds both transactions and announces both to a fresh peer at the next resend timer; this branch re-adds neither and announces neither. Letting both expire from the mempool, without a restart, gives the same result. Submitting the parent by hand with sendrawtransaction, as the release note suggests, brings the child back at the next timer.

achow101 noted above that CPFP needs the parent in our mempool; this is the same dependency once the child already exists. One way to keep it would be to also resubmit an unconfirmed incoming parent whose output a resubmitted transaction of ours spends: announcing that child already shows that the parent pays us. Otherwise the release note could name this case. I can share the probe script.

After a restart without mempool.dat, or after mempool expiry, a CPFP child that the wallet itself created for an incoming payment stays out of the mempool on this branch, and no resend timer brings it back. The child spends our output of the incoming parent, so `IsFromMe()` still selects it, but the parent is now skipped, and without the parent the child cannot enter the mempool. I measured this on regtest at f63a38f781 and at its base d4b0e1e4b0: one node pays the wallet at 1 sat/vB and is disconnected, then the wallet spends that unconfirmed output at 50 sat/vB. After a restart with `-persistmempool=0`, the base re-adds both transactions and announces both to a fresh peer at the next resend timer; this branch re-adds neither and announces neither. Letting both expire from the mempool, without a restart, gives the same result. Submitting the parent by hand with `sendrawtransaction`, as the release note suggests, brings the child back at the next timer. achow101 noted above that CPFP needs the parent in our mempool; this is the same dependency once the child already exists. One way to keep it would be to also resubmit an unconfirmed incoming parent whose output a resubmitted transaction of ours spends: announcing that child already shows that the parent pays us. Otherwise the release note could name this case. I can share the probe script.
mzumsande commented 2026-11-06 16:47:31 +00:00 (Migrated from github.com)

Concept NACK-ish

Rebroadcasting transactions that are not ours is useful as rebroadcasting does have an effect on getting such transactions confirmed. Furthermore, if we want to CPFP a transaction, it needs to be in our mempool first, otherwise the wallet will be unable to broadcast the child.

The problem that in my opinion is most important to fix is the attack scenario, and I think it would be justified to have users who actually got paid and need rebroadcasting do manual steps if that protects passive users from getting deanonymized:

The attack is cheap and simple, and also highly repeatable/scalable: Someone with an interest in a specific address makes a dust payment to it while connected to all reachable nodes, and a day later checks who rebroadcasts it, deanonymizing the owner. The hardest part is the infra needed to be connected to everyone.

Unfortunately, this issue is not fixed by #36482: that approach would just require a few extra steps from the attacker due to the replacement strategy (https://github.com/bitcoin/bitcoin/pull/36482#discussion_r4231801500) so I still think that this PR may be needed - not on its own, but in combination with #36481, which lets users who actually got paid rebroadcast manually.
The same applies to CPFP: if the parent has dropped out of our mempool, the user can rebroadcast it via #36481 first.

After a restart without mempool.dat, or after mempool expiry, a CPFP child that the wallet itself created for an incoming payment stays out of the mempool on this branch, and no resend timer brings it back

I could change the logic to also resubmit unconfirmed in-wallet parents of transactions we created. By creating a CPFP child, the user has shown they expect this payment, so it can't be an unsolicited probe.

> Concept NACK-ish > > Rebroadcasting transactions that are not ours is useful as rebroadcasting does have an effect on getting such transactions confirmed. Furthermore, if we want to CPFP a transaction, it needs to be in our mempool first, otherwise the wallet will be unable to broadcast the child. The problem that in my opinion is most important to fix is the attack scenario, and I think it would be justified to have users who actually got paid and need rebroadcasting do manual steps if that protects passive users from getting deanonymized: The attack is cheap and simple, and also highly repeatable/scalable: Someone with an interest in a specific address makes a dust payment to it while connected to all reachable nodes, and a day later checks who rebroadcasts it, deanonymizing the owner. The hardest part is the infra needed to be connected to everyone. Unfortunately, this issue is not fixed by #36482: that approach would just require a few extra steps from the attacker due to the replacement strategy (https://github.com/bitcoin/bitcoin/pull/36482#discussion_r4231801500) so I still think that this PR may be needed - not on its own, but in combination with #36481, which lets users who actually got paid rebroadcast manually. The same applies to CPFP: if the parent has dropped out of our mempool, the user can rebroadcast it via #36481 first. > After a restart without mempool.dat, or after mempool expiry, a CPFP child that the wallet itself created for an incoming payment stays out of the mempool on this branch, and no resend timer brings it back I could change the logic to also resubmit unconfirmed in-wallet parents of transactions we created. By creating a CPFP child, the user has shown they expect this payment, so it can't be an unsolicited probe.
TheButterZone commented 2026-11-27 15:58:39 +00:00 (Migrated from github.com)
I found this PR on https://delvingbitcoin.org/t/exploiting-wallet-rebroadcast-to-link-addresses-to-node-ips-and-more/3123
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!36398
No description provided.