prisoners.
Both the Nazis and the Japanese did so in WWII.
What they did was evil, no question about it. I have read that the US & perhaps other countries granted immunity to some of the perpetrators in order to get access to the data, techniques used and so on.
Whether or not granting immunity at that point was immoral is less clear and something medical ethicists wrestle with.
Most consider using the information learned to be ethical, as long as there is no rewarding of those who committed the evil, and especially not rewarding those who would continue to commit such evil acts.
I think the same principles would apply to using aborted babies for medical research. The research should be outlawed where it has not already been. The results of the experiments should be evaluated to see whether using medicines, technology and so on can morally be condoned.
Experimentation on prisoners
https://en.wikipedia.org/wiki/Experimentation_on_prisoners
Nazi human experimentation
https://en.wikipedia.org/wiki/Nazi_human_experimentation
PURE EVIL Inside Japan’s feared WW2 medical unit that disembowelled screaming PoWs, popped out eyes & infected them with plague
https://www.thesun.co.uk/news/12393263/ww2-japan-unit-731-disembowelled-pow-alive-plague-experiments/
Japan Dissected My Granddad Alive in World War II
https://www.thedailybeast.com/japan-dissected-my-granddad-alive-in-world-war-ii
25 Images of the Nazi Medical Experiments: Murderous Doctors and Tortured Patients
https://historycollection.com/25-images-nazi-medical-experiments-murderous-doctors-tortured-patients/
Report: Medical Experiments Conducted on U.S. Prisoners, Patients
https://www.pbs.org/newshour/health/medical-slideshow-code