You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I haven't written a test for this, but it seems that a peer can fingerprint a chunk of our mempool by announcing a new compact block with a valid header, but inserting many shorttxids that don't belong to the block but are suspected to be in our mempool. Assuming no short id collisions, we'll then request each tx that we didn't find in either vExtraTxnForCompact or the mempool.
I'm not sure how to fix this since compact block relay relies on this behavior. One possible way of fixing this was brought up here #27086 (comment).
There are two cases to think about here that currently leak some info:
we have the tx, so we won't request it
we don't have the tx, so we will request it
To solve both cases, we could choose some transactions to request even if we have them. For example, if we need X transactions to reconstruct the block, we could request Y transactions in GETBLOCKTXN where we have the other Y-X transactions. Adding these decoy transactions increases the BLOCKTXN response and could cause more round trips. We would also have to ignore the known transactions in BLOCKTXN.
If there are too many txn's that we're missing, we could fall back to block relay instead of trying to add many decoy transactions. According to this data point, compact block reconstruction works pretty well. Most of the time no reconstruction happens and sometimes only a few txn's are needed. So falling back to block relay should be unlikely.
Since quick compact block relay is pretty important to avoid stale blocks, I'm not really sure how to weigh the privacy-bandwidth tradeoff.
After #27675 (but also before, with a few more restrictions), we relay any tx from our mempool (except for those that arrived after the last INV sent to the peer), so someone wanting to fingerprint our mempool could just ask for those transactions directly instead I think and then check whether we send it to them or answer with NOTFOUND.
So I wonder why would someone trouble themselves with doing compact blocks for this, which would involve either creating a new valid block header (expensive) or trying to be the first to announce a compact block found by someone else to the victim (which has timing issues), if they could just ask for this info directly? (this doesn't apply to block-relay-only peers though).
I meant to reply but guess I never did. The point about blocks-only nodes is a good one. In the happy path, they aren't sent compact blocks since they never send SENDCMPCT to the peer again to set the high-bandwidth mode. But they can still be sent unsolicited compact blocks and because they can't reconstruct the blocks, it lets them be fingerprinted if anything is in their mempool. In most cases I don't think we can send GETDATA to fetch txns from blocksonly nodes since they never INV us anything.
I think the only times a -blocksonly node will have a transaction is if they have a peer with the relay permission, in cases of reorg, or if they accidentally decide to broadcast a tx?
FWIW, this is solvable by changing to more fibre like methods for block transmission. Because FEC coded missing data doesn't identify what was missing.
So I had thought the code would check if there were too many missing transactions and just request a full block if all were missing. That doesn't address the general attack (since the attacker could admit some real txn that are in the block) but it would mostly address the blocksonly case (and could easily get a if blocksonly check so that it always did) -- but I can't find that. It should be added.
It would also be prudent to just drop any unrequested compact block messages that show up outside of the correct protocol behavior (or treat them as header messages). That would also eliminate the attack on blocks only peers and also discourage protocol violations that waste bandwidth (e.g. going around spamming everyone with compact blocks to try to speed up your own propagation).
The latter of these two should be much easier to implement and be a more comprehensive attack protection.
Dropping seemingly-unsolicited compact blocks seems fine, we already do that for the parallel portion, this should be a change just to the first one? blocksonly nodes should never set cb peers.
So I had thought the code would check if there were too many missing transactions and just request a full block if all were missing. That doesn't address the general attack (since the attacker could admit some real txn that are in the block) but it would mostly address the blocksonly case (and could easily get a if blocksonly check so that it always did) -- but I can't find that. It should be added.
Is this still useful if we add a patch to drop unsolicited cmpctblock messages? An attacker would still be able to do this to non-blocksonly peers, but as pointed out above by @mzumsande it doesn't seem particularly useful as the attacker could simply request the transactions directly from these peers.
If it is useful to fallback to the legacy BLOCK message in the non-blocksonly case, then should it only be done when all the transactions are missing or could it instead be if some % are missing?
I don't recall if the vulnerability related to requesting the transaction was closed (relay pool limited its scope at least to recently announced txn) but there were complications related to orphan txn (e.g. that relaying a transaction ought to imply permission to fetch its parents if they are still in your memory pool). But if that vulnerability hasn't been closed it ought to be closed. Edit: Sipa noted to me on IRC that the behavior now is that when you INV you grant only permission to fetch txn in your mempool up to that point in time (which is very close to equivalent to only granting permission to things that you've INVed (or would have inved if the peer had been connected)). So I think the CB probing, in fact, is an additional information leak.
Ignoring the unrequested CB is desirable for non-privacy reasons, specifically because if it doesn't someone might decide it's in their best interest to spam the entire network with an unrequested CB to try to improve propagation. This has been done in the past with unsolicited BLOCKS (which is obviously much worse). I haven't asked matt but I bet if this oversight weren't completely accidental I bet it was due to fibre sending them unsolicited, since if you were connecting to a fibre node at all obviously you did want blocks even if the HB logic hadn't yet selected you. --- since by the time CB were developed we'd already learned the lesson that being tolerant in what you accept turns out to cause trouble.
Just in principle if there is some unsolicited activity that shouldn't exist it probably ought to at least be ignored if not outright triggering a disconnection. There have been a lot of vulnerabilities in the past that could have been avoided or greatly mitigated by doing so, and sure sometimes it's discovered that it might be useful to have the behavior, but in that case the version that introduces the behavior can introduce a new message type or a handshake that confirms its okay.
Yea, I'm not really sure if twas entirely deliberate or not, but they'd presumably have to be the first node to relay you a block (so at least its not entirely trivial, as IIRC it has to build on the tip, or if it doesn't it should!), and, indeed, I believe FIBRE took advantage of it (tho not very effectively due to lack of parallel compact block reconstruction in Bitcoin Core at the time). Now that we do have parallel compact block reconstruction, I wonder if we shouldn't disable this while at the same time bumping the parallelization limit (dunno what it is now but probably should be 3?) and increasing the HB peer set (they're pretty cheap, and it probably should have been higher to begin with).
Opened #32606 to drop unsolicited CMPCTBLOCK messages.
I wonder if we shouldn't disable this while at the same time bumping the parallelization limit (dunno what it is now but probably should be 3?) and increasing the HB peer set (they're pretty cheap, and it probably should have been higher to begin with).
I did not do this, but happy to close in favor of another PR that addresses this, or to add this to #32606 later, just not confident that I understand yet how to reason about the implications of this.
Activity
maflcko commentedon Aug 15, 2023
I guess this relates to the TODO as well:
bitcoin/src/blockencodings.cpp
Line 24 in 80d70cb
Crypt-iQ commentedon Aug 15, 2023
I think implementing the TODO might add round-trips and maybe leak what we had in our own mempool prior to block acceptance?
Crypt-iQ commentedon Aug 25, 2023
There are two cases to think about here that currently leak some info:
To solve both cases, we could choose some transactions to request even if we have them. For example, if we need X transactions to reconstruct the block, we could request Y transactions in GETBLOCKTXN where we have the other Y-X transactions. Adding these decoy transactions increases the BLOCKTXN response and could cause more round trips. We would also have to ignore the known transactions in BLOCKTXN.
If there are too many txn's that we're missing, we could fall back to block relay instead of trying to add many decoy transactions. According to this data point, compact block reconstruction works pretty well. Most of the time no reconstruction happens and sometimes only a few txn's are needed. So falling back to block relay should be unlikely.
Since quick compact block relay is pretty important to avoid stale blocks, I'm not really sure how to weigh the privacy-bandwidth tradeoff.
mzumsande commentedon Aug 25, 2023
After #27675 (but also before, with a few more restrictions), we relay any tx from our mempool (except for those that arrived after the last INV sent to the peer), so someone wanting to fingerprint our mempool could just ask for those transactions directly instead I think and then check whether we send it to them or answer with
NOTFOUND.So I wonder why would someone trouble themselves with doing compact blocks for this, which would involve either creating a new valid block header (expensive) or trying to be the first to announce a compact block found by someone else to the victim (which has timing issues), if they could just ask for this info directly? (this doesn't apply to block-relay-only peers though).
Crypt-iQ commentedon Feb 17, 2025
I meant to reply but guess I never did. The point about blocks-only nodes is a good one. In the happy path, they aren't sent compact blocks since they never send
SENDCMPCTto the peer again to set the high-bandwidth mode. But they can still be sent unsolicited compact blocks and because they can't reconstruct the blocks, it lets them be fingerprinted if anything is in their mempool. In most cases I don't think we can sendGETDATAto fetch txns from blocksonly nodes since they neverINVus anything.I think the only times a
-blocksonlynode will have a transaction is if they have a peer with the relay permission, in cases of reorg, or if they accidentally decide to broadcast a tx?gmaxwell commentedon May 23, 2025
FWIW, this is solvable by changing to more fibre like methods for block transmission. Because FEC coded missing data doesn't identify what was missing.
So I had thought the code would check if there were too many missing transactions and just request a full block if all were missing. That doesn't address the general attack (since the attacker could admit some real txn that are in the block) but it would mostly address the blocksonly case (and could easily get a if blocksonly check so that it always did) -- but I can't find that. It should be added.
It would also be prudent to just drop any unrequested compact block messages that show up outside of the correct protocol behavior (or treat them as header messages). That would also eliminate the attack on blocks only peers and also discourage protocol violations that waste bandwidth (e.g. going around spamming everyone with compact blocks to try to speed up your own propagation).
The latter of these two should be much easier to implement and be a more comprehensive attack protection.
instagibbs commentedon May 23, 2025
Dropping seemingly-unsolicited compact blocks seems fine, we already do that for the parallel portion, this should be a change just to the first one? blocksonly nodes should never set cb peers.
mzumsande commentedon May 23, 2025
Some discussion about the privacy implications for blocksonly peers in IRC: https://bitcoin-irc.chaincode.com/bitcoin-core-dev/2025-05-23#1123715;
Dropping unsolicited
cmpctblockmessages makes sense to me as well (and doesn't appear to be at odds with anything in BIP152).Crypt-iQ commentedon May 23, 2025
Is this still useful if we add a patch to drop unsolicited
cmpctblockmessages? An attacker would still be able to do this to non-blocksonly peers, but as pointed out above by @mzumsande it doesn't seem particularly useful as the attacker could simply request the transactions directly from these peers.If it is useful to fallback to the legacy BLOCK message in the non-blocksonly case, then should it only be done when all the transactions are missing or could it instead be if some % are missing?
gmaxwell commentedon May 23, 2025
I don't recall if the vulnerability related to requesting the transaction was closed (relay pool limited its scope at least to recently announced txn) but there were complications related to orphan txn (e.g. that relaying a transaction ought to imply permission to fetch its parents if they are still in your memory pool). But if that vulnerability hasn't been closed it ought to be closed. Edit: Sipa noted to me on IRC that the behavior now is that when you INV you grant only permission to fetch txn in your mempool up to that point in time (which is very close to equivalent to only granting permission to things that you've INVed (or would have inved if the peer had been connected)). So I think the CB probing, in fact, is an additional information leak.
Ignoring the unrequested CB is desirable for non-privacy reasons, specifically because if it doesn't someone might decide it's in their best interest to spam the entire network with an unrequested CB to try to improve propagation. This has been done in the past with unsolicited BLOCKS (which is obviously much worse). I haven't asked matt but I bet if this oversight weren't completely accidental I bet it was due to fibre sending them unsolicited, since if you were connecting to a fibre node at all obviously you did want blocks even if the HB logic hadn't yet selected you. --- since by the time CB were developed we'd already learned the lesson that being tolerant in what you accept turns out to cause trouble.
Just in principle if there is some unsolicited activity that shouldn't exist it probably ought to at least be ignored if not outright triggering a disconnection. There have been a lot of vulnerabilities in the past that could have been avoided or greatly mitigated by doing so, and sure sometimes it's discovered that it might be useful to have the behavior, but in that case the version that introduces the behavior can introduce a new message type or a handshake that confirms its okay.
TheBlueMatt commentedon May 23, 2025
Yea, I'm not really sure if twas entirely deliberate or not, but they'd presumably have to be the first node to relay you a block (so at least its not entirely trivial, as IIRC it has to build on the tip, or if it doesn't it should!), and, indeed, I believe FIBRE took advantage of it (tho not very effectively due to lack of parallel compact block reconstruction in Bitcoin Core at the time). Now that we do have parallel compact block reconstruction, I wonder if we shouldn't disable this while at the same time bumping the parallelization limit (dunno what it is now but probably should be 3?) and increasing the HB peer set (they're pretty cheap, and it probably should have been higher to begin with).
davidgumberg commentedon May 23, 2025
Opened #32606 to drop unsolicited CMPCTBLOCK messages.
I did not do this, but happy to close in favor of another PR that addresses this, or to add this to #32606 later, just not confident that I understand yet how to reason about the implications of this.
28 remaining items
Merge #32606: p2p: Drop unsolicited CMPCTBLOCK from non-HB peer and w…
p2p: Drop unsolicited CMPCTBLOCK from non-HB peer
p2p: make blocksonly nodes ignore CMPCTBLOCK messages
p2p: Drop unsolicited CMPCTBLOCK from non-HB peer
p2p: make blocksonly nodes ignore CMPCTBLOCK messages