Jul 24

Preventing Data Corruption Due to User Interface Bugs

There’s a standard way of handling object updates via HTML forms. Generally speaking, when the user selects an object to edit, you populate an HTML form with all the data from the object, post all these fields when the user presses Submit, then update all the fields of the record with the data in the HTTP request.

So, if I’m going to edit an article, the HTML form contains all the article properties, and — even if I just change one — the SQL that results after I press Submit rewrites ALL the fields with what it receives in the request.

This has always made me just a little nervous because is assumes that the request is perfectly accurate — that it accurately represents what we want the object to become. But is this always the case?


Comments

by Kippy,   July 24, 2004 1:31 AM  

I did this very thing, I just had hidden field with MD5's for each string, when it got back to the server, I rechecked the MD5's and updated only the strings that changed (via dynamtic SQL). MD5's are not perfect (1 in 100,000,000), but good enough for my needs. If you had to be 100% sure, just dup the string in a hidden field. Compare when it gets back to the server.


by Jonathan Hollin,   July 26, 2004 7:52 AM  

I tend to read the columns of the record to be changed into a hash (I use Perl), then use a simple "eq" comparison to identify the changes and prepare a dynamic "UPDATE" command before issuing that UPDATE to the DB. It's quick, efficient and very reliable.


by Deane,   July 26, 2004 12:46 PM  

Yes, that addresses the efficiency issue, but what about the problems caused by UI bugs? If you compare the existing object with what's in the request, you still don't find problems caused by a malfunctioning UI.


by Jonathan Hollin,   July 26, 2004 8:06 PM  

"What about the problems caused by UI bugs?"

With all due respect Deane, this shouldn't be an issue at all. The back-end application SHOULD have sufficient integrity checks, input validation, taint checking and error-handling to cope with any failing of the UI.

If this isn't the case, then you have bigger problems to consider: for example, the user (or script) that deliberately submits data that can compromise the database!



Add Comment


Want to advertise on this site? Contact FM.
Web Hosting Web hosting, dedicated servers and Web design services
Laser Toner Cartridges UK laser toner, toner cartridges, hp toner, lexmark toner, samsung toner, canon, toner, epson toner, oki toner, kyocera toner, xerox toner, remanufactured toner, compatible toner
Direct TV Deals Free 4 room direct tv deals. no equipment to buy. free fast professional direct tv installation. this is the best direct tv deal available anywhere.
SEO Article Learn from the experts with our SEO article.
rope light Shopping with birddog distributing, inc., gives you access to the lowest prices, the best customer service and the quickest delivery times possible.
Laptop AC Adapter We offer genuine factory direct replacement AC adapters.
Direct TV Best satellite TV deals.
Direct TV Deals Direct TV programming deals are varied and include packages containing from 50 channels up to over 250 channels.
8mm film to DVD Retain family memories with the only frame by frame digital restoration service in the United States for your 8mm film to DVD today
Rubber Stamp Shop for custom self-inking stamps, hand stamps, address stamps, label stamps, check endorsement stamps, check deposit stamps, date stamps, pre inks, pocket stamps, ink and much more!