prof. Carlo Bellettini
carlo.bellettini@unimi.it
Quanti hanno un telefonino Android?
È un target appetitoso
Usiamo il sandboxing della JVM ?
Linux ci fornisce:
La sicurezza viene forzata a livello di OS
Inizialmente una applicazione ad esempio non può:
Sono caratterizzati da:
Manifest.permission
Allows read/write access to the "properties" table in the checkin database, to change values that get uploaded.
Allows an application to access coarse (e.g., Cell-ID, WiFi) location
Allows an application to access fine (e.g., GPS) location
Allows an application to access extra location provider commands
Allows an application to create mock location providers for testing
Allows applications to access information about networks
Allows an application to use SurfaceFlinger's low level features
Allows applications to access information about Wi-Fi networks
Allows applications to call into AccountAuthenticators.
Allows an application to add voicemails into the system.
Allows an application to act as an AccountAuthenticator for the AccountManager
Allows an application to collect battery statistics
Allows an application to tell the AppWidget service which application can access AppWidget's data.
Must be required by device administration receiver, to ensure that only the system can interact with it.
Must be required by an InputMethodService, to ensure that only the system can bind to it.
Must be required by a RemoteViewsService, to ensure that only the system can bind to it.
Must be required by a TextService (e.g.
Must be required by an VpnService, to ensure that only the system can bind to it.
Must be required by a WallpaperService, to ensure that only the system can bind to it.
Allows applications to connect to paired bluetooth devices
Allows applications to discover and pair bluetooth devices
Required to be able to disable the device (very dangerous!).
Allows an application to broadcast a notification that an application package has been removed.
Allows an application to broadcast an SMS receipt notification
Allows an application to broadcast sticky intents.
Allows an application to broadcast a WAP PUSH receipt notification
Allows an application to initiate a phone call without going through the Dialer user interface for the user to confirm the call being placed.
Allows an application to call any phone number, including emergency numbers, without going through the Dialer user interface for the user to confirm the call being placed.
Required to be able to access the camera device.
Allows an application to change whether an application component (other than its own) is enabled or not.
Allows an application to modify the current configuration, such as locale.
Allows applications to change network connectivity state
Allows applications to enter Wi-Fi Multicast mode
Allows applications to change Wi-Fi connectivity state
Allows an application to clear the caches of all installed applications on the device.
Allows an application to clear user data
Allows enabling/disabling location update notifications from the radio.
Allows an application to delete cache files.
Allows an application to delete packages.
Allows low-level access to power management
Allows applications to RW to diagnostic resources.
Allows applications to disable the keyguard
Allows an application to retrieve state dump information from system services.
Allows an application to expand or collapse the status bar.
Run as a manufacturer test application, running as the root user.
Allows access to the flashlight
Allows an application to force a BACK operation on whatever is the top activity.
Allows access to the list of accounts in the Accounts Service
Allows an application to find out the space used by any package.
Allows an application to get information about the currently or recently running tasks: a thumbnail representation of the tasks, what activities are running in it, etc.
This permission can be used on content providers to allow the global search system to access their data.
Allows access to hardware peripherals.
Allows an application to inject user events (keys, touch, trackball) into the event stream and deliver them to ANY window.
Allows an application to install a location provider into the Location Manager
Allows an application to install packages.
Allows an application to open windows that are for use by parts of the system user interface.
Allows applications to open network sockets.
Allows an application to call killBackgroundProcesses(String).
Allows an application to manage the list of accounts in the AccountManager
Allows an application to manage (create, destroy, Z-order) application tokens in the window manager.
Allows an application to modify global audio settings
Allows modification of the telephony state - power on, mmi, etc.
Allows formatting file systems for removable storage.
Allows mounting and unmounting file systems for removable storage.
Allows applications to perform I/O operations over NFC
This constant is deprecated. This functionality will be removed in the future; please do not use. Allow an application to make its activities persistent.
Allows an application to monitor, modify, or abort outgoing calls.
Allows an application to read the user's calendar data.
Allows an application to read the user's contacts data.
Allows an application to take screen shots and more generally get access to the frame buffer data
Allows an application to read (but not write) the user's browsing history and bookmarks.
Allows an application to retrieve the current state of keys and switches.
Allows an application to read the low-level system log files.
Allows read only access to phone state.
Allows an application to read the user's personal profile data.
Allows an application to read SMS messages.
Allows an application to read from the user's social stream.
Allows applications to read the sync settings
Allows applications to read the sync stats
Required to be able to reboot the device.
Allows an application to receive the ACTION_BOOT_COMPLETED that is broadcast after the system finishes booting.
Allows an application to monitor incoming MMS messages, to record or perform processing on them.
Allows an application to monitor incoming SMS messages, to record or perform processing on them.
Allows an application to monitor incoming WAP push messages.
Allows an application to record audio
Allows an application to change the Z-order of tasks
This constant is deprecated. The restartPackage(String) API is no longer supported.
Allows an application to send SMS messages.
Allows an application to watch and control how activities are started globally in the system.
Allows an application to broadcast an Intent to set an alarm for the user.
Allows an application to control whether activities are immediately finished when put in the background.
Modify the global animation scaling factor.
Configure an application for debugging.
Allows low-level access to setting the orientation (actually rotation) of the screen.
Allows low-level access to setting the pointer speed.
This constant is deprecated. No longer useful, see addPackageToPreferred(String) for details.
Allows an application to set the maximum number of (not needed) application processes that can be running.
Allows applications to set the system time
Allows applications to set the system time zone
Allows applications to set the wallpaper
Allows applications to set the wallpaper hints
Allow an application to request that a signal be sent to all persistent processes
Allows an application to open, close, or disable the status bar and its icons.
Allows an application to allow access the subscribed feeds ContentProvider.
Allows an application to open windows using the type TYPE_SYSTEM_ALERT, shown on top of all other applications.
Allows an application to update device statistics.
Allows an application to request authtokens from the AccountManager
Allows an application to use SIP service
Allows access to the vibrator
Allows using PowerManager WakeLocks to keep processor from sleeping or screen from dimming
Allows applications to write the apn settings
Allows an application to write (but not read) the user's calendar data.
Allows an application to write (but not read) the user's contacts data.
Allows an application to write to external storage
Allows an application to modify the Google service map.
Allows an application to write (but not read) the user's browsing history and bookmarks.
Allows an application to write (but not read) the user's personal profile data.
Allows an application to read or write the secure system settings.
Allows an application to read or write the system settings.
Allows an application to write SMS messages.
Allows an application to write (but not read) the user's social stream data.
Allows applications to write the sync settings
All'interno del file Manifest.xml
dichiaro i permessi di cui ho bisogno
<uses-permission android:name="string" />
Dichiarazione permessi necessari
<activity android:name=".GetPasswordActivity"
android:permission="com.yourapp.GET_PASSWORD_FROM_USER" … >
</activity>
<service android:name=".UserAuthenticatorService"
android:permission="com.yourapp.AUTHENTICATE_USER" … >
</service>
<provider android:name=".EnterpriseDataProvider"
android:readPermission="com.yourapp.READ_ENTERPRISE_DATA"
android:writePermission="com.yourapp.WRITE_ENTERPRISE_DATA" … >
</provider>
Definizione nuovo permesso
<permission android:name="com.yourapp.PERMISSION"
android:protectionLevel="signature"
android:label="@string/permission_label"
android:description="@string/permission_desc">
</permission>
Vogliamo scrivere una applicazione che fa vibrare il telefono quando un conoscente è a me vicino. Abbiamo bisogno dei permessi:
<uses-permission android:name="android.permission.VIBRATE" />
Nel nostro programma useremo
mVibrator = (Vibrator)getSystemService(Context.VIBRATOR_SERVICE);
...
mVibrator.vibrate(new long[]{ 0, 200, 0 }, 0);
Nel codice del servizio
public void vibrate(long milliseconds, IBinder token) {
if (mContext.checkCallingOrSelfPermission(
android.Manifest.permission.VIBRATE)
!= PackageManager.PERMISSION_GRANTED)
throw new SecurityException( "Requires VIBRATE permission");
}
packages.xml
(in /data/system/
)
<package name="com.readability" codePath="/data/app/com.readability-1.apk" nativeLibraryPath="/data/data/com.readability/lib" flags="0" ft="136de965d50">
<sigs count="1">
<cert index="6" key="308201bd30820126a00302010202044ea974a6300d06092a864886f70d01010505003023310b300906035504061302555331143012060355040a130b5265616461626"/>
</sigs>
<perms>
<item name="android.permission.INTERNET" />
<item name="android.permission.ACCESS_NETWORK_STATE" />
<item name="android.permission.WRITE_EXTERNAL_STORAGE" />
</perms>
</package>
Guardiamo il file /etc/permissions/platform.xml
<permission name="android.permission.INTERNET" >
<group gid="inet" />
</permission>
Sotto Android non ci sono file /etc/passwd
o /etc/groups
e quindi gli ID sono hardcoded src
#define AID_INET 3003 /* can create AF_INET and AF_INET6 sockets */
static const struct android_id_info android_ids[] = {
{ "root", AID_ROOT, },
...
{ "inet", AID_INET, },
...
};
In Android 4.2 è stato aggiunto supporto per multiutenza.
Ad ogni utente viene assegnato un identificativo: 0,10,11,12
I processi assumono dei PID ottenuti per concatenazione:
Le applicazioni devono essere firmate per potere essere installate
A cosa servono?
Non è previsto che una applicazione (non di sistema) abbia diritti di root
Esistono diversi exploit
udev
(init/ueventd)adbd
vold
Un componente riesce (indirettamente) a chiamare un componente protetto da un permesso che non ha
Non è vero che per forza ogni applicazione ha UID univoco
E' possibile condividerlo per applicazioni firmate con la stessa chiave
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
...
android:sharedUserId="string"
android:sharedUserLabel="string resource"
... >
...
</manifest>
Il developer CB sviluppa due applicazioni:
full internet
Singolarmente le due applicazioni mi sembrano ragionevoli, ma combinate insieme?
Social Engineering
Esempi (Symantec):
rootcager, Pjapps, Bgserv