Under Security Council Resolution 1373, which was adopted under Chapter VII and is therefore binding, Israel, Egypt and all other states are required to take steps to criminalize and prevent all material support – active or passive, direct or indirect – to terrorist groups. Thus, all states bordering Gaza are legally obliged to prevent the flow of arms and other materiel to Hamas. Israel is also a party to the International Convention for the Suppression of Terrorist Bombings, which renders it criminal for any individual, Israeli or not, to supply rockets, mortars and missiles to Hamas and the other Palestinian terrorist groups. Israel and other state signatories are required to take steps to punish such criminals.
In addition, all states have the right to control their own borders. Israel has the right to prevent the flow of arms to Gaza across its own border with Gaza. Egypt has the same right to prevent the flow of arms across its Gaza. And Israel has the right to demand that Egypt exercise this right both on the grounds of Israeli-Egyptian agreements requiring Egypt to do so and on the basis of Egypt’s obligations under 1373.
Then there are issues related to the legal status of Gaza. If Israel still “occupies” Gaza as is implausibly claimed by the UN and various human rights groups, Israel has a duty to maintain order under article 43 of the Regulations attached to the Fourth Hague Convention, which means Israel is required by the law of occupation to prevent arms from reaching terrorists and militias.
If we set aside the implausible argument that Gaza is occupied, there are two relevant possibilities. Either Gaza is a sovereign state of Palestine or it is territory without a sovereign.
If Gaza is territory without a sovereign, Israel, like any other state, may block the flow of arms because Gaza has no right to object — it has no sovereignty to infringe. Gaza could only object if Israel were violating a relevant humanitarian provision (eg, preventing all entry of food without valid security justification). But there is no humanitarian right to import arms. Even the right to obtain provisions like food is limited in all sorts of ways (such as the right to deny access if food is likely to be diverted to the enemy combatants).
If Gaza is a sovereign Palestinian state, then it has sovereign rights. However, the sovereign rights entail control over its borders on its side, not control over the other side. Thus, Gaza has no right to force Egypt or Israel to permit arms over shared borders. Moreover, as you noted, Hamas purports to be the legitimate governing authority by virtue of elections of the Palestinian Authority and, as such, it is bound to the legal duties of the Palestinian Authority. One of these duties, as agreed to by the PLO in the Oslo Accords, is not to import arms.
The more interesting question is posed by attempts to smuggle arms by air or sea. These are not shared borders with either Egypt or Israel. Israel prevents shipping arms through air and sea, and this must be justified in one of a number of ways. Again, let’s consider the possibilities based on the legal status of Gaza.
If Israel still “occupies” Gaza as is implausibly claimed by the UN and various human rights groups, Israel’s duty to maintain order includes policing shipment of arms by sea and air. Thus, again, Israel is required by the law of occupation to prevent arms from reaching terrorists and militias.
Setting aside the implausible argument that Gaza is occupied, we again have two main possibilities: Palestinian sovereignty and no sovereign.
If Gaza is not sovereign, Israel can enter Gazan air and sea space to intercept arms freely, since Gaza has no sovereign rights to abridge.
If Gaza is sovereign, Israel has the right to block shipment of arms through air or sea space through one of two theories:
Gaza is involved in an armed conflict with Israel, so Israel has the right to enter Gazan air and sea territory (and to otherwise blockade Gaza) in order to prevent the supply of war materiel to Gaza.
Even if Gaza were not involved in an armed conflict, Israel would arguably have a right under doctrines of anticipatory self-defense to prevent Gaza acquiring arms that are clearly intended to be used to attack Israeli civilians and other Israeli targets. This last theory is possibly controversial as there are some international lawyers who deny the existence of a right of anticipatory self-defense. For those who agree that there is such a right, Israel fulfills the basic conditions of necessity, proportionality and imminence.