Good point, and I'm not sure how to resolve that with existing protocol / infrastructure. From a web wallet prospective, few off-the-cuff ideas:
1.) Require users to input their BIP32 public key each time they want to generate an address, but obviously that wouldn't go over well.
2.) Encrypt public key via AES256 with the user's wallet password, which isn't stored online. Little inconvenient, because they need to enter their wallet password each time they want to generate an address, but would work decently. If a hacker replaces the public key with something, then it's not going to decrypt properly unless they also know the user's wallet password.
3.) Have a separate server that holds checksum values of each BIP32 public master key, and bounce validation messages off it. Pretty weak though, as if the hacker is in the server, they can easily see and bypass this one.
4.) Upon address generation, randomly check against a few previously created addresses to ensure they match the public key being used. Plus maybe randomly call up a few previous transactions from the blockchain, and check the redeem script on them to ensure the public key matches up. Hardly fool-proof, but it does make it a little harder as instead of just modifying the public key, they need to modify all addresses and transactions associated with the user account as well.
I don't know, will have to think about this more.