Store sensitive data on the device
It really depends on your audience. Typically, Android OS prohibits applications from accessing other files (i.e. Databases, preference files, regular files stored in the application’s private folder) through verified Linux file permissions. However, on root devices, an application can gain root access and read everything. A few things to think about:
- If you know that your users will not have root (for example, if you do not distribute the application through the Android Market, but only in your company or something like that), you can simply rely on security based on the Android file system.
- If the user gets root access, he will be very careful what application he gives, what privilege
- If the application gains root access, it can lead to great devastation. The information in your application may be the least dangerous for the user.
- Roots lead to zero warranty. Including in applications. You cannot be held responsible for leaking root phone information.
In conclusion, if your information is not sensitive to super-duper (for example, credit card information), I would suggest that you simply adhere to the standard security provided by Android (i.e. save everything in text form, knowing that other applications cannot receive access she).
Otherwise, encryption is the way to go. It's not 100% safe (a hacker can decompile your application and figure out how to decrypt the data), but it's a big pain to crack and stop most hackers. Especially if you confuse your code with something like ProGuard .
Transfer confidential data from the server to the device
You have several options. First of all, always use HTTPS. After enabling HTTPS, here are two additional security measures that I would suggest:
- Use the API key system. Include this API key in all your requests and check it on the server side before sending a response. Remember that since you are using HTTPS, an attacker cannot simply use a network sniffer to find out your API key. However, it is quite easy to understand if someone is decompiling your application, so you can confuse it even more (besides using ProGuard). For example, you can leave the API key broken into pieces around your code (for example, as static members in two or three classes). Then, when you submit the request, you simply combine all these parts. You can even apply some other conversions (such as bit offsets) to make it even harder to figure out from the decompiled code.
- You can generate a key every time you send a request. This key will be generated using some logic that you only know so that you can implement it both on the client side and on the server side. For example, a query may include the following parameters:
time=1321802432&key=[generated-key]
where generated-key generated from the time parameter. For example: md5(time + salt) . When the server receives this request, it can perform two functions:- Make sure that the
key really equal to md5(time + salt) (note that only the client and server know the salt and can be confused similarly to the above API key) and - Make sure that
time not too far back (for example, if more than 1-2 minutes have passed, consider the request to be invalid).
The second method is more useful if you also perform simple HTTP requests, where everyone can see the parameters sent. In addition, it is much more difficult to deal with decompiled code. Especially if you have extended the key calculation logic to several classes.
However , note that nothing allows you to hack your application. You can neutralize as much as you want, if the hacker is really determined to receive your data, he can do it by decompiling your application and spending many sleepless nights passing through your code and finding out how requests are generated. The only real way to protect your data is to ask your user to enter a password, in addition to doing all the work that I wrote about above. You cannot get a password that exists only from someone (user) from the decompiled code :).
Felix Nov 18 2018-11-11T00: 00Z
source share