I can see the verification token key generated by the MVC3 framework as plain text when I execute a server request without ssl.
This key is stored in a cookie called: _RequestVerificationToken_Lw __
In a mixed security environment, you can actually see this token in plain text sent to the server upon initial request to the non ssl website. This token is also static throughout the user's session. Then what's the point of using this token when it can easily be stolen by an attacker, because cookies get into plain text.
Should this cookie be marked as safe and should never be sent in plain text? Or at least regenerate for each request so that the protected information does not flow from the ssl channel?
I am talking about this block in the MVC 3 AntiForgeryWorker class
private string GetAntiForgeryTokenAndSetCookie(HttpContextBase httpContext, string salt, string domain, string path) { string forgeryTokenName = AntiForgeryData.GetAntiForgeryTokenName(httpContext.Request.ApplicationPath); AntiForgeryData token = (AntiForgeryData) null; HttpCookie httpCookie = httpContext.Request.Cookies[forgeryTokenName]; if (httpCookie != null) { try { token = this.Serializer.Deserialize(httpCookie.Value); } catch (HttpAntiForgeryException ex) { } } if (token == null) { token = AntiForgeryData.NewToken(); string str = this.Serializer.Serialize(token); HttpCookie cookie = new HttpCookie(forgeryTokenName, str) { HttpOnly = true, Domain = domain }; if (!string.IsNullOrEmpty(path)) cookie.Path = path; httpContext.Response.Cookies.Set(cookie);
Alwyn source share