Android Security Measures

Android Security

Jitendra Purohit
Pen | Bold Kiln Press
4 min readMay 30, 2018

--

If you’re creating an app or have an app in the market, chances are, you’ve often stopped to consider how to secure your app, your data, and your customer’s data.

A mobile app needs a good bit of plumbing to make it work: there’s software code , business logic on the back-end network and client’s side, databases, APIs funneling data between the two, device and its operating system, and user. Each plays an important role in the fabric of an app’s security. For companies with mobile apps in a crowded, competitive market, having robust security could make a huge difference. Here are a few tips for you to take into consideration while working on mobile app security:

  1. Signature-Based Permission
    Why: It checks that app accessing data is signed with an original signing key.
    Implementation:

2. Use SSL Traffic
Why: Used to establish an encrypted link between server and client.
Implementation: If your app communicates with a web server that has a certificate issued by a well-known, trusted CA, you can use this HTTPS request-

3. Add Network Security Configuration
Why: Used to establish a secure connection between server and client.
Implementation:

For Android N and above

a. Declare the configuration in your app’s manifest.

b. Add an XML resource file, located at res/xml/network_security_config.xml.

For Android N and above,Below Android N

To get public keys with a domain name, the code below prints out the public keys in the chain as an SHA-256 hash using base 64 encoding.

Now run this command to get your key.

c. Using OKHTTP:

Using Retrofit, as Retrofit built on top of OkHttp, configuring it for pinning is as simple as setting up an OkHttpClient as shown above and supplying that to your Retrofit.Builder.

4. Use Encryption Algorithm like AES to Save Credentials
Why: Enhances the security of a message or file. To encrypt a message, you need the right key, and you need the right key to decrypt it as well.
Implementation:

a. Generate a signed key.

b. Encrypt a message, and get an encrypted byte array.

c. Decrypt byte array and get original message back.

5. Use SQL db Encryption
Why: Enhances security of SQLite data.
Implementation:
a. Add dependency in gradle file.

b. Call InitializeSQLCipher() from onCreate.

6. Protect Access to App’s Content Provider
Why: Prevent other apps from accessing your app’s data.
Implementation:

7. Obfuscation
Why: Obfuscating your app makes reverse engineering of the app very difficult.
Implementation:

8. Use Dexguard(a more powerful proguard tool)
Why: DexGuard provides advanced protection for Android applications.

9. Prevent Installation in Rooted Devices
Why: Rooted user can access the system directories of any app. They can be a serious security problem.
Implementation: If isDeviceRooted() returns true. Prevent the user from using the app.

Mobile is where users are, and that is where hackers are lurking to try and steal sensitive information and compromise an app’s security. With a solid strategy for app security and a top-notch mobile developer on hand to help you respond quickly to threats and bugs, your app will be a lot more safe and secure for users. And will also ensure their loyalty (and your assets) in the future.

--

--