Firestore Security Rules - How to Hack a Firebase App

Поділитися
Вставка
  • Опубліковано 18 січ 2025

КОМЕНТАРІ • 145

  • @Fireship
    @Fireship  6 років тому +151

    Hey everybody. Just in case you missed to the point... NEVER ship a Firebase app without solid rules in place first!

    • @patrickmullot73
      @patrickmullot73 6 років тому

      Same goes with stackblitz. It's a wonderfull tool, but DO NOT share production API key there.

    • @Fireship
      @Fireship  6 років тому +2

      I'm sure you could scape a bunch of secret keys there

    •  6 років тому

      Very usefull Jeff, Thanks for your awesome videos

    • @moradabdelgaber5958
      @moradabdelgaber5958 6 років тому

      I'm using Role ( allow read ,write : if request.auth.uid != null ) when I logged in I get data it's ok , but when I log out the user I get the error : Missing or insufficient permissions. first I thought it was because of I didn't unsubscribe the Observable I tried (rxjs/operator/takeWhile) even I used async pipe . I got the same error please help !!!

    • @janoschii
      @janoschii 6 років тому +2

      You are allowing read and write ONLY if the request.auth.uid is not null. So!

  • @MatuellaSlipknot
    @MatuellaSlipknot 6 років тому +42

    Your speech is really on point and the video is so well edited (a minimalist edition like you did is awesome btw). Kudos for all the clean and straightforward explanations, 10/10.

  • @justserv
    @justserv 6 років тому +7

    Very important video! I've been waiting for someone to create a decent intro to Firestore rules like this, and I'm glad you showed us exactly how easy it can be to do something malicious to an unsecured database. Honestly I was asking myself for months how someone might go about erasing my database, and that was an eye-opener! I love how your tutorials are straight-to-the-point; every second always has something useful in it! Keep up the awesome work!! :)

  • @goku21youtub
    @goku21youtub 4 роки тому

    even though the title says something different , this is the most relatable firestore security rules video ive seen till now . im a noob and trying to learn the firestore system right now and this video was extrmely helpfull , well explained , not too long and not too short . Thanx alot !

  • @dalemoncayo
    @dalemoncayo 6 років тому +9

    This is the best firebase tutorial ever. Youre amazing man!

  • @Hardikkmadaan1702
    @Hardikkmadaan1702 5 років тому +1

    The best and the only video you know to protect your data on Cloud Firestore. Thanks a lot buddy!

  • @sellyshootsandscores9300
    @sellyshootsandscores9300 Рік тому

    I loved the emphasis on “And it’s really important that you don’t mess up your back-end rules”

  • @zoidbergZA
    @zoidbergZA 6 років тому +28

    10/10 as always with this man... liked, subbed, notified

    • @Fireship
      @Fireship  6 років тому

      Thank you, much appreciated!

  • @iMed-Med
    @iMed-Med 3 роки тому +1

    Am I the only one that watched all his videos till a point where I listen to it as a podcast? Great content

  • @patrickmullot73
    @patrickmullot73 6 років тому +9

    AWESOME!!! That's pure added value Jeff!

    • @Fireship
      @Fireship  6 років тому +2

      Thank you! This is a very important area that seems to get overlooked way too often.

  • @samadritsarkar2
    @samadritsarkar2 3 роки тому

    Learnt a lot from this 3 years old vid! Thanks mate

  • @holylambo
    @holylambo Рік тому

    amazing video, i have a lot of trouble concentrating on reading the docs so this was incredibly helpful!

  • @MatthijsvanHest
    @MatthijsvanHest 6 років тому +1

    Very clean video, totally explaining exactly what I needed from firebase to safely start developping. Firebase is new to me, I was concerned I can't do a lot of things I need to do and know how to do otherwise.. But your videos show otherwise, Firebase is just different, but it's all there!

  • @bensonmwaura9494
    @bensonmwaura9494 6 років тому +2

    DevOps take note! Always something productive to look forward to, great content.

  • @chordfunc3072
    @chordfunc3072 5 років тому

    Thanks for putting so much time into making this... Always great videos and always stunning graphics, and crisp audio :D Always find my way back to your channel :)

  • @moibe182
    @moibe182 Рік тому

    Thanks Fireship! You keep me improving at my job thanks ❤

  • @zeroblackstar
    @zeroblackstar 6 років тому

    Great videos man, I've been looking for something in depth for a while. Will be getting myself your course/Book for sure.

  • @thijsoudeavenhuis1015
    @thijsoudeavenhuis1015 6 років тому

    Hey guys, this is really good stuff. The docs on firestore are great but only cover the basis. these videos show some really clever tricks to writing more secure firebase apps.

  • @imacuser101
    @imacuser101 6 років тому +1

    Keep up the good work! Your videos are always the best and to the point

  • @thitemple
    @thitemple 5 років тому +1

    Great content on this video and the channel overall. Thanks, I like how on point your examples are and I can't really understand how anyone would downvote a video like this...

    • @chngo7180
      @chngo7180 5 років тому

      The upvote is you who got scared by the title for the kind of hack that might befall your database and quickly clicked on the link. The downvote is the evil doer who expected to learn how to hack in your database but won't be able to do so anymore. @Fireship Thanks for the great content!!

  • @Rouwen87
    @Rouwen87 2 роки тому

    This is an amazing video, answered all of my questions for my server less app I was going to make.
    Thank you!

  • @prabhursec9627
    @prabhursec9627 3 роки тому

    I was confused about this thing before watching this. But ,now everything becomes clear. Nice explanation☺️. Thank you🙂

  • @FidelGuajardo
    @FidelGuajardo 5 років тому +2

    This video content is super important and useful to me. Thank you!

  • @LERSHEANLIM
    @LERSHEANLIM 10 місяців тому

    OMG this video help me so much!!!!! Hope you can do more videos like this!! Keep moving on👍👍

  • @kamalkamals
    @kamalkamals 6 років тому

    This is the best video explain firebase operations roles, we wait to add more, thnx Jeff

  • @FidelGuajardo
    @FidelGuajardo 5 років тому

    Very useful content about using functions to build authentication rules. I had never seen this before.

  • @adriantabay97
    @adriantabay97 6 років тому

    Thank u! Ive learned a lot. It just so perfect because I am writing security rules on my app's firestore

  • @Rafael-hk9pg
    @Rafael-hk9pg 3 роки тому +1

    How can you apply what is told at 9:23 for reading data? Thanks a lot!

  • @dustinpatterson3534
    @dustinpatterson3534 3 роки тому

    Thanks so much for this video! It was a huge help!

  • @RafaelSantos-pq4od
    @RafaelSantos-pq4od 6 років тому +2

    Very good, keep making videos about Security rules in firestorm, there is very little material on the web ... - from Brazil

    • @Fireship
      @Fireship  6 років тому +2

      Will do, I often incorporate them into my advanced lessons. Also, I think the official Firebase team has some rules content around the corner.

  • @GalTadmor
    @GalTadmor 6 років тому +10

    Your timing couldn't be better. I needed something exactly like that a few hours ago. Perfect as always, thanks a bunch!
    Quick question: what about the database.rules.json file? Should I match it to the backend rules? If so, what's the "translation" of it to a JSON file?

    • @Fireship
      @Fireship  6 років тому +4

      Those rules apply to Realtime DB, but this video is specific to Firestore. If you run `firebase init firestore` it will generate another file to define your rules in the IDE.

    • @GalTadmor
      @GalTadmor 6 років тому

      Angular Firebase Awesome. Thank you!

  • @georgedicu6001
    @georgedicu6001 2 роки тому

    for the roles, I would suggest using customClaims on JWT supported by firebase auth, and its server-side.

  • @contactmsr
    @contactmsr 5 років тому

    this is super important tips, i think google firebase team must have these kinds of check list in place

  • @ngotechy
    @ngotechy Рік тому

    Your video was extremely clear and informative. I just wanted to mention that I didn't quite understand the reference to episode 75 regarding user-based rules. Can you please clarify that for me?

  • @agung_laksana
    @agung_laksana 5 років тому

    Really Glad to find your channel since I want learn about serverless using firestore and google cloud functions
    One topic that I am not really confident yet is about security rules. Do you have a course about security rules ?
    I just only find web page about firestore security rules cookbook in your website, I mean the video version about this. Do you have one ?
    A pro version in your website is also ok
    Because it is about security, so it will be great if I can learn deeply through the video from beginner level to advanced
    Thank you very much for all your contents, hope you make it because I can't find a good one on the internet 😀

  • @Laithabujbara
    @Laithabujbara 3 роки тому

    Best explanation ever 👌 👏

  • @postfixnotation9829
    @postfixnotation9829 4 роки тому

    Extremely helpful and easy to understand! I have a question though which is not related to the content of this video, but let's say you wanted to ship an app to the chinese market, I assume Firebase doesn't work there, right? Is AWS Amplify or another product an appropriate alternative for this kind of issue? Thx, have a great day!

  • @razakadam74
    @razakadam74 6 років тому +2

    the title scared me at first but I really enjoyed it. I am always ready to take things to the next level... :)

    • @Fireship
      @Fireship  6 років тому

      Haha, that was my goal :)

  • @albertrenshaw4252
    @albertrenshaw4252 6 років тому

    At 5:53 you say or-statements only check "if one of the conditions is true"; did you mean to say "if one or both of the conditions are true", or is `or` treated as XOR by firebase?

    • @TimeoutMegagameplays
      @TimeoutMegagameplays 5 років тому

      Probably he meant to say if one or both of the conditions are true. You can very easily test it in the simulator if that makes any difference, you could test: allow read: if true || true;

  • @MuhammadbinYusrat
    @MuhammadbinYusrat 4 роки тому +1

    I am thinking if I am offering a service which is open for public (like a survey or something) my only option would be (as far as I understand) is to allow read write for everyone (may be restricting it to a specific collection?) but still it would be public write access...
    What can be done about this scenario? Because even if we add anonymous authentication, the curl request that you talked about in the beginning of your video will still contain all the data required to run it.. and can be pasted in terminal and then we're done again..
    I cannot find anything on this on Google too.. may be I am missing something very obvious here.

    • @spl45hz
      @spl45hz 4 роки тому +1

      You could allow create and read, but no write or delete. However the biggest problem is that anybody can request as many reads and creates as he wants, which might leave you with a huge firestore bill. As long as we cant limit this behavior I suggest staying away from firestore

    • @MuhammadbinYusrat
      @MuhammadbinYusrat 4 роки тому

      @@spl45hz There has to be a workaround for this. Why isn't this happening with more people?

  • @tntg5
    @tntg5 3 роки тому

    Hi Jeff! Thanks for this one!
    Do you know if there is a way to integrate AppCheck into an ionic capacitor app?

  • @TimeoutMegagameplays
    @TimeoutMegagameplays 5 років тому +8

    About the timeouts, you show us how to prevent users from modifying a document, but how would I prevent someone to spam create documents? For instance, I want to limit to 10 documents a minute to be created in /users/{userId}/files/, is that possible?

    • @ahsath
      @ahsath 5 років тому

      you can with query.limit < 10

  • @konfinoyair
    @konfinoyair 5 років тому

    This is not the original post, but a second revision. Anyway thank you.

  • @MrLuc420
    @MrLuc420 6 років тому

    sweet! Exactly what I was looking for!

  • @timsecond
    @timsecond 4 роки тому

    8:22 Can I use the similar method to get data stored in Firebase Realtime Database?

  • @gurucode.studio
    @gurucode.studio 4 роки тому

    Does that works for protecting videos from being watched or downloaded if the user is not subscribed or has bought the video course for example?

  • @KarlSchmaltz
    @KarlSchmaltz 4 роки тому

    Wouldn't having the roles in the user's document be unsafe because that user can edit that document and potentially promote their role? I guess you could always check the incoming data for modifications to the roles portion of the object. Would it be better to have a separate collection that contains all of the user roles that they can't access?

    • @David-dw8wy
      @David-dw8wy Рік тому

      Or how about using custom claims on their auth object

  • @cigrastudio_dev
    @cigrastudio_dev 2 роки тому

    I want a user to only edit the data of other users if he/she clicks on their profile. How to write rules for the scenario?

  • @PACKERSFANSheshank
    @PACKERSFANSheshank 5 років тому +14

    what would happen if someone spammed my db with requests increasing my firebase bill

    • @nfaical3
      @nfaical3 4 роки тому +1

      I guess that what google want. Its very easy to loop with a read request.

    • @PACKERSFANSheshank
      @PACKERSFANSheshank 4 роки тому +1

      @@nfaical3 fair enough...

    • @TheJorge421
      @TheJorge421 4 роки тому +1

      It's funny that fireship made a UA-cam post( don't know how to call them) where it says they were "attacked" just like you say

  • @godmen11
    @godmen11 6 років тому +2

    In the case when we want to restrict access to data that user owns: what if the userId is stolen? (request.auth.uid) Is there anything that verifies that?

    • @robrabbit8288
      @robrabbit8288 4 роки тому

      I guess, he needs to steal the password aswell, since u can check if the user is authenticated.

  • @robbertstapel788
    @robbertstapel788 2 роки тому

    Maybe a stupid question... but what if i am somehow able to set the uid to 1, true, or any other value as long as it's not null?

  • @konfinoyair
    @konfinoyair 6 років тому

    you helped me so much. thanks

  • @haidarrmehsen
    @haidarrmehsen 4 роки тому

    What if I need to put some validation on the data in the incoming request but the validation code needs me to define some variables and is not small code it is complex, what should I do in this case???

  • @CardinalHijack
    @CardinalHijack 5 років тому

    If you have your entire app hosted on one firebase project, IE hosting, firestore, cloud functions etc, is it possible to only allow requests from things on this project? So for example only allow database connections from the site hosted on your project, or only allow the database to be accessed by cloud functions on your project. In effect, just stoping random IPs from connecting to your databse or firing your functions?

  • @georgedicu6001
    @georgedicu6001 2 роки тому

    isn't the request.time supposed to be gather than resource.data.createAt (this files is the one already existing, so it will be an update operation)?
    the way you've written it, means the request has to always be in the past .
    in this case you allow update on {productId} for the 1st 60 secs, then you always deny?

  • @rudrasarkar1852
    @rudrasarkar1852 4 роки тому

    My question is : How can I find that products id, I guess firebase front end don’t show id of the product id to client side.

  • @bono95zg
    @bono95zg 6 років тому

    is it posible to only allow read if on your hosted domain?

  • @remoreacts91
    @remoreacts91 6 років тому

    So if I did my rules right, the curl -x command should not work right? I pressed enter and nothing happened..so I am guessing atleast that collection I tested is safe.

  • @maheshj01
    @maheshj01 4 роки тому

    hey, thanks for this great video I wanted to know how can we have rules in a chat app where I have two types of roles seller and buyer and I want to prevent sellerseller or buyerbuyer communication basically I want that only sellerbuyer can communicate. Some Insights on this would be really helpful.

  • @OfferoC
    @OfferoC 6 років тому

    How do you test and deploy these rules?

  • @AmitK
    @AmitK 6 років тому

    is this possible to expose credentials while using firebase with react native mobile app ?

  • @williamxsp
    @williamxsp 5 років тому

    What if I have a query like this.db.collection(`users`, ref =>
    ref.where("someProperty", "==", someValue)
    );?

  • @MrMaxBushido
    @MrMaxBushido 5 років тому

    This sounds too complicate for me, where should i go to understand how to secure my saved data?

  •  3 роки тому

    Awesome, thanks!

  • @SouhailELAmrani
    @SouhailELAmrani 5 років тому

    this rules doesn't exist in realtime database firebase ? how can i protect my Realtime data ??

  • @abdulalimrajoub6063
    @abdulalimrajoub6063 6 років тому +1

    Thanks man , it's awesome

  • @saranshagarwal2500
    @saranshagarwal2500 6 років тому

    How to change rule for a particular collection.
    Like i have a collection by the name Test and in the collection there are documents. all documents have same fields. i want every document field must have different data.

  • @egamingizback444
    @egamingizback444 3 роки тому

    How i can give to an specific user the verified badge to my app?

  • @adminmail6006
    @adminmail6006 6 років тому +1

    need what background music is running ... can anyone??

  • @deepikamadaan95
    @deepikamadaan95 4 роки тому

    Hi,
    Kindly reply, its so urgent.
    I have 2 apps, 1 is for company and another one is for clients.
    And in both the apps, registered users are modifying data in the same collection documents. No one is the owner of any document. In that case how can I make sure that my firebase data is safe for that collection.
    I am just checking user is authenticated user in the rules.
    Please Please reply, I am very scared before publishing my apps.

  • @beneditomauroo
    @beneditomauroo 5 років тому

    Firebase sugests using custom claims for role auth

  • @tfktoufik9724
    @tfktoufik9724 2 роки тому

    thanks bro you help me

  • @Cnuggets
    @Cnuggets 5 років тому +1

    How do i navigate to two worded collections like ‘user record’ ex: match/ user record/{urId}

    • @Cnuggets
      @Cnuggets 5 років тому

      please help! I’m stuck

    • @yocheeseify
      @yocheeseify 5 років тому +1

      Have you figured this out?

    • @Cnuggets
      @Cnuggets 5 років тому

      @@yocheeseify you have to restructure your data, so far there is no solution for this. It's also good practice to using the naming conventions like in coding.

    • @yocheeseify
      @yocheeseify 5 років тому

      @@Cnuggets ah gotcha. Thanks for the assist!

    • @Cnuggets
      @Cnuggets 5 років тому +1

      The Apocalypse You are welcome. Happy Coding!

  • @mateja176
    @mateja176 6 років тому

    Jeff is a legend

  • @kirill4531
    @kirill4531 5 років тому

    Is there any way I can limit the number of docs user can create?
    I have a field "owner" = "user@email.com" in a doc, and I don't want a new record if there are already 100 records with this owner.

  • @boysattitude3283
    @boysattitude3283 Рік тому

    Agar firebase ki OTP share kar di to kya kare

  • @ameerattaa2250
    @ameerattaa2250 6 років тому

    hi my friend
    how can moniter my firestore database so that whenever a new data added by a user the admin get notification on his app

    • @Fireship
      @Fireship  6 років тому +1

      That's a good use case for a cloud function. Check out some of these lessons for ideas angularfirebase.com/tag/functions/

    • @ameerattaa2250
      @ameerattaa2250 6 років тому

      Angular Firebase i will thank you very much

  • @budhanshukajla3793
    @budhanshukajla3793 4 роки тому

    How to get my firebase based android app's IP address?

  • @shivam-dua
    @shivam-dua 4 роки тому

    Thank you!

  • @joshbedo8291
    @joshbedo8291 4 роки тому

    Awesome thanks!

  • @moradabdelgaber5958
    @moradabdelgaber5958 6 років тому

    I'm using Role ( allow read ,write : if request.auth.uid != null ) when I logged in I get data it's ok , but when I log out the user I get the error : Missing or insufficient permissions. first I thought it was because of I didn't unsubscribe the Observable I tried (rxjs/operator/takeWhile) even if I used async pipe , I got the same error . please help !!!

    • @ThatsEli
      @ThatsEli 6 років тому

      You only allowed to read and write with the condition request.auth.uid != null.(Only allow when logged in)

  • @drmucahiderdogan
    @drmucahiderdogan 3 роки тому

    Great tutorial.

  • @HungTinTrinh
    @HungTinTrinh 3 роки тому

    Amazing good job!

  • @hojdog
    @hojdog 6 років тому

    Everybody, use *Custom Claims* for role based access, not this way.

  • @wesleycampos6586
    @wesleycampos6586 6 років тому

    Queria saber falar inglês para não ter que ficar usando legendas kkkkk... mas parabéns pelo seu trabalho =]

  • @aankushchauhan
    @aankushchauhan 2 роки тому

    really helpful

  • @akashtakawale9074
    @akashtakawale9074 3 роки тому

    This is so cool !!

  • @jorgeriveramx
    @jorgeriveramx 3 роки тому

    awesome as allways

  • @LocalDegenn
    @LocalDegenn 5 років тому +1

    0:24 Savage

  • @vid2ification
    @vid2ification 4 роки тому

    Just need an alternative nd functional os for Moto Z⁴... Shilltube offers no examples, and google doesn't want to show those seach results.

  • @adamn1973
    @adamn1973 5 місяців тому

    Super helpful

  • @avilainkennefoue290
    @avilainkennefoue290 3 роки тому

    The real title of this video is: how to prevent your Firestore from getting hacked !

  • @yeilmusic
    @yeilmusic 5 років тому

    MUCH LOVE

  • @solomonaryeetey7370
    @solomonaryeetey7370 5 років тому

    Just subscribed

  • @أخبارالآن-ك1ش
    @أخبارالآن-ك1ش 3 роки тому

    Please hack code password for firebase

  • @tonyjaradev
    @tonyjaradev 4 роки тому

    Lifesaver

  • @razakadam74
    @razakadam74 6 років тому

    Wish I could have 10 - 30 mins of slack time with you.

  • @DjWizard1991
    @DjWizard1991 4 роки тому

    12 Guys is the one who tried to hack into your apps

  • @dr_rick
    @dr_rick 6 років тому +2

    You're not teaching how to hack it, you're teaching how to secure it, everything you did to "hack" is by design. Great tutorial, I just suggest you fix the title and description of the video.

    • @Fireship
      @Fireship  6 років тому +5

      That's a fair point, but the title is tongue-in-cheek. My main goal is to emphasize that your Firebase data is vulnerable unless you secure it with rules.

    • @dr_rick
      @dr_rick 6 років тому

      Yes, I totally understand that, Jeff. I just mean that some people might expect to learn how to secure an actual hack. Kinda of a click bait if you know what I mean. But I also think it's good to bring attention to this aspect of firestore, since it's becoming famous and it's still something new.
      Thanks for the response and for the video!

  • @TheFarijo
    @TheFarijo 5 років тому

    nice bait