Relay and accept transactions that personally benefit the user #1648

pull luke-jr wants to merge 3 commits into bitcoin:master from luke-jr:my_free_txn changing 1 files +15 −3
  1. luke-jr commented at 11:05 PM on August 1, 2012: member

    This is a rework of #1128:

    • Transactions from or to me are given a priority boost in my own mining
    • Transactions from me are always accepted to my memory pool
    • Transactions to me are accepted to my memory pool regardless of fees paid
  2. Accept any transaction (fee-free or even non-standard) from myself 69a2135ce7
  3. When mining, weigh transactions to or from myself higher 40646f4d5f
  4. Ignore fees on transactions paying me, when deciding whether to accept them into my memory pool ed6b70809b
  5. jgarzik commented at 9:37 PM on August 2, 2012: contributor

    Accepting non-standard transactions has already been NAK'd. Putting this into a new pull req doesn't change that.

  6. jgarzik closed this on Aug 2, 2012

  7. luke-jr commented at 12:55 AM on August 3, 2012: member

    This has not already been NAK'd. Please reopen so I don't need to keep resubmitting, and consider reading the change to review (this doesn't accept any old non-standard transactions, only ones you make yourself).

  8. gmaxwell reopened this on Aug 3, 2012

  9. BitcoinPullTester commented at 1:52 PM on August 8, 2012: none

    The following is an automatic comment from the Bitcoin Pull Tester. If you believe it is in error, please contact jenkins@bluematt.me

    This pull passed automatic sanity-tests! This means it merges cleanly onto current master, builds and unit-tests pass You can find the test log and build output at http://jenkins.bluematt.me/pull-tester/ed6b70809b01da9bd01e9c4f81d1b9df8ac74662

  10. SergioDemianLerner commented at 4:50 PM on August 13, 2012: contributor

    This change is partially, if not totally, flawed. This change gives a tool for an attacker to increase considerably the attack surface!

    Any user can send a peer a transaction that returns IsMine() == true or IsFromMe() == true if he knows who the peer is (the peer's public key).

    Creating transactions that return IsFromMe()=true the attacker can bypass penny flooding prevention and IsStandard() and go directly to the CPU-expensive ConnectInputs() code. This creates a perfect DoS attack. He can also skip IsStandard() and put non-standard txs into mapOrphanTransactions. Afterwards he can send a single tx that triggers the verification of thousands non-standard transactions at once, and I'm almost sure this can be used to mount a DoS.

    Creating transactions with IsMine() = true is also dangerous. The attacker can create a non-standard tx and send 0.0000001 to the victim's address and bypass penny flooding prevention and isStandard(). The peer would blindly relay that transactions to remaining peers. This could be used (although I didn't explore how to do it) to force the remaining nodes to block the victim's node.

    I find this change very disturbing, from the security point of view.

  11. luke-jr commented at 5:04 PM on August 13, 2012: member

    An attacker can't create transactions that return IsFromMe()==true unless they have already compromised your wallet.

    No anti-DoS rule should ever be made based on relaying valid transactions, though perhaps concern should be given to potentially filling the victim's memory/wallet with spam.

  12. SergioDemianLerner commented at 5:57 PM on August 13, 2012: contributor

    Why the attacker can't create transactions that return IsFromMe()==true ?

    The code IsFromMe(Tx) calls (GetDebit(tx) > 0) that calls GetDebit() from each txin, that finds the previous transaction and calls IsMine(prevout) which only checks that the recipient address is a specific key (only works for standard transaction templates). It does NOT check the signatures, just the template.

  13. SergioDemianLerner commented at 6:02 PM on August 13, 2012: contributor

    Some time ago there was a discussion on https://bitcointalk.org/index.php?topic=91915.0 about the purpose of IsStandard() check and its benefits

  14. luke-jr commented at 6:06 PM on August 13, 2012: member

    If the signatures don't match, the transaction is invalid and won't even get this far.

  15. SergioDemianLerner commented at 6:40 PM on August 13, 2012: contributor

    TRUE but you can create a VALID tx that sends 0 BTC to the victim and use the REMAINING previns/txouts to do nasty things. I can't find any way to attack now, but I don't like the idea of allowing the attacker to skip a check only by adding a few bytes to the transaction that sends 0 BTC to an specific address.

  16. sipa commented at 6:42 PM on August 13, 2012: member

    I think @luke-jr is right here, though I haven't looked closely enough to be sure, so thanks for raising the point.

    Anyway, this does raise another point: maybe IsFromMe() transactions should not be retransmitted unless they are really created by this instance (and not received from the network).

  17. luke-jr commented at 6:42 PM on August 13, 2012: member

    If that really works, it's a bug (in the existing code).

  18. SergioDemianLerner commented at 6:43 PM on August 13, 2012: contributor

    Nevertheless IsFromMe()=true is just enough of a problem.

  19. SergioDemianLerner commented at 6:44 PM on August 13, 2012: contributor

    If you want your client to allow a "fast track" for your transactions, then you can add some hidden message to the script of the transaction. The hidden message must be a MAC (Message Authentication Code) of your transaction using a secret key. Then you can check very fast that you're the sender of a transaction

  20. sipa commented at 6:54 PM on August 13, 2012: member

    No need for something that complex. Wallet transactions already have a fFromMe field which can easily be used to track whether it is not only "from me", but also "created by this instance".

  21. luke-jr commented at 6:57 PM on August 13, 2012: member

    @sipa That sounds like a good idea. How does it work with raw transactions (which are likely the common use case for this)?

  22. SergioDemianLerner commented at 6:59 PM on August 13, 2012: contributor

    Great!

    (but maybe the luke-jr runs multiple instances in different computers, so fFromMe is not available)

  23. gmaxwell commented at 7:42 PM on August 13, 2012: contributor

    If sendrawtransaction can be made to cause fFromMe to be set then it even covers the multiple instance case, so long as you do the work to trigger it from each instance. (Arguably better than the wallet duplication required to make input sniffing work)

  24. SergioDemianLerner commented at 1:42 PM on August 14, 2012: contributor

    I found two new attacks that breaks pseudonimity and allows a node to discover the peer's public address. With this information in hand (IP and Bitcoin pub address), a hacker may get the real identity and track the users payments.

    a) Wait to see if the peer relays a non-standard transaction, it it does, then the public key must be the one of the txins or txouts.

    b)

    1. Send money to 60 different txouts (all owned by you, each one containing 0.000001 BTC) my( i )
    2. List the 600K current Bitcoin addresses in use.
    3. Separate the addresses in 60 groups. For each group, create a non-standard tx with 1 input an 10000 outputs. Each tx input is one of your txouts [ my(i) ]
    4. One at the time, send the 60 transactions to the peer.
    5. Only the one with the victim's public address in it will be relayed. (you can check that using the command "mempool"). This is because the victim's node won't check the tx.GetMinFee(1000, true, GMF_RELAY) protection for that tx since IsMine() =true.
    6. Then proceed recursively (binary search) to discover which of the 10K address is the victim's pubkey.

    This is a classical side-channel attack.

    My opinion: Never branch the code checking IsFromMe() / IsMine() in CTxMemPool::accept()

    Note that the use of fFromMe does not posses any risks .

  25. luke-jr commented at 4:58 PM on August 14, 2012: member

    @SergioDemianLerner "A" is not a real risk, since relaying the non-standard transaction is the only way to actually use it (so the only way to avoid this risk is to not use non-standard transactions at all). "B" seems like it could have some serious privacy implications, though - do you think it would work better if the client secretly held onto the transaction and only relayed it again later?

  26. SergioDemianLerner commented at 5:34 PM on August 14, 2012: contributor

    "A" could be achieved by sending the transaction directly to the miners (I don't know how to achieve that) . Then only the miners will know who send it.

    Your idea to hide the transaction is interesting...The node should act exactly as if the transaction had been rejected. Also there should be no timing differences between rejecting and hiding.

    The only problem I see is that if the attacker has two connections to the victim, then he can monitor if the transaction goes out from the other end, so the attack it still possible...

    Anyway, why do you want to force to relay transactions that go to you?

    Your decision to relay/not-relay as a single node in the network has very little probability to influence the fact that the transaction will or won't be included in a block by a miner. It is only relevant if you own a high percentage of the nodes of the network, so you can chain transmissions until a miners node.

    Maybe what you want is to put the transaction into a special pool to monitor for 0-confirmations, but not for re-transmit. Could you explain what is the real benefit for you of this change? What's the use case?

  27. luke-jr commented at 2:35 AM on August 24, 2012: member

    After thinking about it more, this gains from this seem not worth the risks at this time.

  28. luke-jr closed this on Aug 24, 2012

  29. DrahtBot locked this on Sep 8, 2021

github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2026-04-15 15:15 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me