[Guide] How to secure Firebase Real Time Database from hacker!

Let me tell you my database structure, then plz suggest me the rules:

Sample database:

Names(Bucket 1):
+1234567890(Tag1): XYZ
+1234567899(Tag2): ABC

Now, I want that read should be allowed to everyone but writing should be user specific. Like a user with mobile number +1234567890 should be allowed to change his tag(name) value only.

Plz help me how to achieve this?

You can’t make a rule with number tag, you need to use user id.

If I somehow don’t provide API key and url of my firebase database in the apk (source code) and it only get them while the apk runs…Is my database secure in this case?

2 Likes

50% secure.

1 Like


No rules will works without get user token​:expressionless:

Everything went above head

Permission Denied error??. how to solve this error?

@Avijit @Horizon can’t get user token

Currently not working “got id token”

But my Users do not log in through Firebase Authentication. Only The Data should be fetched if the URL contains a specific Code.

It can be still hacked, I don’t think rules can protect a complex user database from getting hacked. The changes that you do in your FDB from app can be done from outside sources too wether you use (rules + AppCheck token) or not.

1 Like

correct, there needs to be a strong backend, focusing on rate limiting, ddos attack, sql injections and much more.

strong encryption + authentication is required at backend, so learn coding :slight_smile: