Challenge - 5 Problems
Storage Security Master
Get all challenges correct to earn this badge!
Test your skills under time pressure!
❓ security
intermediate2:00remaining
Identify the effect of this Firebase Storage rule
Given the following Firebase Storage security rule, what is the effect on file uploads?
service firebase.storage {
match /b/{bucket}/o {
match /user_uploads/{userId}/{allPaths=**} {
allow write: if request.auth != null && request.auth.uid == userId;
allow read: if false;
}
}
}Attempts:
2 left
💡 Hint
Look at the conditions for write and read separately.
✗ Incorrect
The rule allows write only if the user is authenticated and their UID matches the folder name, so users can upload only to their own folder. The read is explicitly denied for everyone.
❓ service_behavior
intermediate2:00remaining
What happens when a user tries to read a file with this rule?
Consider this Firebase Storage rule:
What happens when any user tries to read a file in the 'public' folder?
service firebase.storage {
match /b/{bucket}/o {
match /public/{allPaths=**} {
allow read: if true;
allow write: if false;
}
}
}What happens when any user tries to read a file in the 'public' folder?
Attempts:
2 left
💡 Hint
Check the condition for read permission.
✗ Incorrect
The rule explicitly allows read for everyone by using 'if true'.
❓ Architecture
advanced2:00remaining
Choose the best rule to restrict file deletion to owners only
You want to allow users to upload and delete only their own files under 'users/{userId}/files/'. Which Firebase Storage rule achieves this?
Attempts:
2 left
💡 Hint
Consider how to allow both upload and delete but restrict others.
✗ Incorrect
Option A allows write only if the user owns the folder and it's either a create (resource == null) or delete (request.resource == null), covering upload and deletion but not updates.
🧠 Conceptual
advanced2:00remaining
What error occurs if a rule references an undefined variable?
In Firebase Storage rules, what happens if you write a rule that uses a variable not defined in the path or request context, like 'userId' without declaring it in the path?
Attempts:
2 left
💡 Hint
Think about how Firebase validates rules before deployment.
✗ Incorrect
Firebase validates rules on deployment and will reject rules with undefined variables, causing deployment to fail.
✅ Best Practice
expert3:00remaining
Select the best practice for securing user files in Firebase Storage
Which of the following is the best practice to secure user files in Firebase Storage to prevent unauthorized access?
Attempts:
2 left
💡 Hint
Think about isolating user data and limiting access.
✗ Incorrect
Best practice is to isolate user data by folder and restrict access so users can only access their own files, preventing unauthorized access.