Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:18:71

So they set out, until when they had embarked on the ship, al-Khidh r tore it open. ˹Moses˺ said, "Have you torn it open to drown its people? You have certainly done a grave thing."  

So they set off, making their way on foot along the coast of the sea, until, when they embarked on the ship, which was carrying them, he, al-Khidr, made a hole in it, by destroying a plank or two on the starboard side with an axe after they had sailed into deep waters. Said he, Moses, to him, ‘Did you make a hole in it to drown its people? (li-tughriqa ahlahā, ‘for you to drown its people’; a variant reading has li-yaghraqa ahluhā, ‘so that its people might drown’). You have certainly done a dreadful thing’, that is, a grave and reprehensible thing — it is reported that the water did not ˹actually˺ penetrate it.
القرآن:١٨:٧١

فَانْطَلَقَا حَتَّىٰ إِذَا رَكِبَا فِي السَّفِينَةِ خَرَقَهَا ۖ قَالَ أَخَرَقْتَهَا لِتُغْرِقَ أَهْلَهَا لَقَدْ جِئْتَ شَيْئًا إِمْرًا  

{فانطلقا} يمشيان على البحر {حتى إذا ركبا في السفينة} التي مرت بهما {خرقها} الخضر بأن اقتلع لوحا أو لوحين منها من جهة البحر بفأس لما بلغت اللجج {قال} له موسى {اخرقتها لتغرق أهلها} وفي قراءة بفتح التحتانية والراء ورفع أهلها {لقد جئت شيئا إمرا} أي عظيما منكرا روي أن الماء لم يدخلها.