|
Condition 1: Running Dynamic SQL Generated with Unsanitized Texts
OK, everyone knows this. The programmer takes an argument from a web page submission and plugs it into SQL as part of preparing a database interaction. Here’s a sample in Java:String loginSQL = "SELECT USER_NAME, AVATAR_IMAGE, LAST_POST_TITLE, LAST_POST_TIME FROM USER_INFO WHERE USER_ID IN (SELECT USER_ID FROM USER_PASSWORD WHERE USER_EMAIL = '" + parm (USER_EMAIL_PARM) + "' AND HASH_PASSWORD = PASS_HASH_FUNCTION (1, '3315', 'passHash1', '" + parm [USER_PASSWORD_PARM] + "')";This example is simplified to some degree, but the effect is the same. If an attacker enters a password like this Oracle example:
LOL' UNION ALL SELECT CURRENT_USER, NULL, PRIVILEGE, SYSDATE FROM SESSION_PRIVILEGES -- ' ;…then the attacker may well get the identity of the current database user and a list of all privileges active for that user.