SSL
Home > Ask the Security Experts > Information Security Threats Questions & Answers > What is the most secure way for application developers to manage cookies?
Ask The Security Expert: Questions & Answers
EMAIL THIS

What is the most secure way for application developers to manage cookies?

Ed Skoudis EXPERT RESPONSE FROM: Ed Skoudis

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


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


>
QUESTION POSED ON: 14 December 2007
How can the mishandling of cookie implementations leave such big security holes and vulnerabilities in Web sites?

>
EXPERT RESPONSE
Web sites use cookies to store information on a browser. Cookies hold data, such as user preferences and session tracking credentials, which the browser then presents to a Web site when the user accesses it again. If the Web site doesn't define and manage the cookies appropriately, however, this can lead to some significant security holes.

One possible threat is the disclosure of sensitive user information. Some cookies hold names and mailing address info; others have account numbers. Some cookies even contain passwords, a dangerous but not uncommon practice. When a user provides an ID and password at the beginning of a session, that application can set a session credential cookie back on the browser, which will present that cookie to the server at each browsing session's subsequent interaction. That way, the user doesn't have to authenticate again and again during the session. If a bad guy steals a cookie used for that purpose, however, the attacker can perform a "session-cloning attack," inserting that cookie into a browser and accessing the application as that victim user. Clearly, we need to make sure that our applications protect all sensitive cookies carefully.

To do so, Web application developers should minimize the information in cookies, making sure that they contain only data that the application absolutely must store on the browser.

Next, a Web application developer should make sure that cookies are marked as "secure," meaning that the browser will only pass that cookie over an SSL-encrypted connection using HTTPS. Then, even if the Web site operator inadvertently makes part of the application available via HTTP instead of HTTPS, that part of the application won't be able to accept cookies. Of course, such restrictions might break the application, depending on the functionality that relies on the cookies. Still, having the application break is often better than having cookies containing sensitive information sent across the Internet in clear text.

Next, application developers should mark the domain for which a cookie is valid, and they should mark it as narrowly as possible. Browsers will only pass cookies back to servers in the domain for which they are defined. Consider the example of a developer in an educational institution called MySchool, with a domain name of myschool.edu. The cookies for a school's Web application should not be defined as passable to every Web site on .edu. That would be a big risk, as every other school with an .edu domain would have a shot at collecting these cookies. Instead, the cookie should be limited to myschool.edu, at least. Or, the developer might want to further limit where they will be sent, writing the application so that it sets cookies just for server1.myschool.edu.

Further, the Web application should encrypt the cookie information before sending it to the browser. It should then decrypt the data at the server when it comes back. Don't just rely on SSL to encrypt the cookie. SSL protects the information while it is in transit, but not while it is sitting in the browser. Add another layer of encryption by having the server encrypt the cookie before sending it back to the browser. In the vast majority of applications, users don't need to see the contents of cookies. They are stored on the browser merely for future reference, and code running on the server can decrypt them.

Finally, Web developers should enable their code to expire cookies within a reasonable timeframe. For session-credential cookies, the timeframe maybe small, possibly only 10 minutes or so. After a few minutes of non-use of the application, the user will have to log in again. While re-prompting the user is a small nuisance, it significantly increases the security of the application.

More information:

  • See which hacker tools work in tandem over Wi-Fi to sniff out URLS and cookies.
  • Expert Joel Dubin explains why compromised Java scripts mean bad news for your cookie data.


  • Sound Off! -   Be the first to post a message to Sound Off!


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


    RELATED CONTENT
    Information Security Threats
    What are the dangers of cross-site request forgery attacks (CSRF)?
    Should social engineering tests be included in penetration testing?
    What kind of data is compromised during a Google hack?
    Best practices for using restriction policy whitelists
    Defining mobile device security concerns
    What security measures can be taken to stop crimeware kits?
    What software development best practices can prevent input validation attacks?
    Can 'herd intelligence' effectively stop malware?
    Is there a market for standalone antivirus products?
    Should keystroke loggers be used in enterprise investigations?

    Application Attacks (Buffer Overflows, Cross-Site Scripting)
    Tips for SQL injection protection
    Microsoft addresses XSS in Internet Explorer
    Internet Explorer open to spoofing, scripting attacks
    Software still plagued with security holes, researcher says
    Microsoft tools won't be quick fix for SQL injection attacks
    Microsoft identifies tools to address SQL injection attacks
    New defenses for automated SQL injection attacks
    Alarming SQL injection attacks
    Adobe Flash Player flaw previously patched, Symantec says
    Adobe zero day flaw being actively exploited in wild
    Application Attacks (Buffer Overflows, Cross-Site Scripting) Research

    SSL
    Product review: Array Networks SPX2000
    The Shortcut Guide to Extended Validation SSL Certificates
    How to test the security of personal details submitted to a website
    Should enterprises implement a mandatory iPhone VPN?
    Should iPhone email be sent without SSL encryption?
    How to secure an FTP connection
    Can Trojans and other malware exploit split-tunnel VPNs to infiltrate a network?
    What are the risks of connecting a Web service to an external system via SSL?
    Secure file copying with WinSCP
    Should an IT staff be concerned with a network's physical security?

    RELATED GLOSSARY TERMS
    Terms from Whatis.com − the technology online dictionary
    cache poisoning  (SearchSecurity.com)
    cyberterrorism  (SearchSecurity.com)
    dictionary attack  (SearchSecurity.com)
    directory harvest attack  (SearchSecurity.com)
    distributed denial-of-service attack  (SearchSecurity.com)
    JavaScript hijacking  (SearchSecurity.com)
    ping of death  (SearchSecurity.com)
    script kiddy  (SearchSecurity.com)
    stack smashing  (SearchSecurity.com)
    SYN flooding  (SearchSecurity.com)

    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

    TechTarget Security Media
    Information Security View this month\\'s issue and subscribe today.
    Information Security Decisions Apply online for free conference admission.
    SearchSecurity.com
    HomeNewsMagazineWebcastsWhite PapersLearningAdviceTopicsEventsAbout Us

    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    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 2003 - 2008, TechTarget | Read our Privacy Policy
      TechTarget - The IT Media ROI Experts