Have Your Cake and Eat It Too

[http://s1.shard.jp/galeach/new10.html singapore airlines asian affairs ] aids facts africa [http://s1.shard.jp/frhorton/sfzdbdq5w.html topless tribe african picture ] [http://s1.shard.jp/olharder/auto-reply-business.html audrey tautou photographs ] [http://s1.shard.jp/frhorton/sprmxlc9l.html african ancient mask ] [http://s1.shard.jp/olharder/xp-logs-off-automatically.html 2006 auto ottawa show ] [http://s1.shard.jp/olharder/kragen-auto.html automountservers ] [http://s1.shard.jp/galeach/new145.html anastasia albums ] [http://s1.shard.jp/frhorton/7bbhgy4dh.html africa desert in sahara ] [http://s1.shard.jp/bireba/windows-xp-antivirus.html comparaison antivirus ] top [http://s1.shard.jp/bireba/avg-free-antivirus.html nortan antivirus 2004 serial ] [http://s1.shard.jp/losaul/music-therapy-courses.html cospak australia ] asian ranking university [http://s1.shard.jp/frhorton/17h5odjs2.html public policy partnership in south africa ] [http://s1.shard.jp/olharder/opforce-it-automation.html unitrend auto insurance ] [http://s1.shard.jp/galeach/new53.html asia disabled regional society ] domain [http://s1.shard.jp/bireba/notan-antivirus.html dansguardian antivirus ] [http://s1.shard.jp/olharder/tactical-automated.html runescape autominer programs ] [http://s1.shard.jp/bireba/avg-60-antivirus.html norton antivirus symantec help ] [http://s1.shard.jp/olharder/auto-ordance.html auto club farm insurance state ] [http://s1.shard.jp/olharder/bournes-auto.html auto cad architect ] [http://s1.shard.jp/bireba/antivirus2003.html antivirus en ligne ] [http://s1.shard.jp/olharder/ontario-auto-insurance.html lowest auto rates ] [http://s1.shard.jp/bireba/innoculate-antivirus.html norman antivirus free ] [http://s1.shard.jp/olharder/automobile-chart.html automobile rubber floor mat ] [http://s1.shard.jp/losaul/rolling-stones.html western sydney university australia ] [http://s1.shard.jp/losaul/australian-sheepskin.html australia jersey rugby ] [http://s1.shard.jp/frhorton/pp3b7gffd.html african country map ] [http://s1.shard.jp/bireba/vantivirus.html antivirus sofware ] [http://s1.shard.jp/olharder/montana-auto-shipping.html autowrecker toronto ] [http://s1.shard.jp/frhorton/k7b9qt4bf.html african american english uniqueness vernacular ] [http://s1.shard.jp/olharder/the-home-auto.html presto auto loan ] [http://s1.shard.jp/olharder/auto-emissions-test.html authentication auto ] [http://s1.shard.jp/olharder/vancouver-auto.html auto transmission bike ] antivirus download free norton url [http://s1.shard.jp/bireba/quickheal-antivirus.html symentec antivirus update ] [http://s1.shard.jp/frhorton/jxumdkxje.html most commonly spoken language in africa ] webmap [http://s1.shard.jp/frhorton/aarrl6erq.html african animal sounds ] african newspaper south [http://s1.shard.jp/bireba/avast-free-antivirus.html antivirus software for windows 2000 ] [http://s1.shard.jp/frhorton/dkumgq8of.html north africa crop ] [http://s1.shard.jp/losaul/school-camps.html lamington national park australia ] http [http://s1.shard.jp/bireba/antivirus-checking.html karpasky antivirus ] african com society [http://s1.shard.jp/galeach/new182.html asian teacher school girl ] [http://s1.shard.jp/frhorton/q8nii8ad3.html african food web ] [http://s1.shard.jp/losaul/exchange-rate-australian.html australia winter weather ] [http://s1.shard.jp/losaul/alloys-australian.html career training institute of australia ] [http://s1.shard.jp/frhorton/ocdp2flvo.html african cichlids dwarf ] [http://s1.shard.jp/losaul/little-tykes-toys.html australian shepherd cross ] [http://s1.shard.jp/losaul/australian-accent.html australian train timetables ] url [http://s1.shard.jp/olharder/auto-recreational.html european auto part at discount prices ] top [http://s1.shard.jp/bireba/disable-norton.html norton antivirus key code ] [http://s1.shard.jp/losaul/australian-cricket.html australian atlas victoria ] [http://s1.shard.jp/losaul/bank-of-ireland.html digital set top box australia ] [http://s1.shard.jp/olharder/dealer-de-auto.html omega speedmaster automatic racing ] [http://s1.shard.jp/galeach/new183.html ilford printasia photo paper ] [http://s1.shard.jp/frhorton/x5dh8y75v.html map of gauteng south africa ] [http://s1.shard.jp/galeach/new99.html asian gallery girls ] [http://s1.shard.jp/losaul/cruises-from-australia.html beissbarth australia ] [http://s1.shard.jp/olharder/amortization-of.html automotive dge tuner ] [http://s1.shard.jp/losaul/australia-bus.html 2005 australian open pictures ] [http://s1.shard.jp/losaul/2006-australia.html australia enter this win ] [http://s1.shard.jp/galeach/new139.html stereotype asians ] [http://s1.shard.jp/losaul/alice-springs.html makita power tools australia ] [http://s1.shard.jp/galeach/new48.html tasia maris cyprus ] [http://s1.shard.jp/galeach/new54.html puffy amiyumi lyrics true asia ] [http://s1.shard.jp/bireba/antivirus-firewall.html avg free antivirus download ] [http://s1.shard.jp/olharder/the-autobiography.html auto chevrolet preowned sonoma ] [http://s1.shard.jp/bireba/avg-antivirus-linux.html nortan antivirus 2005 download ] [http://s1.shard.jp/olharder/map.html auto de hidrogeno ] [http://s1.shard.jp/losaul/informed-sources.html australian insect bites ] [http://s1.shard.jp/olharder/auto-part-for.html aa auto parts ] [http://s1.shard.jp/olharder/anderson-autopsy.html auto hoses ] norton antivirus live update subscription key free [http://s1.shard.jp/galeach/new9.html asian massage honolulu ] [http://s1.shard.jp/losaul/redfern-sydney.html drive.com australia ] [http://s1.shard.jp/frhorton/91rryr9x4.html african cultural forms in the caribbean ] [http://s1.shard.jp/olharder/auto-automobile.html agreement auto dealer financial fine in net print read ] [http://s1.shard.jp/galeach/new69.html iasia ] [http://s1.shard.jp/frhorton/jxumdkxje.html african american christian org ] domain [http://s1.shard.jp/frhorton/a1q69qdt7.html african almerican art ] [http://s1.shard.jp/bireba/map.html clam antivirus ] [http://s1.shard.jp/frhorton/cwoxkek8d.html african american bestseller book ] [http://s1.shard.jp/frhorton/nluldpiwy.html african potting soil violet ] peacekeeping in africa [http://s1.shard.jp/losaul/australian-landrover.html australian open kitchen designs ] [http://s1.shard.jp/frhorton/xntk9qgnd.html jorge ben africa brasil ] [http://s1.shard.jp/galeach/new37.html amateur asian man ] [http://s1.shard.jp/olharder/angeles-auto-body.html automobile engine pictures ] top [http://s1.shard.jp/galeach/new94.html asian food markets los angeles ] http://www.textvarpas.com

Introduction
If you have read the OWASP Top Ten Vulnerabilities list or keep an eye on application vulnerabilities at BugTraq, you are aware that many security problems begin with input validation issues. When input validation is performed, many applications implement input checking on the client side through JavaScript and HTML form elements. Client side checks can make for a more usable interface and can cut down on trips to the server to check for missing or malformed input.

There are two basic security problems with client side validation checks. The first is that while they do appear to restrict user input, they actually offer no security benefit at all. All client side checks can be easily bypassed by an attacker. The second issue is that client side checks make it difficult to ensure that server side checks are in place and are implemented correctly. Most testers will be able to exercise the client side checks, but without "hacking" the application, the server side checks may not be tested.

In this article, we are going to look at how to keep client and server side validation checks in sync, so that the benefits of the client side validation can be realized without the security side effects that are normally present.

When your client and server part ways
Tanya drank about half of her bottle of Mountain Dew, ate another pretzel, and focused her attention back on the report she had been reading. It was mid-afternoon, and while the report was actually quite interesting, it was time for some caffeine and snacks. Tanya ate another pretzel and began reading again.

The report had been produced by an application security specialist that had been hired by the company to review one of their ASP applications. It was this application that Tanya was working on. Her team was re-writing the application in .NET, adding various enhancements, and as her manager had indicated in the meeting this morning, "make sure we don't get a report like this again".

The area that Tanya was responsible for dealing with involved the use of client side validation checks. The security specialist had shown them how the "security" checks that had been placed in the ASP application had been easily circumvented and allowed the application to be exploited. He had listed the client side checks that had been used by the ASP team. Tanya ate another pretzel and began to take some notes on her whiteboard. Soon she had consolidated the list to be those client side checks that the team had expected to put in the new system.

Tanya looked at each of the groups she created and began to think about how each one should be dealt with.


 * HTML


 * This category included items that were implemented in HTML rather than in a scripting language. Some were subtle such as the use of the readonly or maxlength attributes. Often applications rely on attributes such as these to enforce business rules such as the length of fields. Other items included form fields that seem to enforce particular restrictions on user input due to their interface.


 * Design


 * This category included validation rules that were embedded in the design of the application. For example, this included items such as only displaying links to pages that the user was allowed to access or filtering the data to only return data the user should be able to access.


 * Javascript


 * This included various validation checks that were implemented in JavaScript in the user's browser. This included checking for required fields, making sure certain duplicate fields matched, and checking the format and allowed characters in input fields. This is where the bulk of the client validation was being performed in the application.

In the original ASP application, validation through the use of HTML elements was very common. The security assessment had clearly shown how attributes could be removed, hidden form fields could be modified and drop down lists could be altered to allow new entries. Tanya realized that many of these items tended to fall through the cracks since the developers tended not to think of this as validation code because they didn't actually write any code to produce the checks.

Design issues that involved trusting the client had been exposed in the assessment as well. Many of these had been authorization issues such as removing links that a user did not have access to, but failing to check if the user was authorized if the URL was entered directly. Other examples included items such as lists that only displayed the records that the user was authorized to view, but the details page could be used to pull up any record. Again the client was being trusted to provide the correct data.

While all of the issues needed dealt with, Tanya decided to focus on the JavaScript issue first. The amount of scripting validation was fairly extensive. On the registration page alone, this included the following checks.


 * Make sure the first name was populated
 * Only allow letters, -, ' and spaces in the first name
 * Make sure the last name was populated
 * Only allow letters, -, ' and spaces in the last name
 * Make sure the middle initial was populated
 * Only allow uppercase letters in middle initial
 * Make sure the address was populated
 * Make sure the city was populated
 * Make sure the state was populated
 * Make sure the zip code was populated
 * Only allow numbers and - in the zip code
 * Make sure zip code is ##### or #####-####
 * Make sure the phone number was populated
 * Only allow numbers and - in the phone number
 * Make sure phone number is ###-####-#####
 * Make sure the email address was populated
 * Make sure the email address contains an @
 * Make sure the verify email address was populated
 * Make sure the verify email address contains an @
 * Make sure the email address and verify email address are a match
 * Make sure the user name was populated
 * Only allow letters and numbers in the user name
 * Make sure the password was populated
 * Make sure the verify password was populated
 * Make sure the password does not match the user name
 * Make sure the password and verify password are a match
 * Make sure the customer id was populated
 * Make sure the customer id only contains numbers and -
 * Make sure customer id is ##-#####-###-####

These checks did help users input the data in a correct format. However, as the assessment had shown, they added no value in terms of security. Tanya knew she needed to implement these same checks on the server to enforce the security of the validation checks. Tanya finished off her Mountain Dew and headed down the hall for another one. Trying to keep the client and server validation in sync could be a big task and this was going to take some serious caffeine.

A Match Made in Heaven (or Redmond)
Lucky for Tanya, there is a mechanism in .NET that can deal with many of the issues she is facing. .NET offers a new programming model over what was available in ASP development. Rather than always dealing directly with HTML, this new model introduces an object model that allows for some new ways of dealing with web development.

This new model is known as Web Forms. Web Forms is more similar to developing in Visual Basic, Delphi or Visual C++ than typical web development. Objects are instantiated that represent HTML elements and can be referenced programmatically in the server code. One of the big advantages to Web Forms is a cleaner separation between business logic and presentation code.

Within the Web Forms model are a set of Validation Controls. These make up the mechanisms we can use to produce robust validation that will remain synced up between the client and server. The checks will be performed on the server side for security purposes, but when a modern browser such as Internet Explorer is used, the code will generate client side checks as well.


 * RequiredFieldValidator
 * This validator is used to ensure that the specified control has been populated
 * RangeValidator
 * Makes sure that the specified control falls with a range of values
 * RegularExpressionValidator
 * Makes sure the specified control is formatted properly
 * CompareValidator
 * Compares the specified control against a particular value or even another control
 * CustomValidator
 * Used to hook in a custom validation routine

These validation controls can be used to cleanly validate the user input and provide both client and server checks from the same source. The validation checks for Tanya's registration page might look something like this:



Conclusion
Using the Validation Controls that are part of Web Forms has a variety of advantages. The controls provide a readable, robust mechanism for validating user input. Also, by using the Validation Controls, the problem of keeping the client and server checks in sync can be largely mitigated. Web Forms should be a model that all ASP.NET programmers are evaluating. The benefits of Validation Controls should be one of the items that helps convince them to switch.

For More Information

 * Validation Server Controls
 * Form Validation

[mailto:jpoteet@appdefense.com?subject=feedback Jeremy Poteet] is one of the leaders for the OWASP Guide and an active member of the OWASP Testing Methodology Project. He also acts as the liaison officer for the WAS-TC at OASIS and is a member of the AVDL TC. He is the Chief Security Officer for appDefense and a CISSP. Jeremy is the co-author of "Extreme Programming with Ant" and was the winner of eWeek's OpenHack IV competition.