Quote:
Originally Posted by adamscott421
I am making an app that sends an NSURLRequest to my own webserver to a php file that queries a database. The user will be allowed to insert items into the database so i obviously need a cleaning function for that. But my question is are there any other security concerns i need to worry about, for instance can i hard code my username and password when connecting to mysql?
|
Use https if you don't want people to snoop on the contents of your request. Even then, remember that the URL is NOT encrypted, so anyone monitoring the network between the phone and your server could conceivably see the URL (NAT servers, web proxies, etc.) So be sure to put anything sensitive in a POST, not in a GET.
That done, I don't think there's any reason to put your database password in the iPhone app - it should be in the PHP, since the PHP accesses the database.
Lastly, you need to make sure that no one can construct a http query that would harm your data. Perhaps the app should request a user key (NOT easily guessable, NOT a sequential number!) from the server on first run, and include that user key in every request? Then the server should only act on requests with a valid user key. At this point, even if someone builds a custom https request, they need to guess a valid user key to affect any data.
PS - just for noobs - you should not have any SQL or real field and table names in your https request; just action names that the server will respond to. If you have "select from" or "delete from" anywhere in your request, or something like "action=set&table=hiscores&field=name" , then you're doing it wrong.