Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
1
Question by cheesemaster · Jul 11, 2016 at 12:45 PM · servergoogle playsecurityin app purchasevalidation

Google Play - IAP Purchase Server side receipt validation

Hi, turns out our in app purchase integration is hackable, some people have already racked up $900 worth of fake purchases so far! We're using Prime31 plugin for Unity and they recommend referring to the google docs for server-side receipt validation.

Trouble is this is the first time I'm doing this type of job and there doesn't seem to be any decent step-by-step guide or walk-through on google or anywhere else for that matter to set it up. If I manage it I might make one for laymen like myself.

Using the Prime31 plugin I have got so far as to receive a successful GooglePurchase object back to Unity.

From what I have understood, the .originalJson field of that object needs to be Sha1 hashed with the google play private key (possibly also with a unique identifier like the player's username) in Unity and then sent to the server for validation and a success/failed result returned back to Unity before the item is consumed. Does that sound like an accurate description of what's involved client side?

If so, what I'm having difficulty understanding now is what to do with this string on the server? What should constitute a valid result or an invalid result? Does the server need to call up google directly to compare the hashed string to something? Or does the server need its own copy of the private key to compare it with?

Does anyone have any insight into how people are actually hacking these purchases? Is it by reverse engineering the APK and discovering the private key? It would be helpful to know what we are trying to prevent in order to understand the apparent solution we are trying to implement.

Any info at all would be greatly appreciated. Thanks.

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image cheesemaster · Jul 11, 2016 at 09:57 PM 1
Share

Delving further into this, for anyone interested, it appears that the most common type of hack for in-app-purchases is a "man-in-the-middle" attack where the client unwittingly calls a server that pretends to be Google, which receives the purchase request from the client (your app), and always returns a successful response, irrespective of whether or not any money was taken.

The reasoning therefore behind receipt validation, is to verify that the server the request was sent to was actually Google, as opposed to some dodgy IP made by the hacker.

The way we can verify this, is by using the GooglePlay Public $$anonymous$$ey, which is basically a long string constant randomly generated by Google when you register a new app that only Google, and the developer know about (find it in the google-play console under "Services & API"'s tab).

The presumption is that the "man-in-the-middle" (the hacker's dodgy server) doesn't know this key and, unlike Google, can not return it in its dodgy GooglePurchase response object.

So far from what I've understood google use this key (or possibly its private counterpart - something I'm still trying to understand) to encrypt/hash the GooglePurchase.signature field of the response in a way that the "man-in-the-middle" can not do.

Therefore the developer can be sure that the response came from Google by "validating" the signature field of the response. Validation is essentially = ensuring that the signature was encrypted in the expected manner that it should be if it made use of the public key.

I am still not sure why this can't be done locally, as in within the client (which also has a copy of the public key) and why the response needs to be sent off to a server for the validation to be done in PHP. This seems completely unnecessary to me, but I am sure I will find out in the co$$anonymous$$g days.

If anyone has any info that could be remotely useful to my effort I would really appreciate it.

0 Replies

· Add your reply
  • Sort: 

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

48 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Security, Authentication, TLS & UnityWebRequest 0 Answers

Google Play libpng security alert 1 Answer

IAP Restore purchase on Android "Already Recorded Transaction" 0 Answers

Server side security: dynamic hash salt 0 Answers

Data encryption to transfer data over web 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges