MOBILE

Mobile Application Security - BlackBerry Security - Permissions and User Controls (part 1) - RIM Controlled APIs

2/9/2011 9:08:24 AM
Permissions are determined per-application and assigned based on the application’s signature or a policy specified by the user. Most APIs are not considered sensitive and can be accessed by unsigned applications. The sensitive API set includes APIs for accessing personal information manager (PIM) data, phone features, operating system configuration, and the network. Applications that use these APIs may have to be signed, depending on whether the sensitive API is an MIDP or CLDC API, or a RIM proprietary API. Sensitive APIs that are proprietary to RIM and not part of MIDP2 are known as RIM Controlled APIs.

Remember when testing on simulator that unless security is explicitly enabled, none of the security behavior discussed in this section will be enforced. Make sure to turn on simulator security when exploring how the OS and permission systems behave.

RIM Controlled APIs

RIM Controlled APIs are divided into different API sets, each with a unique signing authority. The three most common signing authorities are abbreviated as follows:

  • RCR (RIM Cryptographic Runtime) Includes the majority of RIM’s cryptographic APIs. Public key cryptography APIs require a different signing key from Certicom.

  • RRT (RIM Runtime API) Provides access to sensitive platform functionality, such as the Application Permission Manager.

  • RBB (RIM BlackBerry Apps API) Provides control of built-in BlackBerry applications (for example, the BlackBerry browser).

Applications that use more than one controlled API set are signed with multiple signatures. For example, an application that uses the BlackBerry browser and the Application Permission Manager will have both RRT and RBB signatures. The signing infrastructure is extensible, and third-party developers can add their own signing authorities to control access to their APIs by using the BlackBerry Signing Authority Tool. Regardless of the signing key required, the security behavior is the same.The term RIM Controlled API is used for any API that requires a signature from a signing authority. When developers purchase signing keys from RIM, they receive authorization for signing from the RCR, RRT, and RBB authorities.

In addition to signatures required for accessing RIM Controlled APIs, two BlackBerry OS features also require signatures: applications that automatically launch on BlackBerry startup and BlackBerry system modules. If these features were allowed, unsafe code could run as startup and either monitor the user’s actions or commit an effective spoofing attack to steal important information.

Before an application is allowed to run, it must pass a Java verification stage to ensure that the application uses well-formed Java instructions and does not use dangerous Java features such as Java native invocation or reflection. Disallowing these features ensures that the application does not load dangerous code or bypass class access restrictions to call or create prohibited methods. There are three stages to this validation:

  • Compile Time Verification All code instructions and class references are verified using standard Java verification. This step ensures that well-formed Java instructions are used throughout.

  • Link Time Verification When the COD is loaded onto the BlackBerry, it is linked with the platform APIs. If the COD file links against any RIM Controlled APIs and does not have an appropriate signature, then the linker refuses to link the binary. The application will still be loaded onto the device, but will fail immediately upon startup (see Figure 1).

    Figure 1. Error displayed when loading an unsigned application that uses RIM Controlled APIs.

  • Run Time Verification Checks are performed whenever the application invokes a RIM Controlled API. These checks prevent malicious code, or legitimate code that has been exploited, from accessing RIM Controlled APIs or bypassing the application permissions system.

The combination of verified Java code, code integrity, and per-API access control is powerful for security. These mechanisms enable sandboxed applications and enable users to control how those applications use data on the device.

Before getting too excited about the BlackBerry’s signature-based security architecture, remember that code-signing certificates are cheap and do not require an extensive authentication process. Requiring signatures increases accountability and enables code integrity, but a signature does not guarantee the signed code is well written or nonmalicious. The only foolproof mechanism to avoid malware is to avoid installing third-party applications altogether.

Signatures are required for at least one class contained within each of the following RIM packages:

