Home > Ask the Software Quality Experts > Application Security Questions & Answers > Cookie poisoning prevention in ASP.NET
Ask The Software Quality Expert: Questions & Answers
EMAIL THIS

Cookie poisoning prevention in ASP.NET

Dan Cornell EXPERT RESPONSE FROM: Dan Cornell

Pose a Question
Other Software Quality Categories
Meet all Software Quality Experts
Become an Expert for this site


Software quality news and advice
Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


>
QUESTION POSED ON: 14 August 2006
What's the best way to avoid cookie poisoning in ASP.NET?

>
EXPERT RESPONSE
Developers should take a three-step approach to avoid cookie poisoning:

  1. Do not store sensitive information in cookies
  2. If sensitive information must be stored in cookies, make it extremely difficult for a user to successfully modify it
  3. Validate all cookie values to ensure that they are well-formed and correct

First of all, cookies are communicated as part of the HTTP header traffic being passed back and forth between the Web server and the Web browser. This means there is no special status afforded to cookies that guarantees their values won't be changed in the time period between when the Web application sets them and when they are returned by the browser. Cookies are just "bits on the wire" and malicious users with a Web proxy tool are able to control the existence and value of cookies.

For this reason, sensitive information should not be stored in cookies and security-relevant decisions in code should never be made based on the values of cookies. If a Web application uses few or no cookies, and if these cookie values are only used for non-sensitive decision making then the impact of modified cookies will be decreased or eliminated.

If sensitive information must be stored in cookie values, this information should be encrypted using an industry-standard, well-tested algorithm such as AES. By encrypting the data, if a malicious user attempts to modify the value, the decryption process will fail.

Application security and input validation:
Discover the power of .NET's code access security

The importance of input validation

Input Validation attacks -- Hacking Exposed Web Applications

If an application does use cookies to store information, it is crucial to treat these cookies like any other untrusted application input and positively validate them. If a cookie is used to store an integer value then the application must parse it to be sure it is a valid integer. If that integer must be within a given range, then the application must validate this as well. And so on. Also note: validating that a value is good is much more secure than checking for known "bad" values. If an application only checks for known "bad" values then an attacker who can craft a new, unanticipated "bad" value will have rendered the validation worthless.

Unfortunately, the ASP.NET platform does not really provide any platform-specific tools to help foil cookie poisoning attacks. The ASP.NET validation framework - very useful for validating Web control values - does not apply to cookies. However, the regular expression support in .NET can be a useful tool for validating expressions against positive criteria. As with most application security issues, it is up to the developer to make good design and coding decisions. This is the root of any good input validation strategy.


Digg This!    StumbleUpon Toolbar StumbleUpon    Bookmark with Delicious Del.icio.us    Add to Google


RELATED CONTENT
Application Security
Top tools for testing Web application security
How to prevent HTTP response splitting
PCI DSS compliance: WAF, code review or both?
Application security careers have bright future
How to prevent anti-DNS pinning attacks
Open source application security testing tools
Java application security features and measures
Web application security testing basics
Password recovery with .NET 2.O using C#
Free load and performance testing tools

Building security into the SDLC (Software development life cycle)
How to prevent HTTP response splitting
Browser security a concern for website development
Web application security and the PCI DSS
PCI DSS compliance: Web application firewalls (WAFs)
PCI DSS compliance: The basics
PCI DSS compliance: Code review
PCI DSS compliance: WAF, code review or both?
Application security careers have bright future
Writing software requirements that address security issues
Software Security Engineering: A Guide for Project Managers -- Chapter 3, Requirements Engineering for Secure Software

Threat modeling
Web application security and the PCI DSS
The essentials of Web application threat modeling
How to implement security in Java EE and Java ME
Application security shouldn't involve duct tape, Band-Aids or bubble gum
Stop SQL injection attacks on applications
How to counter XSS attacks
Breaking the same origin barrier of JavaScript
Protection against "zero-minute" exploits
Denial of service and Ajax
CSRF attack vector with Ajax serialization

RELATED RESOURCES
2020software.com, trial software downloads for accounting software, ERP software, CRM software and business software systems
Search Bitpipe.com for the latest white papers and business webcasts
Whatis.com, the online computer dictionary



Search and Browse the Expert Answer Center
Search and browse more than 25,000 question and answer pairs from more than 250 TechTarget industry experts.
Browse our Expert Advice



Software Quality - Software Maintenance, Software Requirements, Software Standards
About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
SEARCH 
TechTarget provides enterprise IT professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective IT purchase decisions and managing their organizations' IT projects - with its network of technology-specific Web sites, events and magazines.

TechTarget Corporate Web Site  |  Media Kits  |  Reprints  |  Site Map




All Rights Reserved, Copyright 2006 - 2008, TechTarget | Read our Privacy Policy
  TechTarget - The IT Media ROI Experts