Possible to change Firebase callable Functions data on Front End?

General Tech Bugs & Fixes 2 years ago

0 2 0 0 0 tuteeHUB earn credit +10 pts

5 Star Rating 1 Rating

Posted on 16 Aug 2022, this text provides information on Bugs & Fixes related to General Tech. Please note that while accuracy is prioritized, the data presented might not be entirely correct or up-to-date. This information is offered for general knowledge and informational purposes only, and should not be considered as a substitute for professional advice.

Take Quiz To Earn Credits!

Turn Your Knowledge into Earnings.

tuteehub_quiz

Answers (2)

Post Answer
profilepic.png
manpreet Tuteehub forum best answer Best Answer 2 years ago

I'm using Stripe and Firebase Function for payment. My current scenario for buying items in my app looks like the following.

  • Loading an Item, which is an firestore document with an Id and a price
  • User clicks on "Buy now for price", enters credit card information and confirems
  • I get a stripe source with an id, which to my knowledge contains information about the credit card
  • I call my firestore callable function and pass the stripeSourceIditemID and the item.price
  • In my function I check if the user (from context) is authentiated, then I charge the user and save the bought item in the user data, to deisplay the item later

My concerns are the point 4. Is it possible for a user to hack my front end code in a way, so that after stripe returns the sourceId, the hacker would call the function with a different price or a different itemId to get a different item for another price? If that is the case, how could I fix this problem?

profilepic.png
manpreet 2 years ago

Anything you pass from the client to the server, can be changed by a malicious user. That's why you should never trust any data that comes directly from the server.

The solution is to only pass the itemID from the client, and have the server look up the price based on that. If the malicious user passes a different item ID, they'll just be buying a different item, but still at the price that you have set.

I highly recommend watching Five tips to secure your app from the Firebase Summit 2018 for more tips on securing your app.


0 views   0 shares

No matter what stage you're at in your education or career, TuteeHub will help you reach the next level that you're aiming for. Simply,Choose a subject/topic and get started in self-paced practice sessions to improve your knowledge and scores.