net.rim.blackberry.api.blackberrymessengernet.rim.device.api.bluetooth
net.rim.blackberry.api.browsernet.rim.device.api.io
net.rim.blackberry.api.browser.fieldnet.rim.device.api.io.http
net.rim.blackberry.api.browser.pluginnet.rim.device.api.ldap
net.rim.blackberry.api.homescreennet.rim.device.api.smartcard
net.rim.blackberry.api.invokenet.rim.device.api.system
net.rim.blackberry.api.mailnet.rim.device.cldc.io.ssl
net.rim.blackberry.api.mail.eventnet.rim.device.api.notification
net.rim.blackberry.api.menuitemnet.rim.device.api.servicebook
net.rim.blackberry.api.messagelistnet.rim.device.api.synchronization
net.rim.blackberry.api.optionsnet.rim.device.api.applicationcontrol
net.rim.blackberry.api.optionsnet.rim.device.api.lowmemory
net.rim.blackberry.api.pdapnet.rim.device.api.memorycleaner
net.rim.blackberry.api.phonenet.rim.device.api.file
net.rim.blackberry.api.phone.phonelogsnet.rim.blackberry.api.maps
net.rim.blackberry.api.spellcheck.SpellCheck (Class)net.rim.device.api.gps

Signing BlackBerry Applications

BlackBerry signatures use public key cryptography and a RIM-managed online signing service. To sign code, developers must have a public/private keypair and have registered that keypair with RIM. The following step-by-step guide describes how to get RIM signing keys and what happens along the way:

  1. Go to RIM’s code signing website (www.blackberry.com/go/codesigning).

  2. Hidden on the web page is a small link to an order form for requesting keys (www.blackberry.com/SignedKeys/).

  3. Fill out the form and provide payment information. As part of this registration process, a PIN will be required. This PIN is essentially a password for the user account and will be used by the signing authority to associate cryptographic keys with the account.

  4. After the form is submitted, a few days will pass while RIM processes your order. Assuming that everything is acceptable, the signing infrastructure will send three e-mails—one for each of the RCR, RRT, and RBB signing authorities.

  5. Attached are CSI files. These are text files that include the developer ID, the nickname of the signing authority (for example, RCR), and the URL for the signing web service. If the JDE is installed, CSI files are automatically associated with RIM’s Signature Tool. Double-clicking on the CSI file will launch the Signature Tool and start the key-registration process. These CSI files don’t really have any key material in them and are used to tell the Signature Tool about the signing authorities that exist.

  6. Once the Signature Tool opens the CSI file, it checks to see if the developer already has a public/private keypair. If not, the developer will be asked whether they want to generate one. This is pretty fun, because RIM makes you move the mouse and pound the keyboard to collect entropy. At the end of the generation process, a password is required. This is used to encrypt the keypair and protect it on disk.

  7. Once the public/private keypair is generated, the signature tool asks for your RIM signing authority PIN.

  8. The PIN and the public key are used to create a message that is then sent via HTTP POST to RIM’s signing authority servers. This message contains the public key, the developer’s signing authority ID, and cryptographic data to ensure the message’s integrity. The curious can watch these messages in Wireshark. The server records the relationship between the user ID and the public key. This way, RIM does not need to generate the private key directly. The same public/private keypair can be registered with all three signing authorities.

  9. Steps 5–8 must be repeated for each CSI file until all signing authorities are registered.

Getting signing keys is the first step in creating RIM signed applications. To actually sign code, use the RIM Signature Tool, which is bundled with the JDE and Eclipse plug-in. To run the tool from Eclipse, build the application and then select Request Signatures from the BlackBerry menu. This will launch the Signature Tool with the currently selected project already loaded, as shown next. If you’re not using the Eclipse plug-in, the Signature Tool can be launched as SignatureTool.jar from the JDE’s bin directory. The COD file will have to be loaded manually. To do so, click the Add button and browse to the COD file.


An individual application may not necessitate code signatures from every signing authority. For example, if the application does not use cryptography, then a RIM Cryptographic Runtime (RCR) signature is not required. The Signature Tool inspects the application and determines which keys are required. To request signatures from the required signing authorities, click the Request button and enter the private key’s password. Behind the scenes, the private key is used to create a digital signature of the application, which is then sent via HTTP POST to the appropriate signing authorities. If they accept the signature, they will sign the response and return a signature of the signature. The Signature Tool adds this to the COD file.

By being online, RIM is able to monitor the signing process and control the number of times an individual signing key may be used. RIM can also respond to compromise and refuse signatures if a key is known to be compromised. Every time a signature is requested, an e-mail will be sent to the signature key’s owner summarizing what was signed and who signed it. This e-mail also contains the number of signatures remaining. Standard developer keys may be used a little over two billion times.

