How to protect data in HTML5 + PhoneGap mobile app?

Is it possible to protect the sqlite database inside a mobile application created using PhoneGap + HTML5? I have a large chunk of data that I would like to protect. But from the nature of the technology used, it seems to me almost impossible. If it is not possible to protect the data, is it possible to at least use some obfuscation to discourage script-kiddies so as not to try to easily get to the data?

+6
source share
3 answers

The user of your software has more rights to control the sqlite database than you. Your software is just a visitor on your machine . Any form of encryption will be security, although unknown , because you cannot have a secret (or secret key) on the device.

If you want to protect the database, you must host it. I recommend setting up a RESTful interface so that js on the mobile device can perform actions on the data. You should assume that the attacker has 100% access to this RESTful interface. You should never expose a function like do_query("select ..."); . Make sure you take the SQL injection into account.

+1
source

The only thing you can do is to encrypt the data as it enters the database, and then decrypt it as it returns. To do this in a semi-supported way, you will need some level of database access, where there may be encryption / decryption so that your main application does not worry about it.

I am not very good at PhoneGap, so I'm not sure if there are any existing plugins that do this. But if you do not mind that encryption / decryption is related to your application code, you can simply pass everything through the encrypt(myData) function on the way to the database, and then through the decrypt(myData) function on the way out. This will work very well if you are only going to / from the database in several places.

This is a pretty tough decision, but, as you said, the options are pretty limited.

Finally, I would suggest using a device identifier (if you can get one) or some other way for each key or each device to get an encryption key, so that each device is more difficult to crack, and not all devices using the same key. A hash of a username or salted username or salted hash of a hash file may be a good option.

+1
source

You can also encrypt your data using JSAES: AES in JavaScript , but then you need some kind of key management mechanism using your server / user.

0
source

Source: https://habr.com/ru/post/887133/


All Articles