BE PARANOID OR NOT TO BE ? Alize PENEL Linux and Android System - - PowerPoint PPT Presentation

be paranoid or not to be aliz e penel
SMART_READER_LITE
LIVE PREVIEW

BE PARANOID OR NOT TO BE ? Alize PENEL Linux and Android System - - PowerPoint PPT Presentation

BE PARANOID OR NOT TO BE ? Alize PENEL Linux and Android System Developer Dev Team Member Agenda 02 03 01 Network Security Internet socket in Aspects Permission in Android OS Marshmallow INTERNET PERMISSION IN MARSHMALLOW


slide-1
SLIDE 1

BE PARANOID OR NOT TO BE ?

slide-2
SLIDE 2

Alizée PENEL

Linux and Android System Developer Dev Team Member

slide-3
SLIDE 3

Agenda

01

Internet Permission in Marshmallow

02

Network socket in Android OS

03

Security Aspects

slide-4
SLIDE 4

INTERNET PERMISSION IN MARSHMALLOW

slide-5
SLIDE 5

INTERNET PERMISSION DECLARATION

AndroidManifest.xml

htups:/ /github.com/vx/connectbot from VX Solutjons

slide-6
SLIDE 6

INTERNET PERMISSION DEFINITION

frameworks/base/core/AndroidManifest.xml

slide-7
SLIDE 7

MARSHMALLOW PERMISSIONS

Permission are automatjcally granted at install tjme

  • UI shows permissions details
  • UI from Google Play, not from the system

Dangerous permissions are granted at runtjme

slide-8
SLIDE 8

INTERNET PERMISSION INTERNALS

On device : /system/etc/permissions/platgorm.xml system/core/include/private/android_fjlesystem_confjg.h

root@genymotion:/ cat /data/system/packages.list

slide-9
SLIDE 9

MAPPING GID PROCESS

slide-10
SLIDE 10

That’s all ? Anything is checked at the runtjme ?

slide-11
SLIDE 11

NETWORK SOCKETS IN ANDROID OS

slide-12
SLIDE 12

THE BASICS

slide-13
SLIDE 13

JAVA.NET.SOCKET CLASS

Any applicatjon can directly instantjate this class

Even the framework uses it

Packed in Android Java core library : core-libart.jar

Source fjle : libcore/luni/src/main/java/net/Socket.java

slide-14
SLIDE 14
slide-15
SLIDE 15

ANY PERMISSION CHECKED !?

slide-16
SLIDE 16

SOCKET SYSCALL IN BIONIC

bionic/libc/bionic/socket.cpp Same type of declaratjon for connect and accept syscalls

NetdClientDispath, C structure of 4 functjon pointers on 3 syscalls ( __socket, __connect, __accept4) & 1 functjon (fallBackNetIdForResolv)

slide-17
SLIDE 17

WHAT HAPPENING IN BIONIC ?

As soon as bionic is loaded, the functjon __libc_preinit() is called by the dynamic linker In __libc_preinit(), call to netdClientInit() functjon The libnetd_client.so library is loaded by dlopen()

slide-18
SLIDE 18

WHAT HAPPENING IN BIONIC ?

From libnetd_client.so library, bionic retrieves 4 functjon symbols :

  • netdClientInitSocket()
  • netdClientInitConnect()
  • netdClientInitAccept4()
  • netdClientInitNetIdForResolv()

Call them, one by one, with their respectjve syscall as a parameter.

slide-19
SLIDE 19

NETDCLIENT LIBRARY

slide-20
SLIDE 20

IMPACTS ON NETDCLIENTDISPATCH STRUCTURE

NetdClientDispatch structure does not contain the syscalls

anymore It points on libnetd_client library functjons :

  • netdClientSocket()
  • netdClientConnect()
  • netdClientAccept4()
  • getNetworkForResolv()
slide-21
SLIDE 21
slide-22
SLIDE 22

WHAT !?

slide-23
SLIDE 23

ANDROID KERNEL

Android kernels have many modifjcatjons Every Android kernel has a network optjon actjvated : Paranoid

slide-24
SLIDE 24

PARANOID KERNEL OPTION

It restricts access to some networking features depending

  • n the group of the calling process

include/linux/android_aids.h

slide-25
SLIDE 25

SOCKET CREATION IN THE KERNEL

In net/ipv4/af_inet.c & net/ipv6/af_inet6.c, the process group is checked before creatjng the socket If not allowed, return EACCES

slide-26
SLIDE 26

SUMMARY

slide-27
SLIDE 27

INTEREST OF NETDCLIENT LIBRARY AND BIONIC TRICK

Firewall marks in netd Networks packets are fmagged through a fwmark client/server mechanism Allow packets going through iptable rules, set by the OS In a “system case”, fwmark server checks also the permission

  • f the process
slide-28
SLIDE 28

SECURITY ASPECTS

slide-29
SLIDE 29

DISCLAIMER

I am NOT a Security developer Consider just the architectural aspect of the implementatjon

slide-30
SLIDE 30

HOW TO BREAK THE SYSTEM ?

Internet permission Paranoid optjon Rooted devices

slide-31
SLIDE 31

HOW TO BREAK THE SYSTEM ?

sharedUserId

  • A way to share permissions between packages
  • Permissions state is propagated to all packages upon changes

Other applicatjons

slide-32
SLIDE 32

Thanks for your atuentjon !

PENEL Alizée apenel@genymobile.com www.genymobile.com

slide-33
SLIDE 33

QUESTIONS ?