Many sacred texts contain problematic passages (i.e. passages which endorse morally repugnant ideas and practices). For that matter, so do the founding documents of many secular intellectual traditions. Aristotle was a racist and sexist, for example (Politics 1260a13, Politics 1327b20-33).
Some people criticize contemporary versions of Judaism, Christianity, and/or Islam on the basis of problematic passages within the Hebrew Bible, the New Testament, and the Koran. This sort of criticism is typically misguided for a simple reason. These religious traditions have disavowed many problematic passages within their sacred texts. It is unfair to criticize a religion on the basis of a passage which it has renounced.
But can a religion possibly discard passages within its own sacred texts? After all, these texts are thought to be divinely authored, or at least divinely inspired. Can religions just pick and choose passages within their own scriptures? Here are a few strategies employed by some strands of the contemporary Abrahamic religions to reject or nullify passages.
Reject passages by rejecting inerrancy.
The simplest strategy for dealing with problematic passages is explicitly to allow that the original text contained errors. One may maintain that the Bible was written by inspired, but imperfect people. They were good, but not perfectly reliable transmitters of the divine message. Therefore, each passage must be weighed to determine whether it can plausibly be part of the divine message. Passages which fail this test can be rejected. The problematic passages were simply mistakes made by fallible people having bad days.
Alternatively, one might utilize the fact that our oldest manuscripts of sacred texts are handwritten copies of copies of copies of copies, etc. Even if the original texts were completely perfect, errors may have crept in over time because scribes can err, and manuscripts can be damaged by fire, water, insects, etc. Again, each passage in our current texts must be weighed to determine whether it can plausibly be part of the divine message. The problematic passages may be due to the corruption of manuscripts transmitted across centuries, and so may be rejected.
Accept inerrancy. Reject passages by rejecting textual literalism.
One might maintain that all of the passages in our current manuscripts are true, but the problematic passages are true only at a metaphorical level. Thus, problematic passages may be retained while their literal meaning is rejected. For example, the barbaric eye-for-an-eye passages in the Hebrew Bible (e.g. Ex 21:23-25) may be read metaphorically to mean that a person who harms another must pay monetary damages: for causing the loss of an eye one must pay a fine equal to the worth of an eye.
Alternatively, one might insist that sacred texts must be interpreted holistically. God is not a flip-flopper, so if two passages taken in the most natural way contradict each other, then at least one of these passages does not mean what it seems to mean. One version of this strategy is the interpretative principle of consistency which says, if a passage conflicts with the overwhelming bulk of the rest of the text, its natural meaning must be rejected. Another version is the interpretative principle of charity which says, if a problematic passage conflicts with an unproblematic passage, its natural meaning must be rejected. For example, the Hebrew Bible says both that one should do no work on the Sabbath (Ex 20:8-10), and that one should save lives whenever one can (Lev 19:16). To resolve the contradiction, the Talmudic rabbis as well as Jesus ruled that the prohibition of work on the Sabbath contains an implicit exception for lifesaving and healing (Yoma 84b, Talmud; Mark 3:3-4).
Accept inerrancy, textual literalism, and the problematic passages. Reject their application.
Surprisingly, one can accept that all passages of a sacred text are literally true, and still reject problematic passages. One maneuver is to say that these passages were appropriate for the time and place in which they were written, but the problematic passages are no longer applicable because times and circumstances have changed. They are literally true, but irrelevant to the contemporary world. For example, when the Temple was destroyed, Talmudic rabbis decreed that the Torah's rules of animal sacrifice no longer applied.
Alternatively, one may maintain that problematic passages have been superseded or transformed by newer revelations. For example, some Christians say that certain values and commandments found in the Hebrew Bible have been replaced by those of the New Testament. And some Muslims say that the Hebrew Bible and the New Testament contain simplistic rules which are rendered more sophisticated when read through the lens of the Koran.
Accept the problematic passages and their application. Render them useless.
A nifty maneuver is to wall off the problematic passages by adding nullifying details. For example, Talmudic rabbis faced with explicit endorsement of capital punishment in the Hebrew Bible (e.g. Ex 20:12-17) added extreme qualifications and restrictions which functionally eliminated capital punishment without formally rejecting the passages. For example, they decreed that guilty parties could only be executed if they had previously stated their intention to commit the crime to at least two people who warned them beforehand not to commit the crime, and who later witnessed the crime (Sanhedrin 1:4, Talmud). Similarly, faced with passages in which God orders genocide (e.g. Deut 20:16-18) the rabbis proclaimed that such passages cannot be used as a precedent or justification for any subsequent genocide. God's orders concerned never-to-be-repeated events, like the Biblical flood.
As a last resort, one may simply background the problematic passages. One might say, "The passages are there, and we don't deny that they are true, and they do mean what they seem to mean, but ... well ... we just don't talk about, or invoke them these days." Of course, this is not as decisive a rejection or nullification as the others mentioned above, but it is a functional rejection of the problematic passages, nevertheless. For example, the commandment to punish the misuse of God's name (Lev 24:13-16) is so deemphasized within some strands of Judaism and Christianity that it has virtually vanished.
Counterintuitive though it sounds, the mainstream contemporary Abrahamic religions reject or nullify various problematic passages within their sacred texts. I have listed eight strategies; presumably there are others.
The original U.S. Constitution denied human rights to slaves, but that is not a reason for criticizing the contemporary U.S., for those morally problematic passages in the Constitution have been overturned by various amendments and laws. Similarly, one should not criticize contemporary religions on the basis of problematic passages within their sacred texts, if those problematic passages have been rejected or nullified.