Wiki

Version 1 (hans, 06/24/2014 08:49 pm)

1 1 hans
h1. Trusted @Intent@ Interaction
2 1 hans
3 1 hans
the approaches to implementing the trust checking
4 1 hans
* pinning
5 1 hans
* TOFU/POP
6 1 hans
7 1 hans
tokens to check
8 1 hans
* the package ID of the app
9 1 hans
* the signing key of the app (see "android:protectionLevel":https://developer.android.com/guide/topics/manifest/permission-element.html)
10 1 hans
* a Chooser with a pinned list of package names (like PixelKnot)
11 1 hans
* the hash of the APK
12 1 hans
** needed to verify that the APK has not been modfied "ref":http://arstechnica.com/security/2013/07/google-patches-critical-android-threat-as-working-exploit-is-unleashed/
13 1 hans
** test exploit https://gist.github.com/poliva/36b0795ab79ad6f14fd8
14 1 hans
** http://www.saurik.com/id/17
15 1 hans
16 1 hans
17 1 hans
h3. When to Verify?
18 1 hans
19 1 hans
There are two good opportunities for verifying senders and receivers: at install and on each @Intent@/@startActivity()@ interaction.  Running the verify on install means that it is rarely run but means more complicated code.  Running the verify on each @Intent@ interaction means the verification is run every time, but the code should be much simpler.  Since the point of this system is security, simpler code is more important than execution efficiency.
20 1 hans
21 1 hans
22 1 hans
h3. Chained Validation Methods
23 1 hans
24 1 hans
Validation is based a token.  If the token does not exist in a given step, then the check goes on to the next step.  If the token does have an entry but it does not match, then validation stops and an error is thrown.
25 1 hans
26 1 hans
# check pins
27 1 hans
# check TOFU/POP
28 1 hans
# prompt user
29 1 hans
30 1 hans
h2. Sending @Intents@ to a trusted recipient
31 1 hans
32 1 hans
If data needs to be sent to another app and the receiving app must be trusted.  For example, if your app uses an OpenPGP providing app, then the sender wants to be sure that the receiver is the right app.
33 1 hans
34 1 hans
* @isIntentReceiverTrusted()@
35 1 hans
* @startTrustedActivity()@
36 1 hans
* @startTrustedActivityForResult()@
37 1 hans
* @bindTrustedService@
38 1 hans
* @onActivityResult()@ would then also handle validation problems and prompts
39 1 hans
* maybe @onTrustedActivityResult()@?
40 1 hans
41 1 hans
h2. Receiving @Intents@ from a trusted sender
42 1 hans
43 1 hans
Provide a method for a receiver to verify that the sender is the right one.  For example, with ChatSecure it will become possible for other apps to send data via OTRDATA.  Once the user has clicked "Accept Always" then ChatSecure should remember that and verify that each incoming @Intent@ is allowed to be processed.  Another example is ChatSecure allows apps to send an @Intent@ to create an account.
44 1 hans
45 1 hans
* @isIntentSenderTrusted(Intent intent)@
46 1 hans
* Both service intents and activity intents should be handled
47 1 hans
** Look into @Binder.getCallingPid / getCallingUid@
48 1 hans
** If all else fails, might need an auth token exchange
49 1 hans
50 1 hans
h2. TOFU/POP callbacks
51 1 hans
52 1 hans
For using TOFU/POP validation rather than pinning, there needs to be some callbacks to allow the app to display the relevant UI.
53 1 hans
54 1 hans
* @onFirstUse()@ - the first time a @packageName@ is seen
55 1 hans
* @onValidateFailed()@ - if there is a mismatch between the @packageName@ and the signing certificate
56 1 hans
57 1 hans
58 1 hans
h2. validation methods on @PACKAGE_ADDED@/@PACKAGE_REPLACED@/@PACKAGE_CHANGED@
59 1 hans
60 1 hans
* calculating the APK hash is heavy because it has to read the whole APK
61 1 hans
* this can be done on when receiving the @Broadcast@s from the system
62 1 hans
* then a framework handles tracking this
63 1 hans
* only verifies signing key or hash when the app is installed/upgraded
64 1 hans
* lightweight version of @getTrustedIntent()@ and @startTrustedActivity()@
65 1 hans
* trusts Android system entirely
66 1 hans
* app must include changes to @AndroidManifest.xml@ to register @BroadcastReceiver@
67 1 hans
68 1 hans
69 1 hans
h2. sources of relevant code
70 1 hans
71 1 hans
* "PackageManager.addPermission":https://developer.android.com/reference/android/content/pm/PackageManager.html#addPermission(android.content.pm.PermissionInfo)
72 1 hans
* "Intent.ACTION_PACKAGE_ADDED":https://developer.android.com/reference/android/content/Intent.html#ACTION_PACKAGE_ADDED
73 1 hans
* https://github.com/moxie0/AndroidPinning
74 1 hans
* https://github.com/ge0rg/MemorizingTrustManager
75 1 hans
* https://github.com/guardianproject/ICTD/blob/master/src/info/guardianproject/ictd/ICTD.java#L62 (InformaCam)
76 1 hans
* martus-android's version of OrbotHelper.java
77 1 hans
* http://www.unwesen.de/2011/04/10/android-intent-sender-verification/
78 1 hans
* https://github.com/commonsguy/cw-omnibus/tree/master/MiscSecurity
79 1 hans
** The SigDump project lists all packages -- tapping on one decodes the "signature" and dumps the signature as a binary
80 1 hans
** The SigCheck project checks another app's "signature", comparing it to a known good value held as a raw resource (e.g., one dumped via SigDump).
81 1 hans
82 1 hans
h2. Use Cases
83 1 hans
84 1 hans
h3. Trusted Processing App
85 1 hans
86 1 hans
Martus needs to have strongly integrated, trusted camera app.  In this case, the Martus app will always initiate the camera @Activity@ by verifying the recipient before sending the explicit @Intent@.  The receiver is then expected to reply with the media directly to Martus.
87 1 hans
88 1 hans
An app wants to include a whitelist of trusted OpenPGP provider engires. Gnu Privacy Guard and OpenKeychain are both trusted, so the app includes pins for the signing certificates for both Gnu Privacy Guard and OpenKeychain.  This app will then only send data to be encrypted or decrypted to APKs that have been signed by those pinned signing certificates.
89 1 hans
90 1 hans
h3. Per-app permissions
91 1 hans
92 1 hans
InformaCam aims to be engine that provides verifiable media to any app.  It has app-specific media stores and keys.  When an app calls InformaCam the first time, InformaCam will register the sender, assign that sender a mediastore, and only send info from that mediastore to the app that is registered to it.  When sending media from a given mediastore, InformaCam will verify that it is sending to the trusted recipient for that mediastore.
93 1 hans
94 1 hans
h2. related idea for upgrading an APK's signing key
95 1 hans
96 1 hans
# create an APK with new package ID and signed by new key
97 1 hans
# both old and new APKs are installed at the same time
98 1 hans
# old one grants the new one perms to read all data based on hash pin