AppSec Blog

Spot the Vuln - Action

Take time to deliberate; but when the time for action arrives, stop thinking and go in.
Napoleon Bonaparte

Spot the Vuln uses code snippets from open source applications to demonstrate vulnerabilities in real world web applications. Every Monday morning a vulnerable code snippet is posted. Take a look at the vulnerable code and try to identify where the security vulnerability is. Every Friday, a solution is posted so you can check your answers. Each exercise is designed to last between 5 and 10 minutes. Do it while you drink your morning coffee and you will be on your way to writing more secure applications.

<?php ...snip... // forgot password? if(isset($_GET['x']) && $_GET['x']=='passreminder') { echo ' <p style="border: solid 2px; padding: 5px; color: red; font-weight: bold; font-size: 11px; margin-left: auto; margin-right: auto; margin-top: 10%; font-family: verdana,arial,sans-serif; text-align: center;">'; if ($cfgrow['admin']!= $_POST['user']) { echo "$admin_lang_pw_wronguser "; echo " $admin_lang_pw_back"; die(); } if ($cfgrow['email']== "") { echo "$admin_lang_pw_noemail "; echo " $admin_lang_pw_back "; die(); } if (strtolower($cfgrow['email'])==strtolower($_POST['reminderemail'])) { // generate a random new pass $user_pass = substr( MD5('time' . rand(1, 16000)), 0, 6); $query = "update ".$pixelpost_db_prefix."config set password=MD5('$user_pass') where admin='".$cfgrow['admin']."'"; if(mysql_query($query)) { $subject = "$admin_lang_pw_subject"; $body = "$admin_lang_pw_text_1 \n\n"; $body .= "$admin_lang_pw_usertext ".$cfgrow['admin']." \n"; $body .= "$admin_lang_pw_mailtext ".$cfgrow['email']." \n\n"; $body .= "$admin_lang_pw_newpw $user_pass"; $body .= "\n\n$admin_lang_pw_text_7".$cfgrow['siteurl']."admin $admin_lang_pw_text_8"; $headers = "Content-type: text/plain; charset=UTF-8\n"; $headers .= "$admin_lang_pw_text_2 \n"; $recipient_email = $cfgrow['email']; if (mail($recipient_email,$subject,$body,$headers)) {echo "$admin_lang_pw_text_3" .$cfgrow['email'];} else { echo "$admin_lang_pw_text_3";} echo " $admin_lang_pw_back "; die(); } else { $dberror = mysql_error(); echo "$admin_lang_pw_text_5 " .$dberror ."$admin_lang_pw_text_5 " ; echo " $admin_lang_pw_back "; die(); } } else { echo "$admin_lang_pw_notsent "; echo " $admin_lang_pw_back "; die(); }// end else (strtolower($cfgrow['email'])==strtolower($_POST['reminderemail']) & $cfgrow['email']!= "") } // end if($_GET['x']=='passreminder') ?>
About the Authors:
Brett Hardin and Billy Rios run, a website dedicated to helping developers understand secure coding practices. You can find out more about the authors by visiting

Post a Comment


* Indicates a required field.