Skip to Main Content
Secure Development for Mobile Apps
book

Secure Development for Mobile Apps

by J. D. Glaser
October 2014
Intermediate to advanced content levelIntermediate to advanced
472 pages
10h 44m
English
Auerbach Publications
Content preview from Secure Development for Mobile Apps
97
PHP seCurIty tools overvIew
is is safe, just not a good practice.
$confirmedINT = intval($id);
query("SELECT * FROM accounts WHERE id = $ confirmedINT ");
No mysql_real_escape_string() needed. Consider the following example.
$id = $_POST['accountID']; //accountID = 45, which
is fine
$safeID = mysql_real_escape_string($id); //falsely cleaned!
query("SELECT * FROM accounts WHERE id = $safeID");
e result is:
query("SELECT * FROM accounts WHERE id = 45");
In this case, mysql_real_escape_string() does nothing because accoun-
tID is an integer, and there is nothing to escape.
However, if accountID is changed to “1 OR 1 = 1”, now examine what happens.
$id = $_POST[accountID]; //accountID = "1 OR 1 = 1", which is NOT
fine
$safeID = mysql_real_escape_string($id); ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Developing with Web Standards

Developing with Web Standards

John Allsopp
Mobile Cloud Computing

Mobile Cloud Computing

Dijiang Huang, Huijun Wu

Publisher Resources

ISBN: 9781482209037