Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Protecting twitter keys on Android

When adding twitter authentication to my android app, going to Twitter dev, I was flabbergasted at finding that I have to initialize Twitter's Fabric like this:

import io.fabric.sdk.android.Fabric;
import com.twitter.sdk.android.Twitter;
import com.twitter.sdk.android.core.TwitterAuthConfig;
...

@Override
public void onCreate() {
    super.onCreate();

    TwitterAuthConfig authConfig = 
                new TwitterAuthConfig("consumerKey",
                                     "consumerSecret");
    Fabric.with(this, new Twitter(authConfig));
}

They are officialy recommending that I put both API Key and API Secret in my app as plaintext. Even in this official sample, the keys are stored in BuildConfig.

I am using Proguard but even then, I cannot guarantee that a determined hacker wouldn't be able to exploit my API Secret. Do established apps like Quora also expose these keys?

Can somebody post an example for overcoming this vulnerability, or give a convincing argument as to why Twitter is doing this?

In contrast, Google and Facebook only required me to add an AppID, and I had to hash my signing certificates and link the hashes to respective apps. This is levels of magnitude more secure than above.

like image 550
xyz Avatar asked Jun 25 '15 07:06

xyz


People also ask

How do I use Google Authenticator for Twitter?

You can use any Time-based One Time Password (TOTP) authentication app like Google Authenticator, Authy, Duo Mobile, 1Password, etc.) After you scan the QR code, tap Next. Enter the code generated by your authentication app, then tap Verify. You'll see a confirmation screen.

Where do I find my Twitter backup code?

Twitter sends you a code via SMS. Enter it in the space provided on the next screen. At this point, you will be presented with a backup code. Print it out and keep it safe.


1 Answers

Proguard will not obfuscate string literals. Instead you could store the secret as an encrypted string (maybe using AES) and decrypt when required. Alternatively, commercial programs such as Stringer or Dexguard provide string obfuscation.

like image 152
Matt Brown Avatar answered Sep 30 '22 14:09

Matt Brown