I like pushing boundaries.
Lady Gaga
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.
...snip... </style> <?php // We do some checking to see what we're doing if (isset($_POST['mode']) && $_POST['mode'] == 'add') { // Proceed with the save $sql = "INSERT INTO " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_name='".mysql_escape_string($_POST['category_name'])."', category_colour='".mysql_escape_string($_POST['category_colour'])."'"; $wpdb->get_results($sql); echo "<div class=\"updated\"><p><strong>".__('Category added successfully','calendar')."</strong></p></div>"; } else if (isset($_GET['mode']) && isset($_GET['category_id']) && $_GET['mode'] == 'delete') { $sql = "DELETE FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".mysql_escape_string($_GET['category_id']); $wpdb->get_results($sql); $sql = "UPDATE " . WP_CALENDAR_TABLE . " SET event_category=1 WHERE event_category=".mysql_escape_string($_GET['category_id']); $wpdb->get_results($sql); echo "<div class=\"updated\"><p><strong>".__('Category deleted successfully','calendar')."</strong></p></div>"; } else if (isset($_GET['mode']) && isset($_GET['category_id']) && $_GET['mode'] == 'edit' && !isset($_POST['mode'])) { $sql = "SELECT * FROM " . WP_CALENDAR_CATEGORIES_TABLE . " WHERE category_id=".mysql_escape_string($_GET['category_id']); $cur_cat = $wpdb->get_row($sql); ?> <div class="wrap"> <h2><?php _e('Edit Category','calendar'); ?></h2> <form name="catform" id="catform" class="wrap" method="post" action="<?php echo bloginfo('wpurl'); ?>/wp-admin/admin.php?page=calendar-categories"> <input type="hidden" name="mode" value="edit" /> <input type="hidden" name="category_id" value="<?php echo stripslashes($cur_cat->category_id) ?>" /> <div id="linkadvanceddiv" class="postbox"> <div style="float: left; width: 98%; clear: both;" class="inside"> <table cellpadding="5" cellspacing="5"> <tr> <td><legend><?php _e('Category Name','calendar'); ?>:</legend></td> <td><input type="text" name="category_name" class="input" size="30" maxlength="30" value="<?php echo stripslashes($cur_cat->category_name) ?>" /></td> </tr> <tr> <td><legend><?php _e('Category Colour (Hex format)','calendar'); ?>:</legend></td> <td><input type="text" name="category_colour" class="input" size="10" maxlength="7" value="<?php echo stripslashes($cur_cat->category_colour) ?>" /></td> </tr> </table> </div> <div style="clear:both; height:1px;"> </div> </div> <input type="submit" name="save" class="button bold" value="<?php _e('Save','calendar'); ?> »" /> </form> </div> <?php } else if (isset($_POST['mode']) && isset($_POST['category_id']) && isset($_POST['category_name']) && isset($_POST['category_colour']) && $_POST['mode'] == 'edit') { // Proceed with the save $sql = "UPDATE " . WP_CALENDAR_CATEGORIES_TABLE . " SET category_name='".mysql_escape_string($_POST['category_name'])."', category_colour='".mysql_escape_string($_POST['category_colour'])."' WHERE category_id=".mysql_escape_string($_POST['category_id']); $wpdb->get_results($sql); echo "<div class=\"updated\"><p><strong>".__('Category edited successfully','calendar')."</strong></p></div>"; } $get_mode = 0; $post_mode = 0; if (isset($_GET['mode'])) { if ($_GET['mode'] == 'edit') { $get_mode = 1; } } if (isset($_POST['mode'])) { if ($_POST['mode'] == 'edit') { $post_mode = 1; } } if ($get_mode != 1 || $post_mode == 1) { ?> <div class="wrap"> <h2><?php _e('Add Category','calendar'); ?></h2> <form name="catform" id="catform" class="wrap" method="post" action="<?php echo bloginfo('wpurl'); ?>/wp-admin/admin.php?page=calendar-categories"> <input type="hidden" name="mode" value="add" /> <input type="hidden" name="category_id" value=""> <div id="linkadvanceddiv" class="postbox"> <div style="float: left; width: 98%; clear: both;" class="inside"> <table cellspacing="5" cellpadding="5"> <tr> <td><legend><?php _e('Category Name','calendar'); ?>:</legend></td> <td><input type="text" name="category_name" class="input" size="30" maxlength="30" value="" /></td> </tr> <tr> <td><legend><?php _e('Category Colour (Hex format)','calendar'); ?>:</legend></td> <td><input type="text" name="category_colour" class="input" size="10" maxlength="7" value="" /></td> </tr> </table> </div> <div style="clear:both; height:1px;"> </div> </div> <input type="submit" name="save" class="button bold" value="<?php _e('Save','calendar'); ?> »" /> </form> <h2><?php _e('Manage Categories','calendar'); ?></h2> ...snip...
About the Authors:
Brett Hardin and Billy Rios run spotthevuln.com, a website dedicated to helping developers understand secure coding practices. You can find out more about the authors by visiting http://spotthevuln.com/about-spot-the-vuln/

Post a Comment
* Indicates a required field.