Unit 1: How phones are built to defend · Lesson 1 of 5 · 18 min

The app sandbox

Prove from an Android shell that every app is its own user and cannot read its neighbours.

mission

You are
You are the IT analyst at Kestrel Field Services, 30 phones, one IT lead.
Situation
Leo Marsh's Galaxy A53 is connected over USB debugging for a review. Before hunting for problems you want to see the walls that should contain them.
Goal
Show that apps are separated from each other and from you.
Hand in
The user IDs of two apps and what happens when you try to cross a wall.

Apps as sealed apartments

01

See who you are

adb gives you the shell user, not root. It can inspect a lot, but app data is off limits.

a53-leo
id
uid=2000(shell) gid=2000(shell) groups=2000(shell),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) context=u:r:shell:s0

you should see uid=2000(shell). Not 0, not root.

02

Try to read app data

a53-leo
ls /data/data
ls: /data/data: Permission denied
ls /data/data/com.kestrel.jobs
ls: /data/data/com.kestrel.jobs: Permission denied

you should see Permission denied, twice. Each app's private folder belongs to that app alone.

03

Find each app's own user

Android gives every app its own Linux user ID when it is installed. The kernel then keeps them apart like any two users on a server.

a53-leo
dumpsys package com.kestrel.jobs | grep userId
    userId=10213
dumpsys package com.whatsapp | grep userId
    userId=10201

you should see Different numbers, so different owners of different files.

defender tip iOS does the same job with a sandbox profile per app instead of a user per app. The result for you is the same: apps ask the OS, they do not reach across.

04

List what is installed

a53-leo
pm list packages -3
package:com.kestrel.jobs
package:com.microsoft.teams
package:com.microsoft.office.outlook
package:com.whatsapp
package:com.pixelglow.camera
package:com.vidsnap.saver
package:com.google.android.apps.authenticator2
package:com.tideguide.tides

you should see Eight apps you or IT installed. One name you will meet again: com.vidsnap.saver.

What a sandbox does and does not stop

Stops
App A reading App B's files
App A reading your messages database
A game opening the camera silently

Walls between apps.

Does not stop
An app you granted SMS access
An app you made an accessibility helper
A bug in the OS itself

Permissions you hand out and flaws in the walls.

What a defender takes away

  1. 1Every Android app runs as its own user, and every iOS app in its own sandbox.
  2. 2Harmful apps rarely break walls. They ask for permissions instead.
  3. 3The OS itself is the wall, which is why OS updates matter most.

Questions

0 of 3 solved

Answer each one from what you find on your lab machine.

  1. Show hint

    dumpsys package com.kestrel.jobs | grep userId

  2. Show hint

    Same command, different package.

  3. Show hint

    ls /data/data