Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is google-services.json safe from hackers?

If a hacker decompiled my APK would he be able to see my API keys from this file? I am not worried about my source code repository. I am just worried about a hacker being able to see this API key from my APK somehow. I'm trying to encrypt this file and decrypt it at runtime but having some issues

like image 692
stepheaw Avatar asked Aug 04 '17 13:08

stepheaw


People also ask

Is it safe to commit Google-services json?

Willie Chalmers III points to "Is google-services. json safe from hackers?", and adds: Yes, that API key isn't a server API key which should never be public, so it's fine if your google-services. json is visible by others.

Should I hide Google-services json?

The general answer is yes, the google-services. json is safe to check in to your repo and is something that should be shared among engineers on your team. The JSON file does not contain any super-sensitive information (like a server API key).

What is Google-services json used for?

The google-services. json file created in this doc is used within your app to connect to firebase and facilitate Android Push Notifications and is normally labelled google-services.


2 Answers

The way that the Google plugin is set up, it will be really hard for you to hide the content of the google-services.json file. The only viable way would be to re-implement yourself what the plugin already does for you, which I wouldn't recommend. When using the plugin the way Google intends you to, it will unfortunately be easy for anyone unzipping your APK to get hold of your Firebase/Google API Key.

However, you can prevent any abusive use of that API key by configuring who can use it. For an Android app, you can specify that your API Key can be used only by an Android application that has been signed by a given keystore and using a given package name.

To configure those restrictions, follow the documentation here: https://cloud.google.com/docs/authentication/api-keys#api_key_restrictions

On top of restricting the API Key, if you're using Firebase RTD/Firestore, you should also make sure that you configure security rules on the data store. Depending on your use-case, you can prevent anonymous user to read or write in sections of your database.

If you want more details, here is a good article I found on how to secure your API keys in an Android application: https://proandroiddev.com/developing-secure-android-apps-8edad978d8ba

like image 134
Julien Arzul Avatar answered Oct 16 '22 17:10

Julien Arzul


According to Firebase documentation here:

When you connect an app to your Firebase project, the Firebase console provides a Firebase configuration file (Android/iOS) or a configuration object (web) that you add directly into your local project.

  • For iOS, you add a GoogleService-Info.plist configuration file

  • For Android, you add a google-services.json configuration file

A Firebase config file or config object associates your app with your Firebase project and its resources (databases, storage buckets, etc.).

And then it identifies the content as public:

The content is considered public, including your platform-specific ID (entered in the Firebase console setup workflow) and values that are specific to your Firebase project, like your API Key, Realtime Database URL, and Storage bucket name.

Remember that, if you use Realtime Database, Cloud Firestore, or Cloud Storage, you still need to follow the security guidelines described by Firebase.

Also note that, although they are public for your application, these files should not be made available on public repositories of open source projects.

like image 8
fhsilva Avatar answered Oct 16 '22 15:10

fhsilva