Simultaneously Solo and Pool Mining It's possible to send shares both to a localhost GBT "pool" (e.g., Bitcoin Core's) and to a remote Stratum pool.* Now, if I discover a block, won't both my localhost GBT "pool" and the remote pool claim it as theirs? This appears to be known as the "selfish mining attack."

*using, e.g., bfgminer's #allblocks option, which offers "Support for submitting found blocks to a local Bitcoin GBT server (bitcoind or Bitcoin-Qt with -server flag): just append #allblocks to the end of your bitcoind's URI." (source)
Now, if I discover a block, won't both my localhost GBT "pool" and the remote pool claim it as theirs?


No. That isn't possible. Changing the coinbase transaction (what controls where a block reward goes) invalidates the block. All that happens is that the block propagates slightly faster.

Cheating on pooled mining




  This appears to be known as the "selfish mining attack."


Actually, that's something else.

Luca Matteis explains:


  You're missing the main point: when a selfish miner finds a new block,
  he keeps it private, does not broadcast it to the network, and starts
  mining on top of that privately.
  
  The rest of the network is still mining on a block that was actually
  already found, but not broadcast.
  
  When the rest of the network finally finds this block, the selfish
  miner broadcasts his version, in an attempt to replace it.
  
  By invalidating blocks this way a selfish miner is effectively wasting
  other people's cycles, and has a head start for winning the next
  block, because he started mining on it before the others.