Classic Web security Flaw (Invalid cookie setting)

Source: Internet
Author: User

1. Concept:
HTTP is a stateless protocol that responds to the server side and the client in a request/response manner. The request is not directly connected, so when you jump from one page to another, the information cannot be delivered, so the server has to make a mark and store the information in the browser. That is, a cookie is a method that is often used by servers to record state information by marking a customer.
Cookies can be used to store database information, personalize page settings, and help online pages to obtain and maintain customer-related information. It greatly expands the application capabilities based on the Web client/server.
2. In Web applications, cookies can easily become part of security issues. In a real-world scenario, the one thing that cookies are used to do most is to maintain the status of the server that is being authenticated. This retention can be either session-based or persistent. In either case, the service-side ticket (Ticket) contained in the authentication cookie can be very difficult to distinguish between a real user and a malicious attacker if the user's request with the ticket is a laxative. In real-world cases, the most common way to create cookies is through cross-site scripting vulnerabilities. An attacker could use a small piece of JavaScript code to steal an important cookie mark that represents the user's identity. The first secret to avoiding this problem is to do all that is possible and to add a httponly tag to your cookie.
The browser has a series of comparisons and screening when it chooses to send those local cookies to the service side of the request. The most important of these screening is the coincidence of domain and path. Domain-shaped cookies, such as. abc.com, are sent to all abc.com requests on port 80.
In a large web site, there are often many applications that live under different subdomains or paths. These apps can often have the ability to manipulate each other's app cookies because they share a domain name. In the actual design work, the most important security principle is: Minimize authorization. This means that you need to minimize the extent to which your cookie can be accessed.
Another attribute that is not commonly used in cookies is secure. When this property is enabled, the browser simply sends cookie content to the server in the HTTPS request. If there is a very sensitive business in the application, such as login or payment, you need to use HTTPS to ensure the security of the content transmission; second, after the user is successfully authorized, the client identity cookie obtained is not set to secure, so many will be taken from the non-HTTPS page, Thus creating an important identity laxative. So, in a Web site, if SSL is used, you need to carefully check the cookie value returned in the SSL request and whether the secure attribute is specified.
In addition, it is worth noting that some Web applications, in addition to the cookies generated in their own program code, often generate some cookies from other sources.
Almost every site can not be separated from the cookie, but the use of cookies seems simple, two very easy to be despised, the use of the cookie in the application of the code, almost only a small cost to obtain a huge security benefits.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.