Home > Ask the Security Experts > Expert Archive: Information Security Threats Questions & Answers > How should application developers manage cookies?
Ask The Security Expert: Questions & Answers
EMAIL THIS

How should application developers manage cookies?

Ed Skoudis, past SearchSecurity.com expert EXPERT RESPONSE FROM: Ed Skoudis, past SearchSecurity.com expert

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?

>
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.


  • BROWSE BY TAG
    Application and Platform Security,   Application Attacks (Buffer Overflows, Cross-Site Scripting),   SSL and TLS VPN Security,   Secure VPN Setup and Configuration,   Enterprise Network Security,   Expert Archive: Information Security Threats,   VIEW ALL TAGS

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



    RELATED CONTENT
    Application Attacks (Buffer Overflows, Cross-Site Scripting)
    Adobe warns of critical update for Reader, Acrobat 9.1.3
    9 Ways to Improve Application Security After an Incident
    Developers Need Help with Security Errors
    Buffer overflow tutorial: How to find vulnerabilities, prevent attacks
    SQL injection protection: A guide on how to prevent and stop attacks
    Experts rebuke programmers who use SQL injection as feature
    SANS: Application threats, website flaws pose biggest security threats
    Mozilla helps Adobe push out faster patches
    SSH key compromise shuts down Apache website
    IBM finds sharp spike in malicious content on trusted sites
    Application Attacks (Buffer Overflows, Cross-Site Scripting) Research

    SSL and TLS VPN Security
    Expert calls SSL protocol vulnerability a non issue
    How SSL-encrypted Web connections are intercepted
    Best Remote Access Products
    How to set up a split-tunnel VPN in Windows Vista
    Securing the intranet with remote access VPN security
    A short enterprise VPN deployment guide
    Creating an SSL connection between servers
    Can S/MIME, XML and IPsec operate in one protocol layer?
    Can secure USB devices prevent man-in-the middle attacks
    How to secure SSL following new man-in-the-middle SSL attacks

    Expert Archive: Information Security Threats
    The telltale signs of a network attack
    Will Google Chrome enhance overall browser security?
    Are there antivirus suites that pick up more than just run-of-the-mill viruses?
    What tools can a hacker use to crack a laptop password?
    Are social networking sites an easy target for malicious hackers?
    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

    RELATED GLOSSARY TERMS
    Terms from Whatis.com − the technology online dictionary
    buffer overflow  (SearchSecurity.com)
    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)
    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



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

    About Us  |  Contact Us  |  For Advertisers  |  For Business Partners  |  Site Index  |  RSS
    TechTarget provides technology professionals with the information they need to perform their jobs - from developing strategy, to making cost-effective purchase decisions and managing their organizations' technology projects - with its network of technology-specific websites, events and online magazines.

    TechTarget Corporate Web Site  |  Media Kits  |  Site Map




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