Programmatically Managing Permissions Using the Application Permissions Manager

If an administrator or user has denied an application permission to access certain functionality, the application can read or request permissions using the net.rim.device.api.applicationcontrol.ApplicationPermissionsManager class. This class is a RIM Controlled API and is therefore restricted to signed applications.

The following example demonstrates requesting access to use Bluetooth and the Phone APIs:

ApplicationPermissions ap = ApplicationPermissionsManager.getInstance()
.getApplicationPermissions();
ap.addPermission(ApplicationPermissions.PERMISSION_BLUETOOTH);
ap.addPermission(ApplicationPermissions.PERMISSION_PHONE);
ApplicationPermissionsManager.getInstance().invokePermissionsRequest(ap);

For a more in-depth example, review the ApplicationPermissionsDemo project included with the JDE.

Other  
  •  Windows Phone 7 Development : Working with Controls and Themes - Introducing the Metro Design System
  •  Windows Phone 7 Development : WebBrowser Control - Saving Web Pages Locally
  •  Programming the Mobile Web : Geolocation and Maps - Detecting the Location (part 3)
  •  Programming the Mobile Web : Geolocation and Maps - Detecting the Location (part 2) - Google Gears
  •  Programming the Mobile Web : Geolocation and Maps - Detecting the Location (part 1) - W3C Geolocation API
  •  Programming the Mobile Web : Geolocation and Maps - Location Techniques
  •  iPhone Programming : Table-View-Based Applications - Connecting the Controller to the Model
  •  Programming the Mobile Web : Mobilizing WordPress and Other CMSs
  •  Programming the Mobile Web : Server-Side Browser Detection and Content Delivery - Content Adaptation
  •  Programming the Mobile Web : Multimedia and Streaming
  •  Mobile Application Security : BlackBerry Security - Development and Security Testing
  •  Mobile Application Security : BlackBerry Security - Introduction to Platform
  •  Windows Phone 7 Development : Using a WebBrowser Control to Display Dynamic Content
  •  Windows Phone 7 Development : Using a WebBrowser Control to Display Local HTML Content
  •  Windows Mobile Security - Networking
  •  Windows Mobile Security - Local Data Storage
  •  Windows Mobile Security - Permissions and User Controls
  •  Windows Phone 7 Development : Using a WebBrowser Control to Display Web Content
  •  Windows Phone 7 Development : Adding a WebBrowser Control
  •  Programming the Mobile Web : Content Delivery (part 3)
  •  
    Most View
    Microsoft Content Management Server Development : A Placeholder Control for Multiple Attachments (part 2) - Generating the Table of Attachments
    On The Origin Of PCs
    Silverlight : Binding Across Elements
    Android 4.0 For Your Samsung Galaxy SII
    MySQL for Python : Creating Users and Granting Access - Creating users in MySQL
    How To Add Attachments To Your Phone
    Top 10 TVs – November 2012
    Batch File Basics (Part 1)
    Kobo Mini : Does The World Need A Smaller E-Reader? (Part 1)
    Syncing And Streaming (Part 1)
    Top 10
    The Performance Review Of AMD Radeon HD 7790 And Nvidia GeForce GTX 650 Ti BOOST (Part 4)
    The Performance Review Of AMD Radeon HD 7790 And Nvidia GeForce GTX 650 Ti BOOST (Part 3)
    The Performance Review Of AMD Radeon HD 7790 And Nvidia GeForce GTX 650 Ti BOOST (Part 2)
    The Performance Review Of AMD Radeon HD 7790 And Nvidia GeForce GTX 650 Ti BOOST (Part 1)
    Turtle Beach Ear Force XP Seven Headset - A New Era Of Tournament-Level Gaming Audio (Part 3)
    Turtle Beach Ear Force XP Seven Headset - A New Era Of Tournament-Level Gaming Audio (Part 2)
    Turtle Beach Ear Force XP Seven Headset - A New Era Of Tournament-Level Gaming Audio (Part 1)
    The NZXT Kraken X40 Compact Liquid Cooler Review (Part 1)
    The NZXT Kraken X40 Compact Liquid Cooler Review (Part 3)
    The NZXT Kraken X40 Compact Liquid Cooler Review (Part 2)