Viewing and resetting the BIOS passwords on the RedmiBook 16
I recently lost the BIOS password for my Xiaomi RedmiBook 16. Luckily, viewing and even resetting the password from inside a Linux session turned out to be incredibly easy.
As it turns out, both the user and the system ("supervisor") passwords are not hashed in any way and stored as plaintext inside EFI variables. Viewing these EFI variables is incredibly easy on a Linux system where efivarfs is enabled, even under a regular user account and if secure boot is enabled:
$ uname -a
$ whoami
$ sudo dmesg | grep "Secure boot"
Reading the variables:
$ hexdump -C /sys/firmware/efi/efivars/SystemSupervisorPw*
$ hexdump -C /sys/firmware/efi/efivars/SystemUserPw*
If you have a root shell, removing the passwords entirely is also possible:
# chattr -i /sys/firmware/efi/efivars/SystemUserPw* /sys/firmware/efi/efivars/SystemSupervisorPw*
# rm /sys/firmware/efi/efivars/SystemUserPw* /sys/firmware/efi/efivars/SystemSupervisorPw*Reboot, and the BIOS no longer asks for a password to enter setup, change secure boot settings, etc.