asp.net - Making a secure login cookie -


i've read 1 of jeff's articles xss , got me thinking how better protect login cookies in home cooked authentication system.

basically this(note, configurable , set true):

     protected static string computeloginhash(string passwordhash){         stringbuilder sb=new stringbuilder();         sb.append(passwordhash);         if(cookieuseip){             sb.append(httpcontext.current.request.userhostaddress);         }         if(cookieusebase){             sb.append(httpcontext.current.request.mappath("/"));         }         if(cookieusebrowserinfo){             sb.append(httpcontext.current.request.useragent);         }         sb.append(sitename);         return computehash(sb.tostring());     } 

(note passwordhash made out of password, unique salt, , username).

ok, 1 of questionable things use useragent string. there harm in doing this? or browsers change useragent string under normal operation(as in, without being updated)? goal if attacker gets login cookie, them not able it. meet goal or overly cumbersome user? @ moment, info store in cookie plain text username.

first , foremost should never write own session handler. reinventing wheel , less secure.

if computeloginhash() producing cookie value big problem on hands. attacker can obtain username/password hash database , build cookie value passing hash function. allow attacker login without need cracking password. removing protection provided hashing passwords.

a cookie value must cryptographic nonce, value must expire (less day good.). added security enable http-only cookies helps thwart xss. set sts-header enforce https , in turn take care of owasp a9. also,don't forget session riding. there absolutely no point in checking user-agent because attacker controlled variable.


Comments

Popular posts from this blog

c# - How to set Z index when using WPF DrawingContext? -

razor - Is this a bug in WebMatrix PageData? -

visual c++ - Using relative values in array sorting ( asm ) -