Secure android app with firebase authentication? - android

I am in the process of developing an android application which I intended to publish to the PlayStore soon. I was doing some research and apparently a lot of android apps can get hacked due to the nature of PlayStore with downloading APKs and decompiling to view source codes. I will be using firebase authentication which will include a google-services.json . Is there a way to secure this file or is this file harmless? Google/Firebase says its fine to just add to app folder, but i'm not sure? AND is there anyway of securing firebase auth - i am not using any database firebase facilities as i am using my backend , so I do not need to write any security keys for firebase database??

Related

How do I hide the OneSignal key in an application I developed with Dart Flutter?

I am developing an app with Dart Flutter and I will publish this app in stores. So thousands of people will use this app.
I set up a notification system with OneSignal for this application.But if this app's APK file somehow gets access and is decrypted, the OneSignal key is also found.
Finding the key can have dire consequences.
What measures can I take for this? How can I hide the key?
Generally, you should not use any sensitive data in your application. Most of the keys provided to Flutter are Client keys, which means it's less destructive than server aka (secrets).
As I have checked OneSignal, they provide only Client_ID to Flutter SDK which is ok to keep, and the REST_KEY is supposed to be used in the backend and must be securely protected.
You may have two ways to protect your sensitive data:
Use services such as Firebase Remote Config and provide the key. This is technically a safe way to provide keys.
Use a backend API you and your team build and proxy all requests from your Flutter application via that. A Function could be a serverless function only to proxy your request protected for your application, or you can do it in the backend of your choice.
You can read more here too.

Firebase API key restrictions issue

I am using Firebase Authentication and Firebase dynamic links in my android project. I have put restrictions in my API key here
https://console.cloud.google.com/apis/credentials/
and allowed only android app with the package name and signature i specified. But there are still people able to create accounts using my API key outside my application and using script. I don't know how is this possible. As per firebase docs, it should be restricted to only my app. Is there anything i am missing to prevent people creating accounts through script?
Note: I am just using Firebase authentication, No firestore or Realtime database.

should I connect to firebase on the front-end or the back-end?

Im currently building an app, back-end and front-end and I use Firebase for saving pictures that the users can upload and download, up till now I've been uploading them from the front-end and if the upload is successful then I send the image link with the rest of the data to the back-end, but as Im saving firebase credentials (in order to connect) in the app, now Im questioning if it would be better/safer doing it all in the back-end, sending all the information (image included) and the let back-end upload the image to firebase. I don't how how secured are those credentials being of the app
I usually handle things in the front-end if the Firebase SDK has what I need. The only common reasons not to do this, is when there is a requirement to do them in the back-end. This is only common for operations that: require a lot of memory/CPU/bandwidth, require access to secret information (e.g. an API key for a payment gateway), or where the code itself is secret (e.g. detecting cheats in a game, or malicious messages in a chat app).
In your case for example, uploading directly from the front-end to Cloud Storage is a great reason to use the Firebase SDK. Doing so means that Firebase takes care of the encoding, of retrying, of security, and many other things. If you'd want to introduce your own server in the middle, you'll have to write the (client and server) code to handle all of that yourself.
Note that the keys that Firebase tells you to add to your app through the google-services.json are not credentials, but merely configuration data that the app needs to find your Firebase project on the servers. For more on this, see my answer here: Is it safe to expose Firebase apiKey to the public?
But that said, with the configuration data anybody can call Firebase API methods on your project. So you need to secure access in some way, to prevent other users from coming up with their own code that uses your project.
The common way to do this is by using Firebase Authentication on the client to sign the users of your app in. You'd then use the Firebase security rules to limit who can read/write what files in Cloud Storage.

User has access to Firebase Realtime Database without using my Android app

I am working on an android application connected with firebase.
As we know that the api key and database name as being stored in strings.xml in apl file so they can be easily extracted.
As I told one of my friend his email-id and password for testing purpose.
The issue is that he was able to see all the data in the firebase realtime database by using the restAPI.
I had used sha1 but since the firebase is responding to the other links.
Is there any other way in which the firebase will respond to the request generated by the android app and not any web or ios.
Credentials for accessing Firebase are not platform specific. Once you know the credentials of a user, you can access the platform as that user.
For this reason you should never share your credentials with someone else, but instead give them access to your project with their credentials.
The simplest way to fix your problem now is to change the password of your account. After doing that, the other user will lose access within an hour.
The configuration data that is added to your Android app through google-services.json is just configuration data. It is in no way meant as authentication for your app. For more on this see Is it safe to expose Firebase apiKey to the public? and How to prevent other access to my firebase.

Firebase Storage really needs a user to upload files?

Recently I started to learn and work with Firebase and I have a doubt with their Storage Service.
I'm just using Firebase Storage to upload files from my Android App. I'm not using Firebase Auth Service, because I use my own backend for authenticate users.
Firebase Storage is working and the files are being upload with success, but I'm receving a strange warning exception (that's not avoiding the upload to be success):
E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.FirebaseApiNotAvailableException: firebase-auth is not linked, please fall back to unauthenticated mode.
I don't want to create users with Firebase, because I handle this in my backend...
Why I'm faceing this warning? If I need to authenticate users just to stop this warning, can I create a "Application Level User"? I don't need to authenticate separeted users for this because all files are shared among users...
The Firebase SDK for Cloud Storage works with the Firebase Authentication SDK to help the Cloud Storage backend know who the active user is. This is how Cloud Storage security rules work. Without the linkage between these two products, you wouldn't be able to write security rules that allow or reject access to certain users.
If you're not using Firebase Authentication, then you can just ignore that message. But this also means that you have to enable full read and write access to everyone at the path in your storage bucket that your users upload to. In other words, anyone in the world can freely modify your storage bucket, and that could become a problem for your app.
If this isn't what you want, consider using Firebase Auth to do custom authentication with your backend so you can be sure that only authenticated (and possibly authorized) users can modify your storage bucket.

Categories

Resources