Le root : un inconnu chez soi ?

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Le root : un inconnu chez soi ?

Vous laisseriez le compte admin de votre laptop à un inconnu ? Ou même votre password Gmail ? Alors pourquoi tant d’utilisateurs installent le root sur leurs devices ?
Venez découvrir comment marche réellement ce hack, son évolution au cours des dernières années et ses implications un peu trop vite oubliées.

Bruce Bujon

April 11, 2017

Annual Pro sale · Save $30

Have presentations of your own?

Share with private links, password protection, and more control over your work.

Transcript

106 slides
  1. Qui suis-je ? / $ whoiam  Architecte logiciel 

    Développeur Java  Hacker curieux Bruce BUJON PerfectSlayer @HardCoding
  2. Qu’est-ce que le root ?  Compte utilisateur  UID

    = 0 (User IDentifier)  Tous les droits et toutes les permissions Le « SuperUser »
  3. Qu’est-ce que rooter un device ?  Se donner la

    capacité de se connecter avec le compte root :  Depuis l’écran de connexion,  En substituant son utilisateur par le compte root.
  4. Qu’est-ce que rooter un device ?  Se donner la

    capacité de se connecter avec le compte root :  Depuis l’écran de connexion,  En substituant son utilisateur par le compte root. Shell distant avec adb root Commande su (Substitute User)
  5. Pourquoi rooter un device ?  Opportunités :  Xposed

    Framework  Sauvegarde et restauration avancées  Gestion du noyau  Suppression des bloatwares 5,6 % de devices rootés Source : Google Android Security 2016 report
  6. Pourquoi rooter un device ?  Opportunités :  Xposed

    Framework  Sauvegarde et restauration avancées  Gestion du noyau  Suppression des bloatwares  Penser en dehors des API du SDK/NDK  Reprendre le contrôle de son device 5,6 % de devices rootés Source : Google Android Security 2016 report
  7. Démonstration du root $ adb shell gretprop ro.build.type userdebug $

    adb shell id uid=2000(shell) gid=2000(shell) groups=2000(shell),1004(input), … context=u:r:shell:s0 ROM de développement id : donne l’identifiant courant shell : un utilisateur standard
  8. Démonstration du root $ adb shell gretprop ro.build.type userdebug $

    adb shell id uid=2000(shell) gid=2000(shell) groups=2000(shell),1004(input), … context=u:r:shell:s0 $ adb root $ adb shell id uid=0(root) gid=0(root) groups=0(root),1004(input),… context=u:r:su:s0 ROM de développement id : donne l’identifiant courant shell : un utilisateur standard Redémarre adb avec les permissions root
  9. Démonstration du root en production $ adb shell getprop ro.build.type

    user $ adb root $ adb shell id uid=2000(shell) gid=2000(shell) groups=2000(shell),1004(input), … context=u:r:shell:s0 ROM de production Utilisateur standard
  10. Démonstration du root en production $ adb shell getprop ro.build.type

    user $ adb root $ adb shell id uid=2000(shell) gid=2000(shell) groups=2000(shell),1004(input), … context=u:r:shell:s0 $ adb shell su -c id /system/bin/sh: su: not found ROM de production Utilisateur standard Commande su absente Lance id en tant que root
  11.  lunch <BUILD>-<BULDTYPE>  BUILD  BUILDTYPE : user userdebug

    eng (engineer) Accès limité : production User + root + debug Debug++ : développement Nom de code d’un device ROM cooking : Configuration de la cible
  12. ROM cooking : modules d’une ROM  Le BUILDTYPE définit

    les modules de la ROM : "su": { "class": ["EXECUTABLES"], "path": ["system/extras/su"], "tags": ["debug"], "installed": ["out/target/product/generic/system/xbin/su"] }, "adbd": { "class": ["EXECUTABLES"], "path": ["system/core/adb"], "tags": ["optional"], "installed": ["out/target/product/generic/root/sbin/adbd"] }, Extraits de module-info.json
  13. $ ls -l /system/xbin/su -rwsr-x--- root shell 10280 2017-02-15 21:15

    su Setuid flag + root user ROM cooking : Module su (substitute user)
  14. $ ls -l /system/xbin/su -rwsr-x--- root shell 10280 2017-02-15 21:15

    su $ cat system/extras/su/su.c … setuid(0); setgid(0); … execv(args[0], args); … Setuid flag + root user Utilisateur : root Groupe : root Exécute la commande en paramètre ROM cooking : Module su (substitute user)
  15.  Processus de l’exemple de démonstration : « adb shell

    id » 0 (root) 0 (root) /init /sbin/adbd PID1 Démon adb ROM cooking : Module adbd (démon adb)
  16.  Processus de l’exemple de démonstration : « adb shell

    id » 0 (root) 0 (root) 0 (root)  2000 (shell) /init /sbin/adbd /sbin/adbd PID1 Démon adb Fork adb ROM cooking : Module adbd (démon adb)
  17.  Processus de l’exemple de démonstration : « adb shell

    id » 0 (root) 0 (root) 0 (root)  2000 (shell) 2000 (shell) 2000 (shell) /init /sbin/adbd /sbin/adbd /system/bin/sh /system/bin/id PID1 Démon adb Fork adb Shell Récupère l’identifiant ROM cooking : Module adbd (démon adb)
  18.  Processus de l’exemple de démonstration : « adb shell

    id »  Avec « abd root » 0 (root) 0 (root) 0 (root)  2000 (shell) 2000 (shell) 2000 (shell) /init /sbin/adbd /sbin/adbd /system/bin/sh /system/bin/id PID1 Démon adb Fork adb Shell Récupère l’identifiant 0 (root) 0 (root) ROM cooking : Module adbd (démon adb)
  19.  L’influence du BUILDTYPE sur le root : BUILDTYPE Modules

    adb shell user adb root eng su + adbd 0 (root) OK userdebug su + adbd 2000 (shell) / 0 (root) OK user adbd 2000 (shell) KO ROM cooking : Configuration & modules root
  20.  L’influence du BUILDTYPE sur le root :  Impossible

    d’utiliser les modules officiels pour se connecter en root. BUILDTYPE Modules adb shell user adb root eng su + adbd 0 (root) OK userdebug su + adbd 2000 (shell) / 0 (root) OK user adbd 2000 (shell) KO ROM cooking : Configuration & modules root
  21. HTC Dream / G1  22 Octobre 2008 : Premier

    téléphone commercialisé sous Android
  22. HTC Dream / G1  22 Octobre 2008 : Premier

    téléphone commercialisé sous Android  6 Novembre 2008 : AOSP Issue Tracker, Issue 1207 « In connectbot (ssh client) if you're connected to a remote server, and type reboot, it will reboot both the remote server and the local phone. »
  23. HTC Dream / G1  22 Octobre 2008 : Premier

    téléphone commercialisé sous Android  6 Novembre 2008 : AOSP Issue Tracker, Issue 1207 « In connectbot (ssh client) if you're connected to a remote server, and type reboot, it will reboot both the remote server and the local phone. »
  24. Communauté du root  « How-to-root » sur XDA :

    Koush (Koushik Dutta) CyanogenMod ClockworkMod Cyanogen Inc CyanogenMod
  25. CyanogenMod  Créée en 2009  Rapidement de plus en

    plus populaire  Accès au root inclus
  26. CyanogenMod  Créée en 2009  Rapidement de plus en

    plus populaire  Accès au root inclus Mais « sécurisé » !
  27. Superuser  Package OTA :  /system/app/Superuser.apk  /system/xbin/su 

    Usage :  Runtime.getRuntime().exec("su id");  Popup de confirmation Zinx (Christopher Lais) CyanogenMod Par la recovery
  28. su com.myapp (1) su id (2) uid/gid/cmd permissions.db (3) Vérification

    (4) socket + uid/gid/cmd Superuser : Communications entre processus
  29. su com.myapp superuser (1) su id (2) uid/gid/cmd permissions.db (3)

    Vérification (4) socket + uid/gid/cmd (5) ActivityManager Superuser : Communications entre processus
  30. su com.myapp superuser (1) su id (2) uid/gid/cmd permissions.db (3)

    Vérification (4) socket + uid/gid/cmd (5) ActivityManager (6) Popup Superuser : Communications entre processus
  31. su com.myapp superuser (1) su id (2) uid/gid/cmd permissions.db (3)

    Vérification (4) socket + uid/gid/cmd (5) ActivityManager (6) Popup (7) Réponse Superuser : Communications entre processus
  32. su com.myapp superuser (1) su id (2) uid/gid/cmd permissions.db (3)

    Vérification (4) socket + uid/gid/cmd (5) ActivityManager (6) Popup (7) Réponse (8) Mise à jour Superuser : Communications entre processus
  33. su com.myapp superuser (1) su id (2) uid/gid/cmd permissions.db (3)

    Vérification (4) socket + uid/gid/cmd (5) ActivityManager (6) Popup (7) Réponse id (8) Mise à jour (9) exécute Superuser : Communications entre processus
  34.  Processus 0 (root) 0 (root) 0 (root)  10042

    (u0_a42) /init zygote com.myapp Superuser : Résumé des processus
  35.  Processus 0 (root) 0 (root) 0 (root)  10042

    (u0_a42) 10042 (u0_a42) /init zygote com.myapp /system/xbin/su Superuser : Résumé des processus
  36.  Processus 0 (root) 0 (root) 0 (root)  10042

    (u0_a42) 10042 (u0_a42) 10064 (u0_a64) /init zygote com.myapp /system/xbin/su superuser Superuser : Résumé des processus
  37.  Processus 0 (root) 0 (root) 0 (root)  10042

    (u0_a42) 10042 (u0_a42) 0 (root) 10064 (u0_a64) /init zygote com.myapp /system/xbin/su /system/bin/id superuser  0 (root) Superuser : Résumé des processus
  38. 2008 2009 2010 2011 2012 2013 2014 Zinx ChainsDD (Adam

    Shanks) CyanogenMod Superuser : Historique
  39. 2008 2009 2010 2011 2012 2013 2014 Zinx Koush ChainsDD

    (Adam Shanks) CyanogenMod Superuser : Historique
  40. 2008 2009 2010 2011 2012 2013 2014 Zinx Koush ChainsDD

    (Adam Shanks) CyanogenMod Android 4.3 ! Superuser : Historique
  41.  Processus 0 (root) 0 (root) 0 (root)  10042

    (u0_a42) 10042 (u0_a42) 0 (root) /init zygote com.myapp /system/xbin/su /system/bin/id  0 (root) Android 4.3 : Nouvelle approche
  42.  Processus 0 (root) 0 (root) 0 (root)  10042

    (u0_a42) 10042 (u0_a42) 0 (root) /init zygote com.myapp /system/xbin/su /system/bin/id  0 (root) nosuid capacités-- Android 4.3 : Nouvelle approche
  43. ChainFire (Jorrit Jongma) SuperSU  Processus 0 (root) 0 (root)

    0 (root)  10042 (u0_a42) 10042 (u0_a42) 0 (root) /init zygote com.myapp /system/xbin/su /system/bin/id  0 (root) nosuid capacités-- Android 4.3 : Nouvelle approche
  44. ChainFire (Jorrit Jongma) SuperSU  Processus  su devient un

    service (démon su) 0 (root) 0 (root) 0 (root)  10042 (u0_a42) 10042 (u0_a42) 0 (root) 0 (root) /init zygote com.myapp /system/xbin/su /system/bin/id su --daemon  0 (root) nosuid capacités-- Android 4.3 : Nouvelle approche
  45. SuperSU : Mise en place du service  Services lancés

    par init  Configuration : /init.rc  Dans la partition boot  Non (facilement) modifiable
  46. SuperSU : Mise en place du service  Services lancés

    par init  Configuration : /init.rc  Dans la partition boot  Non (facilement) modifiable  Extrait : service flash_recovery /system/bin/install-recovery.sh class main oneshot Extraits de /system/code/rootdir/init.rc Patché pour démarrer le démon su
  47. com.myapp su (client) (3) su id su (démon) init (1)

    install-recovery.sh (2) socket SuperSU : Communications entre processus
  48. com.myapp su (client) (3) su id su (démon) init (1)

    install-recovery.sh (2) socket (4) pid/uid/cmd SuperSU : Communications entre processus
  49. com.myapp su (client) (3) su id su (démon) init (1)

    install-recovery.sh (2) socket (4) pid/uid/cmd su (fils) (5) fork SuperSU : Communications entre processus
  50. com.myapp su (client) (3) su id su (démon) init (1)

    install-recovery.sh (2) socket (4) pid/uid/cmd su (fils) (5) fork SuperSU : Communications entre processus
  51. com.myapp su (client) (3) su id su (démon) init (1)

    install-recovery.sh (2) socket (4) pid/uid/cmd su (fils) (5) fork SuperSU : Communications entre processus
  52. com.myapp su (client) (3) su id su (démon) init (1)

    install-recovery.sh (2) socket (4) pid/uid/cmd su (fils) (5) fork (6) exit code SuperSU : Communications entre processus
  53. com.myapp su (client) (3) su id su (démon) init (1)

    install-recovery.sh (2) socket (4) pid/uid/cmd su (fils) (5) fork (6) exit code (7) exit code SuperSU : Communications entre processus
  54. com.myapp su (client) (3) su id su (démon) init (1)

    install-recovery.sh (2) socket (4) pid/uid/cmd su (fils) (5) fork (6) exit code (7) exit code (8) exit code SuperSU : Communications entre processus
  55.  Processus 0 (root) 0 (root) 0 (root) /init su

    --daemon zygote SuperSU : Résumé des processus
  56.  Processus 0 (root) 0 (root) 0 (root) 10042 (u0_a42)

    10042 (u0_a42) /init su --daemon zygote com.myapp /system/xbin/su SuperSU : Résumé des processus
  57.  Processus 0 (root) 0 (root) 0 (root) 0 (root)

    10042 (u0_a42) 10042 (u0_a42) /init su --daemon su zygote com.myapp /system/xbin/su SuperSU : Résumé des processus
  58.  Processus 0 (root) 0 (root) 0 (root) 0 (root)

    10042 (u0_a42) 10042 (u0_a42) 10064 (u0_a64) /init su --daemon su zygote com.myapp /system/xbin/su superuser SuperSU : Résumé des processus
  59.  Processus 0 (root) 0 (root) 0 (root) 0 (root)

    0 (root) 10042 (u0_a42) 10042 (u0_a42) 10064 (u0_a64) /init su --daemon su /system/bin/id zygote com.myapp /system/xbin/su superuser SuperSU : Résumé des processus
  60. Modifications de la ROM détectées Plus d’OTA Android 4.4 /

    Android 5.0 : Verified boot & block-based OTA
  61. SuperSU : « systemless » root ChainFire boot / /init.rc

    /system /data /xbin/su /install-recovery.sh /app /data Operating System User data Kernel RAM disk
  62. SuperSU : « systemless » root ChainFire boot / /init.rc

    /system /data /xbin/su /install-recovery.sh /app /data Verified boot Operating System User data Kernel RAM disk
  63. SuperSU : « systemless » root ChainFire boot / /init.rc

    /system /data /xbin/su /install-recovery.sh /app /data /su.img Verified boot /su /bin/daemonsu /bin/su + patchs Operating System User data SuperUser Kernel RAM disk
  64. SuperSU : Modifitations du boot  Modifications de la configuration

    d’init : # mount /data/su.img to /su on property:sukernel.mount=1 mount ext4 loop@/data/su.img /su noatime # launch SuperSU daemon service daemonsu /sbin/launch_daemonsu.sh service class late_start user root seclabel u:r:init:s0 oneshot Partition /su Démon su Extraits de init.su.rc
  65. Android 4.3 / 4.4 / 5.0 / 7.0 : SELinux

     Security-Enhanced Linux pour Android :  Amélioration du sandboxing
  66. ≤ 4.4 : permissive 5.0 : enforcing Android 4.3 /

    4.4 / 5.0 / 7.0 : SELinux  Security-Enhanced Linux pour Android :  Amélioration du sandboxing
  67. ≤ 4.4 : permissive 5.0 : enforcing Android 4.3 /

    4.4 / 5.0 / 7.0 : SELinux  Security-Enhanced Linux pour Android :  Amélioration du sandboxing  1ère solution de contournement par ChainFire’s SuperSU
  68. Résumé : Complexité du « root »  Évolutions :

     Gestion des permissions + interactions utilisateur  Nouveau service Linux  Nouvelle partition  Support des règles de sécurité
  69. Résumé : Complexité du « root »  Évolutions :

     Gestion des permissions + interactions utilisateur  Nouveau service Linux  Nouvelle partition  Support des règles de sécurité  Services personnalisés  Surcouche de /system
  70. Résumé : Complexité du « root »  Évolutions :

     Gestion des permissions + interactions utilisateur  Nouveau service Linux  Nouvelle partition  Support des règles de sécurité  Services personnalisés  Surcouche de /system  ChainFire’s SuperSU toujours précurseur su.d su --bind
  71. SuperSU : solution closed source  Exécutables installés : /data/SuperSU.apk

    /su/bin/daemonsu /su/bin/app_process /su/bin/su /su/bin/sukernel /su/bin/supolicy_wrapped /su/bin/supolicy /su/lib/supol.so /su/bin/sush /sbin/launch_daemonsu.sh
  72. SuperSU : solution closed source  Exécutables installés : /data/SuperSU.apk

    /su/bin/daemonsu /su/bin/app_process /su/bin/su /su/bin/sukernel /su/bin/supolicy_wrapped /su/bin/supolicy /su/lib/supol.so /su/bin/sush /sbin/launch_daemonsu.sh Closed source
  73. SuperSU : solution closed source  Exécutables installés : /data/SuperSU.apk

    /su/bin/daemonsu /su/bin/app_process /su/bin/su /su/bin/sukernel /su/bin/supolicy_wrapped /su/bin/supolicy /su/lib/supol.so /su/bin/sush /sbin/launch_daemonsu.sh Closed source Extrait de « How-To SU »
  74. SuperSU : solution closed source  Exécutables installés : 

    Bonus :  Remplace forceencrypt par encryptable dans fstab  Désactive dm-verity et supprime les clefs (par défaut) /data/SuperSU.apk /su/bin/daemonsu /su/bin/app_process /su/bin/su /su/bin/sukernel /su/bin/supolicy_wrapped /su/bin/supolicy /su/lib/supol.so /su/bin/sush /sbin/launch_daemonsu.sh Closed source Extrait de « How-To SU »
  75.  Gratuit (option « Pro » ≤ 5%)  5

    ans de développement  Large support de devices SuperSU Interrogations
  76.  Gratuit (option « Pro » ≤ 5%)  5

    ans de développement  Large support de devices  Septembre 2015 : acquisition par CCMT (Coding Code Mobile Technology) LLC  « They have invested in, or own, a number of popular root apps (though I am not at liberty to disclose which ones) » - ChainFire  Enregistée dans le Delaware (US) mais WHOIS chinois et offres d’emploi à Pékin ? SuperSU Interrogations
  77. Installations « one-click » : King Root, One-click root, KingoRoot

     Adressées aux néophytes :  Solutions en 1 clic !  Gratuites !  24/7 support !
  78. Installations « one-click » : King Root, One-click root, KingoRoot

     Adressées aux néophytes :  Solutions en 1 clic !  Gratuites !  24/7 support !
  79. Installations « one-click » : King Root, One-click root, KingoRoot

     Adressées aux néophytes :  Solutions en 1 clic !  Gratuites !  24/7 support !
  80. Installations « one-click » : King Root, One-click root, KingoRoot

     Adressées aux néophytes :  Solutions en 1 clic !  Gratuites !  24/7 support !
  81. Privacy ? Malware ? Installations « one-click » : King

    Root, One-click root, KingoRoot  Adressées aux néophytes :  Solutions en 1 clic !  Gratuites !  24/7 support !  Excellent référencement  Toutes closed source
  82. 2008 2009 2010 2011 2012 2013 2014 Zinx Koush ChainsDD

    Résumé : Superuser / SuperSU / Magisk 2015 2016 2017 Superuser
  83. 2008 2009 2010 2011 2012 2013 2014 Zinx Koush ChainsDD

    Résumé : Superuser / SuperSU / Magisk 2015 2016 2017 ChainFire CCMT Superuser SuperSU ?
  84. 2008 2009 2010 2011 2012 2013 2014 Zinx Koush ChainsDD

    Résumé : Superuser / SuperSU / Magisk 2015 2016 2017 ChainFire CCMT phhusson topjohnwu Superuser SuperSU ?
  85.  Fonctionnement du root  Implications sur la sécurité 

    Importance d’une solution open-source Conclusion
  86.  Fonctionnement du root  Implications sur la sécurité 

    Importance d’une solution open-source phh‘s Superuser goo.gl/4lWtqd Magisk goo.gl/2pYeie Conclusion
  87. Merci à vous ! Questions ? Bruce Bujon – @HardCoding

    Slides : speakerdeck.com/perfectslayer/

More Decks by Bruce Bujon

Other Decks in Programming