How is Internet Recovery able to connect to my Wi-Fi access point even after I changed the hard drive? I wanted to upgrade my MacBook Pro. It should get a newer version of macOS and also a SSD instead of a HDD. So I pointed the macOS Installer to the SSD that was connected using a USB to SATA connector.

After replacing the Hard Disk, while the battery was disconnected, I tried to boot into the newly installed macOS. That didn't succeeded, so it booted into Internet Recovery.

Since the Hard Disk where the password was stored, was completely removed from the computer, where did the Mac get SSID and password for accessing the Wi-Fi access point?



I wiped the SSD to reinstall the OS. Internet Recovery was still able to connect to the Wi-Fi access point. From this it follows that the Wi-Fi configuration (of the last used Wi-Fi access point) must be stored somewhere else. Where and how can I read from there?
Passwords for the previously connected Wi-Fi access point are also stored in your Mac's NVRAM (along with the keychain which is managed by macOS and is stored in your hard drive).

From the Apple Support article, Reset NVRAM or PRAM on your Mac:


  NVRAM (nonvolatile random-access memory) is a small amount of memory that your Mac uses to store certain settings and access them quickly.
  
  Settings that can be stored in NVRAM include sound volume, display resolution, startup-disk selection, time zone, and recent kernel panic information. The settings stored in NVRAM depend on your Mac and the devices that you're using with your Mac.


That explains why your Mac is able to retrieve and connect to previously known Wi-Fi access point, even after swapping the hard drive.

The data stored in NVRAM is for use by your Mac and is not directly user accessible.