Where is macOS Internet Recovery stored? I read on another site that you can use macOS Internet Recovery to install macOS on a blank SSD? Where would the files be stored? On the firmware? If there any way that the firmware could be erased? (I.e. would running sudo rm -rf / on the disk also wipe the firmware or is it more complicated than that? Is there any way that the firmware could be erased?). I'm working on a disaster recovery plan incase I ran a stupid command like sudo rm -rf /.
Long Version:
The code which permits Internet Recovery Mode (i.e. a slightly modified TFTP client) is stored in the computer's firmware. (In fact, it is a part of it). It's similar to the BIOS chip on Windows computers. When you boot through Internet Recovery, it will download a recovery partition image and load it into the computer's RAM. After this process, you will be able to boot into the normal macOS Recovery interface.

Short Version:
If you were to wipe/replace your hard drive, Internet Recovery would automatically download and load a recovery partition image into the RAM, so you would be safe (as long as you have a backup of your data).

PS.
Also, it is impossible to wipe the laptop's firmware with a simple sudo rm -rf / command.

Source: Chat with Apple Support