Filter everything. Accept nothing but blocks. Problem solved.
But filters are why nodes with less than 12 GB ram take forever to sync now…did you know that? Because people can’t pay more to easily stuff shitcoins inside provably unspendable outputs via op_return, they work harder to abuse the segwit discount by cleverly stuffing data in the witness. And these outputs are not provably unspendable and thus have to stay in Utxo set…which used to be 4 GB not all that long ago.