04/09/21 v2
Just install this Module via magisk manager:which is mentioned by this thread:

Magisk General Support / Discussion
This is the place for general support and discussion regarding "Public Releases", which includes both stable and beta releases. All information, including troubleshoot guides and notes, are in the Announcement Thread

You need it + safetynetfix from kdrag0n then you have valid safetynet.
04/09/21
For the last two days there has been an update on Google's site that causes Safetynet to fail on your phone. It didn't work on my phone and a colleague's phone, but it worked on another colleague's phone with no problems. So it may or may not fail on your end.If you have the problem with safetynet failing. First update magisk to v.23 and the manager to the latest version.
Then we need lsposed with a separate module for lsposed. You can use edxposed, but for most users it laggs much more than lsposed.
If you don't have lsposed. You need to install the following two Magisk modules in the order described.
1. riru
2. riru - LSposed
Otherwise you will get an installation error because the core is missing.
After the installation, restart the phone.
Then the LSposed manager should be visible in your launcher. If not, download the full zip package from here:
Releases · LSPosed/LSPosed
LSPosed Framework. Contribute to LSPosed/LSPosed development by creating an account on GitHub.
Extract the manager.apk from it and install it.
Inside the manager, you should get a green message with "activated". If not, you have not installed the module.
Inside the Lsposed manager, install the XprivacyLua module from the repo. The search function is located at the bottom.
Go to Modules and click on XprivacyLua. And tick the two items for the recommended applications:
System Framework
settings storage
Then click on the 3 dots at the top right.
There, uncheck the item in "Hide -> System apps".
Now you can search in the app list for
Google play Services and set the hook.
Then click on the gear icon on the top right and the app XprivacyLua will open.
In it, search for Google play Services again and set the checkmark next to the gear icon so that each sub-checkmark is set.
Now we need to hide the Magisk Manager. To do this, open the Magisk Manager.
Click on the gear icon at the top right of the main menu. Then click on hide magisk manager. Enter the desired name and wait until the Magisk Manager opens again.
If you have not installed the Safetynet fix from kdrag0n, you can download it here:
GitHub - kdrag0n/safetynet-fix: Google SafetyNet attestation workarounds for Magisk
Google SafetyNet attestation workarounds for Magisk - GitHub - kdrag0n/safetynet-fix: Google SafetyNet attestation workarounds for Magisk
Then install it from the "modules" menu in magisk manager using the "install module from storage" function.
Once you have installed the Safetynet Fix module, restart the phone.
Then open the Settings app and navigate to the Apps section. Then search for Google Play Services, open it and in the storage option, use the function to clear the cache memory.
Now you can check Safetynet again in Magisk and it should be valid.
19/04/21:
There is currently a problem with magisk checking safetynet. When you check safetynet in magisk, you get a safetynet API error. Either use an alternative Safetynet app e.g. Safetynet Test or install the magisk canary app. I heard it was fixed there, but don't know for sure.
I wrote this entire tutorial already in this Thread, but I think it should be separated, so everyone can find it easier:
https://forum.xda-developers.com/showpost.php?p=83736713&postcount=89
This Tutorial descripes 3 Points:
- Unlock Bootloader - which is necessary for root
- Get root via Magisk
- Valid Safetynet
Enable Developer mode in settings
- Open Settings App
- Move to About The Phone
- 7 Taps on the Build-Number
Enable OEM-Unlock in settings
- Go back to Main Menu of Settings
- move to system
- Unfold Extended
- Open Developer options
- Enable OEM-Unlock
If you go further, you should either have a clean phone or backup your data. Because if you unlock the bootloader, the entire phone will be wiped.
Reboot Phone in Fastboot
- Turn off Phone with long press on Power Button and click turn off
- Press Power Button + Lower Volume together for some seconds and you are in fastboot mode
Use Fastboot to unlock Phone
If you don't have it download at first the needed adb and fastboot files for your system:
https://developer.android.com/studio/releases/platform-tools
Extract it to a path where you want it.
- Connect your P5 with your PC with an USB cable
- Open the path where you have extracted the adb tools.
- On Windows press Shift + Right click and in the context menu click on open commandline Window
- If you enter the following console command you should see an listed device about it's serial number:
Code:fastboot devices
It could be that you have to install the usb drivers at first for recognizing it via fastboot.
If a Serial was listed in the Previous step, go further.
Enter the following command to start to unlocking your phone
Code:
fastboot flashing unlock
On your Phone you see a message to "not unlock your phone", with volume up you switch it to "unlock your phone". With the Power Button you accept it.
It will reboot now and at this moment it wipes the entire phone, so you start again from scratch to configure the p5.
if you have a Pixel 5 without the KDDI Version, you can use the following boot image, which is already a prepatched boot image including magisk 21 (Build 21005).
Download it at first:
http://www.mediafire.com/file/8ll4mlzt3l9njph/magisk_patched+Build+21005.img/file
KDDI variant: http://www.mediafire.com/file/widag4w5s02itq5/magisk_patched+KDDI.img/file
Copy the img-file to the path where you had extracted the adb files.
After you have configured your phone so you can use it, turn off p5 again and go again into fastboot mode.
Ensure your phone is connected via usb to the PC.
In the opened command line Window enter the following command:
Code:
fastboot flash boot "magisk_patched Build 21005.img"
For windows powershell Users check this out, if the above command failed:
A suggestion, please add that those having issues with the flash command failing to WRITE can try putting ./ before the command and that should work.
hm not working for me. P5 is unlocked.
C:\>fastboot flash boot "magisk_patched Build 21005.img"
target reported max download size of 268435456 bytes
sending 'boot' (98304 KB)...
OKAY [ 2.419s]
writing 'boot'...
FAILED (remote: Failed to write to partition Not Found)
finished. total time: 2.500s
Do:
./fastboot flash boot "magisk_patched Build 21005.img"
After it finished you can reboot your phone into android system and you will see the magisk manager logo.
Open it and you should see magisk 21005 is installed, then you know root access is granted.
For Safetynet you have to do the following steps
- In Magisk Manager open settings gear.
- under Magisk enable MagiskHide
- Above MagiskHide is a menupoint called "Hide Magisk Manager", click on it, give the magisk manager a new name, click ok and wait until it's reopend.
- Go to main menu of the magisk manager. On bottom is a "shield icon" open it.
- Go to "MagiskHide"
- On Top is the item "Google Play Services" unfold it and set every hook on it.
- It's recommended to set the hook on every google Service you find.
- Go Back to main menu of magisk manager
- Download the latest universal safetynet fix for your P5:
Release v2.4.0 · kdrag0n/safetynet-fix
Highlights Play Integrity bypass without breaking device checks or causing other issues Disabled use of hardware attestation on Pixel 7 and newer (@anirudhgupta109) Other changes Updated instruc...github.com
- After finished installation reboot your P5.
Now you have a rooted phone and a valid safetynet.
Last edited: