When building an application that uses a client-server model, storing sensitive information at client-, such as user credentials, on the client side may result in its unauthorized disclosure if an application the client is vulnerable to attacks that can compromise the information. For example, consider the use of a cookie for storing sensitive information such as user credentials. Cookies are set attack.
For web applications, the most common mitigation to this problem is to provide the client with a cookie and store the sensitive information on the server. Cookies are created by a web server, and are stored for a certain period of time on the client-side. All subsequent requests to the domain identified by the cookie are made to contain information that was saved in the cookie. If the web application is vulnerable to a . When the client re-connects to the server, it provides the cookie, which identifies the client to the server, and the server then provides the sensitive information.
Cookies do not protect sensitive information against cross-site scripting (XSS) vulnerability, an attacker may be able to read any unencrypted information contained in the cookie.attacks. An attacker who is able to obtain a cookie either through an XSS attack, or directly by attacking the client, can obtain the sensitive information from the server using the cookie. This risk is timeboxed if the server invalidates the session after a limited time has elapsed, such as 15 minutes.
A cookie is typically a short string. If it contains sensitive information, that information should be encrypted. Sensitive A partial list of sensitive information includes user names, passwords, credit card numbers, social security numbers, and any other personally identifiable information about the user. For more details about managing passwords, see see 13. Store passwords using a hash function. For more information about securing the memory that holds sensitive information, see 0201. Limit the lifetime of sensitive data.
...
However, the attempt to implement the remember-me functionality is insecure because sensitive information should not be stored at client-side without strong encryptionan attacker with access to the client machine can obtain this informationdirectly on the client. This code also violates 13. Store passwords using a hash function.
...
The server maintains a mapping table that contains between user name names and secure random string pairsstrings. When a user selects "Remember “Remember me," the ” the doPost() method checks whether the supplied cookie contains a valid user name and random string pair. If the mapping contains a matching pair, the server authenticates the user and forwards him or her to the welcome page. If not, the server returns an error to the client. If the user selects "Remember me" “Remember me” but the client fails to supply a valid cookie, the server requires the user to authenticate using his or her credentials. If the authentication is successful, the server issues a new cookie with remember-me characteristics.
This solution avoids session-fixation attacks by invalidating the current session and creating a new session. It also reduces the window during which an attacker could perform a session-hijacking attack by setting the session timeout to 1fifteen minutes between client accesses.
Applicability
Violation of this rule places Storing unencrypted sensitive information within cookies, making the information vulnerable to packet sniffing or XSS attacks.
...
on the client makes this information available to anyone who can attack the client.
Bibliography
...