I need help determining if my Firebase Cloud Firestore setup is secure or vulnerable to hacks.
In the database I have a single collection called userids which contains many documents. Each document contains data pertaining to the user whose userid is the name of the document. An example of this is:
userids (collection)
123456 (document)
field1: "..."
field2: "..."
field3: "..."
777777 (document)
field1: "..."
field2: "..."
field3: "..."
999999 (document)
field1: "..."
field2: "..."
field3: "..."
The functionality I need to have is then as follows:
• Given a userid such as userid=123456 a client or server must be able to read and write data only to the document with name equal to 123456 (the client/server cannot read or write data to the documents with names 777777 or 999999).
• Under no circumstance can anyone access a list of Documents which exist in the database, or the names of any of these Documents.
The security rules I have to enforce this behaviour is currently:
rules_version = '2';
service cloud.firestore {
match /databases/{database}/documents {
match /{document=**} {
allow read, write;
}
}
}
Now, let's say that all of the userids in the database are actually SHA256 hash values which uniquely represent each user. Assuming that this SHA256 hash was known only by the user, would this setup be secure since to read/write from a document you would need the to know the users hash? Is there any way that someone could find out the names of all of Documents in the database?