Just institute universal paternity testing and that can never happen.
BTW the technology exists (and have been sold for nearly 20 years) to determine paternity, sex and genetic diseases in an infant 2-6 weeks after CONCEPTION from the mother's blood.