MacOS Recovery Mode Risk

disk-utilitypartitionrecoverySecurity

(A related question was previously posted in the Asahi Linux forum, I didn't get an answer there; see https://discussion.fedoraproject.org/t/question-and-worries-about-wipe-linux-in-recovery-mode/117284)

I've been experimenting with Asahi Linux on my MacBook and performed multiple reinstallations. To remove leftover volumes (normally read-only), I ran a 'wipe-linux' command in Recovery Mode. While the script seemed to work by deleting the volumes, I'm now concerned about a possible typo during execution.

My question:

If the script I ran was malicious, could it have bypassed the read-only protections and injected malware into my main data partition or the recovery/boot partitions (apple_apfs_isc and apple_apfs_recovery)? These partitions appear writable in Recovery Mode (recovery/boot partitions are usually read only), which worries me.

I am aware that MacOS has a pretty robust virus/malware detection, and virus/malware are uncommon on MacOS anyways. However, it seems that in Recovery Mode there is too much power given and I am afraid something could go south.

Best Answer

Short answer: yes, it's extremely dangerous. Almost all of macOS' normal protections are disabled (or disable-able) in recovery mode.

Recovery mode is intended to allow you to perform basic setup and repairs to your system, like reinstalling macOS, repairing or formatting the disk, and changing security settings. It is NOT intended to be a mode where you'd run any non-Apple software, and it's a really bad idea to run anything you don't completely trust in recovery mode.

In fact, the script you linked prints this message when you run it:

THIS SCRIPT IS DANGEROUS!
DO NOT BLINDLY RUN IT IF SOMEONE JUST SENT YOU HERE.
IT WILL INDISCRIMINATELY WIPE A BUNCH OF PARTITIONS
THAT MAY OR MAY NOT BE THE ONES YOU WANT TO WIPE.

You are much better off reading and understanding this guide:
https://github.com/AsahiLinux/docs/wiki/Partitioning-cheatsheet

That said, while the script is certainly dangerous in that it may delete things you really didn't mean to delete, I don't see any sign that it does anything malicious. It only deletes things, it doesn't install anything or modify anything (except for creating a temporary file of UUIDs that'll vanish when you reboot).

So I don't think you need to worry that it's compromised your system, but it would be a really good idea to have a backup (or better yet, two) of anything you don't want to lose.