views:

103

answers:

3

I always take precautions regarding SQL INJECTION ATTACKS when data is saved between someone's iPhone and a remote database on the cloud.

But is it also necessary to do the same... when just saving data (using sqlite) from someone's cell phone, to a database that's just on their own phone?

What's the worse they can do? Delete their own data (or tables) on their own phone? (If they really try hard enough.)

Thanks.

+1  A: 

Yes, it is necessary, IMHO.

  1. The majority of injection attacks can be prevented by adherence to correctness
    SQL placeholders and bound variables, for example, handle both unexpectedly formed input (e.g., the innocent apostrophe in "5 o'clock") and malicious input (e.g., "' OR 1=1 --").
    So, be scrupulously correct in your data handling, and don't worry about most injections.

  2. Injections might subvert application logic
    SQLite has triggers, I think, but in any case the application might make decisions based on data pulled from the local db, attacking other facets of the environment, etc. If today's application isn't complex enough for this, tomorrow's rev will be.

  3. Someone else might be using (attacking) the phone, not just an authorized user
    True, this is generic risk of, say, the desktop authenticated to StackOverflow. However, I find that "smartphone" apps are more at risk of unintended operators: many phones have no passcode, many apps require no frequent re-authentication, and users may freely give their phones to people who just need to make a quick call.

pilcrow
How would an entry like "5 o'clock" hack or injection attack the database? If I give someone else my phone... they are free to delete any data, contacts, any apps, etc. So "I'll write some injection code" is probably the LEAST likely thing they will try.
Susanna
@Kimberly, "o'clock" might not be malicious in intent -- it might simply corrupt the application or be inappropriately rejected. Regarding your second question, respectfully, just because we can imagine immediate, damaging attacks foolishly facilitated by the user, doesn't mean there aren't subtler attack vectors.
pilcrow
A: 

If you are syncing an iPhone database with a remote database do not trust the content. It doesn't take SQL Injection to change the database. A jailbroken iPhone gives the user full access to entire file system which includes the sqlite database file, this can then be modified however the attacker wants. This isn't sql injection, this is a "Client Side Trust" vulnerability.

SQL Injection under sqlite is useful to an attacker. Unlike MySQL, Sqlite allows you to stack queries, so the attacker can always create/drop/insert/update/delete/select/etc no matter what query is affected by sql injection. Under MySQL its common to inject sub-selects or union-selects to obtain specific data, but for instance you cannot turn a select statement into an insert under normal conditions.

Rook
I'm not 'syncing' with a remote database.. or using any remote database of any kind. If the user physically steals my phone... and then jailbreaks it... he ALREADY can easily delete/add/edit my database. I'm not using MySql in any way.
Susanna
+1  A: 
  • Is it necessary? - Yes, its "necessary", i.e. its probably worth it. Even if you don't care much about security in this context (which may be valid), you should worry about correctness (at the very least, its matter of pride).

  • What's the worst that could happen?

    • User #1 Patty O'Brian enters her name into a field that gums up the SQL call and it fails. The program either doesn't handle it well or the user gets an ambiguous error message as to why it failed.
    • User #2 enters a name that gums up the SQL call and it succeeds! The program is now in an unknown state.

    Either way, now the user contacts support and eats up time and energy (user #2 never admitting what they did, making it even more difficult to debug) and/or demands their money back.

Bert F
My code ALWAYS correctly handles single and double quotes... but I was talking about TRUE sql injection and hacking.
Susanna