I'm all for spreading the hashrate as evenly as possible... and I'm also baffled that "withholding winning blocks" is even a thing. Is there a way to defend against that in code?
Directly, no.
What the pool would have to do is send the suspected miner a work unit that is known to produce a block-winning hash and see if they report it.
grnbrg.