diff options
author | Tom Taylor <tomtaylor@google.com> | 2014-10-14 13:38:17 -0700 |
---|---|---|
committer | Tom Taylor <tomtaylor@google.com> | 2014-10-14 21:45:22 +0000 |
commit | 790ac852b365ab77a895da9b48f925caf8fde729 (patch) | |
tree | 8af4d58c241e6601d1a1c4e089a3cfef07f9bdc1 /packages/WAPPushManager/src | |
parent | 4f89e3b215c731a34b3ab8c300539f96e3f22459 (diff) |
Externally Reported Moderate Security Issue: SQL Injection in WAPPushManager
Bug 17969135
Use query (instead of rawQuery) and pass in arguments instead of building
the query with a giant string. Add a unit test that fails with the old
code but passes with the new code.
Change-Id: Id04a1db6fb95fcd923e1f36f5ab3b94402590918
Diffstat (limited to 'packages/WAPPushManager/src')
-rw-r--r-- | packages/WAPPushManager/src/com/android/smspush/WapPushManager.java | 30 |
1 files changed, 22 insertions, 8 deletions
diff --git a/packages/WAPPushManager/src/com/android/smspush/WapPushManager.java b/packages/WAPPushManager/src/com/android/smspush/WapPushManager.java index 96e037797b98..e9703670008d 100644 --- a/packages/WAPPushManager/src/com/android/smspush/WapPushManager.java +++ b/packages/WAPPushManager/src/com/android/smspush/WapPushManager.java @@ -117,14 +117,18 @@ public class WapPushManager extends Service { */ protected queryData queryLastApp(SQLiteDatabase db, String app_id, String content_type) { - String sql = "select install_order, package_name, class_name, " - + " app_type, need_signature, further_processing" - + " from " + APPID_TABLE_NAME - + " where x_wap_application=\'" + app_id + "\'" - + " and content_type=\'" + content_type + "\'" - + " order by install_order desc"; - if (DEBUG_SQL) Log.v(LOG_TAG, "sql: " + sql); - Cursor cur = db.rawQuery(sql, null); + if (LOCAL_LOGV) Log.v(LOG_TAG, "queryLastApp app_id: " + app_id + + " content_type: " + content_type); + + Cursor cur = db.query(APPID_TABLE_NAME, + new String[] {"install_order", "package_name", "class_name", + "app_type", "need_signature", "further_processing"}, + "x_wap_application=? and content_type=?", + new String[] {app_id, content_type}, + null /* groupBy */, + null /* having */, + "install_order desc" /* orderBy */); + queryData ret = null; if (cur.moveToNext()) { @@ -392,10 +396,20 @@ public class WapPushManager extends Service { SQLiteDatabase db = dbh.getReadableDatabase(); WapPushManDBHelper.queryData lastapp = dbh.queryLastApp(db, x_app_id, content_type); + if (LOCAL_LOGV) Log.v(LOG_TAG, "verifyData app id: " + x_app_id + " content type: " + + content_type + " lastapp: " + lastapp); + db.close(); if (lastapp == null) return false; + if (LOCAL_LOGV) Log.v(LOG_TAG, "verifyData lastapp.packageName: " + lastapp.packageName + + " lastapp.className: " + lastapp.className + + " lastapp.appType: " + lastapp.appType + + " lastapp.needSignature: " + lastapp.needSignature + + " lastapp.furtherProcessing: " + lastapp.furtherProcessing); + + if (lastapp.packageName.equals(package_name) && lastapp.className.equals(class_name) && lastapp.appType == app_type |