What is the Torah approach to when terrorists are using civilians as human shields? Are you allowed to bomb the building?
There is no ancient commentary on causing civilian casualties in a just war. [Rav J. David Bleich, Contemporary Halakhic Problems 3, p 277] Some interpret that to mean the answer is obvious: Yes, civilians may be killed with soldiers if it is unavoidable in a defensive war. The Talmud notes:
Once permission has been granted to an angel to destroy, it does not distinguish between righteous and wicked. [Bava Kamma 60a]
Thus, the default position is that the innocent perish with the guilty. Indeed, before the Exodus, we had to distinguish ourselves from the Egyptians to prevent our own firstborn from dying. Also, Abraham had to ask God to save Sodom and Gomorrah for the sake of the righteous in it. [Gen. 18:23-32] It was not an automatic thing. Finally, the Talmud says, “kill him first”, without adding “but with no collateral damage”. The Maharal concludes:
The Torah allows war when we are attacked, and in responding, we are allowed to not distinguish between the guilty and the innocent. [Gur Aryeh to Gen. 34:13]
However, warning may be given. The Torah says: When you approach a town to attack it, you shall offer it terms of peace.[Deuteronomy 20:10] In commenting, the Midrash tells us:
Rav Shmuel bar Naḥman said: What did Joshua do [when he was about to enter the Promised Land]? He would publish an edict in every place [of the Land of Canaan] he went to conquer, on which he wrote: “Whoever wants to go, let him go; whoever wants to make peace with us, let him make peace; and whoever wants to make war shall make war.”
-The Girgashites vacated and departed from there, and the Holy One, blessed be He, gave them a land as beautiful as their native land, namely Africa.
-The Gibeonites desired to make peace with Israel, and Joshua made peace with them.
-However, the 31 Canaanite kings came to battle with Joshua, and the Holy One blessed be He caused them to fall. [Deut. R. 5:14]
Likewise, King Saul advised the Kenites to leave their homes to avoid being harmed in the war with Amalek:
And Saul said to the Kenites, “Go, depart, get down from among the Amalekites, otherwise I might destroy you with them; for you showed kindness to all the people of Israel, when they came out of Egypt.” So the Kenites departed from among the Amalekites... And Saul defeated the Amalekites... [1 Samuel 15:6-7]
So Saul was prepared to endanger civilians in the course of war, and he was not censured for this.
Not a full answer but we can infer from the Mizrachi his opinion on this matter.
The Torah tells us that Yaakov was very afraid of Eisav (Genesis 32:8). Rashi (ad loc.) explains that he was afraid that he would kill, or be killed. The Mizrachi (ad loc.) is bothered, that why was he afraid to kill? He's allowed to kill in self-defense!
He suggests that Yaakov was afraid of killing the 400 men that were with Eisav. He says if they were being forced by Eisav to accompany him, they were innocent civilians. Yaakov was afraid of killing them in self-defense, for it would be forbidden to kill them, as they were being forced against their will to attack Yaakov.
He ends up rejecting this approach, for if the men were being forced to attack Yaakov, they should have given up their lives rather than kill someone to save their own life. Since they were unjustified in "innocently" attacking Yaakov, he would have been allowed to kill them in self-defense.
I heard from Rav Tzvi Berkowitz of Ner Yisroel that if it were a situation where they were passively endangering someone's life, like a human shield, we can infer from the Mizrachi that it would be forbidden to kill them, even in self-defense.
The Gur Aryeh ad loc. says similar to the Mizrachi, but the Yefeh Toar to Bereishis Rabbah 76:2 questions the Mizrachi's premise.
The only rules in the Torah about treatment of the enemy are
- Don't cut down fruit trees while besieging.
- Offer the enemy the opportunity to flee or surrender and be enserfed.
- Special rules about capturing a woman but there is a dispute about what they actually are.
There is no Geneva convention or anything like it.