Warm tip: This article is reproduced from serverfault.com, please click

How to secure my API against "fictitious" payload?

发布于 2020-11-27 18:47:59

I have developed an app for Android/iOS which calculates a value based on the users input. If an event occurs, this calculated value will be sent to my Backend as normal HTTPS payload. My question is now, how can I make sure, that this value is really only calculated by the source code of my app? Is there a way to handle such a problem?

To make it clear: I want to avoid, that somebody is rooting his phone, extract the Auth-Token from the private storage of my app and sends a valid HTTPS-Payload to my Backend with fictitious payload, manually or by manipulating the source code.

From the view of the backend, it's difficult to evaluate the payload based on its values if it is valid or not.

Any suggestions appreciated!

----------EDIT-----------

For the sake of completeness: apart from the answers here, the following are also very interesting:

Where to keep static information securely in Android app?

How to secure an API REST for mobile app? (if sniffing requests gives you the "key")

Questioner
eltitano
Viewed
0
Scott McNeany 2020-11-28 07:08:07

You can’t trust data coming from the client. Period.

You should consider moving the calculation logic to the server and just sending the raw values needed to perform the calculation. You can easily get sub-second response times sending the data to the server, so the user won’t notice a lag.

If you need offline connectivity, then you’ll need to duplicate the business logic on both the client and the server.