<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Adedov</id>
		<title>OWASP - User contributions [en]</title>
		<link rel="self" type="application/atom+xml" href="https://wiki.owasp.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=Adedov"/>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php/Special:Contributions/Adedov"/>
		<updated>2026-04-25T11:44:35Z</updated>
		<subtitle>User contributions</subtitle>
		<generator>MediaWiki 1.27.2</generator>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=236059</id>
		<title>Slow Down Online Guessing Attacks with Device Cookies</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=236059"/>
				<updated>2017-12-06T07:30:33Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: Clarify algorithm&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
Device cookies as additional authenticator for users devices have been discussed and used in practice for some time already. For example, it was discussed by Marc Heuse at [http://video.adm.ntnu.no/serier/5493ea75d5589 PasswordsCon 14]. Marc speculates on various techniques for blocking online attacks and comes to notion of &amp;quot;device cookie&amp;quot; as good protection alternative (see his [http://video.adm.ntnu.no/pres/549401c165887 talk] on Hydra at PasswordsCon 14, specifically from 32:50). As well as Alec Muffett at the same conference mentions &amp;quot;datr cookie&amp;quot; from Facebook (look from 10:15 of his [http://video.adm.ntnu.no/pres/54b660049af94 talk]). &lt;br /&gt;
&lt;br /&gt;
The main idea behind the protocol is to issue a special “device” cookie to every client (browser) when it is used to successfully authenticate a user in a system. The device cookie can be used to:&lt;br /&gt;
* Distinguish between known/trusted and unknown/untrusted clients&lt;br /&gt;
* Establish universal temporary lockouts for all untrusted clients&lt;br /&gt;
* Lockout trusted clients individually.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Why?=&lt;br /&gt;
There are few well-known ways to [[Blocking_Brute_Force_Attacks|deal with online attacks]]:&lt;br /&gt;
* Temporary account lockout&lt;br /&gt;
* Use CAPTCHA to slow down attacker&lt;br /&gt;
&lt;br /&gt;
Other tricks, like producing confusing answers for attacker are more like “security by obscurity” and cannot be used as first-class protection mechanism.&lt;br /&gt;
&lt;br /&gt;
Temporary account lockout after several failed attempts is too simple of a target for DoS attacks against legitimate users. There is variation of this method that locks out pair of account/IP. It is better in regarding to DoS issues but have security downsides:&lt;br /&gt;
* Attacks from botnets can be effective&lt;br /&gt;
* Attacks through proxies can be effective&lt;br /&gt;
&lt;br /&gt;
Moreover, it is not so trivial to implement account/IP lockout. Consider multiple proxies with chaining addresses in “X-Forwarded-For” header or IPv6.&lt;br /&gt;
&lt;br /&gt;
The method described in this writing may be viewed as variant of account/IP blocking. But it proposes to use a browser cookie instead of an IP address. Thus it may be more predictable from security perspective and easier to implement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Protocol=&lt;br /&gt;
Protocol parameters:&lt;br /&gt;
* T - time period&lt;br /&gt;
* N - max number of authentication attempts allowed during ''T'' &lt;br /&gt;
&lt;br /&gt;
The sign ∎ hereafter states for end of algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Entry point for authentication request'''&lt;br /&gt;
&lt;br /&gt;
:1. if the incoming request contains a device cookie:&lt;br /&gt;
:: a. ''validate device cookie''&lt;br /&gt;
:: b. if device cookie is not valid then proceed to step 2.&lt;br /&gt;
:: c. if the device cookie is in the lockout list&lt;br /&gt;
::: reject authentication attempt∎&lt;br /&gt;
:: d. else&lt;br /&gt;
::: ''authenticate user''∎&lt;br /&gt;
:2. if authentication from untrusted clients is locked out for the specific user&lt;br /&gt;
:: reject authentication attempt∎&lt;br /&gt;
:3. else&lt;br /&gt;
:: ''authenticate user''∎&lt;br /&gt;
&lt;br /&gt;
'''Authenticate user'''&lt;br /&gt;
# check user credentials&lt;br /&gt;
# if credentials are valid&lt;br /&gt;
#: a. ''issue new device cookie to user’s client''&lt;br /&gt;
#: b. proceed with authenticated user&lt;br /&gt;
# else&lt;br /&gt;
#: a. ''register failed authentication attempt''&lt;br /&gt;
#: b. finish with failed user’s authentication&lt;br /&gt;
&lt;br /&gt;
'''Register failed authentication attempt'''&lt;br /&gt;
# register a failed authentication attempt with following information: { user, time, device cookie (if present) }.&lt;br /&gt;
# depending on whether a valid device cookie is present in the request, count the number of failed authentication attempts within period ''T'' either for&lt;br /&gt;
#: a. all untrusted clients&lt;br /&gt;
#: '''or'''&lt;br /&gt;
#: b. a specific device cookie&lt;br /&gt;
# if number of failed attempts within period ''T'' &amp;gt; ''N''&lt;br /&gt;
#: a. if a valid device cookie is presented&lt;br /&gt;
#:: put the device cookie into the lockout list for device cookies until now+''T''&lt;br /&gt;
#: b. else&lt;br /&gt;
#:: lockout all authentication attempts for a specific user from all untrusted clients until now+''T''&lt;br /&gt;
&lt;br /&gt;
'''Issue new device cookie to user’s client'''&lt;br /&gt;
Issue a browser cookie with a value like “LOGIN,NONCE,SIGNATURE”, where&lt;br /&gt;
* LOGIN - user’s login name (or internal ID) corresponding to an authenticated user&lt;br /&gt;
* NONCE - nonce of sufficient length or random value from CSRNG source &lt;br /&gt;
* SIGNATURE - HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
* secret-key - server’s secret cryptographic key.&lt;br /&gt;
&lt;br /&gt;
'''Validate device cookie'''&lt;br /&gt;
# Validate that the device cookie is formatted as described above&lt;br /&gt;
# Validate that SIGNATURE == HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
# Validate that LOGIN represents the user who is actually trying to authenticate&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
* Putting the device cookie in a lockout list has the same effect as if the client had no device cookie. So clients with device cookies are potentially allowed to make ''N'' * 2 failed authentication attempts before actual lockout.&lt;br /&gt;
* Issuing a new device cookie after each successful authentication allows us to avoid making decisions in situations like - “Should the system block a device cookie if there were registered ''N''-1 failed attempts, then one successful authentication, and then again 1 failed attempt? All within period ''T''.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Implementation Tips=&lt;br /&gt;
It is good idea to use standard format for device cookies. So, if the size of a cookie is not an issue, it is recommended to use [https://jwt.io/ JWT].&lt;br /&gt;
&lt;br /&gt;
The following standard [https://tools.ietf.org/html/rfc7519#page-9 claims] can be used:&lt;br /&gt;
* '''sub''' : LOGIN&lt;br /&gt;
* '''jti''' : NONCE&lt;br /&gt;
&lt;br /&gt;
'''Important''': If you already use JWT for storing session tokens or other security stuff make sure you cannot confuse device cookies with other types of tokens. There are two possible ways to mitigate this threat:&lt;br /&gt;
# Use different signature / encryption keys for different token types&lt;br /&gt;
# Add '''aud''' claim into device cookie token that unambiguously refers to brute force protection subsystem (e.g. &amp;quot;aud&amp;quot; : &amp;quot;brute-force-protection&amp;quot; or &amp;quot;device cookie&amp;quot;).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Threat Analysis=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:20%&amp;quot; | Threat&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Threat details&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Mitigation&lt;br /&gt;
|-&lt;br /&gt;
| Online attack against one user&lt;br /&gt;
| Attacker performs a guessing attack against a specific account from an untrusted client(s).&lt;br /&gt;
| As long as the lockout for untrusted clients blocks authN attempts for a specific user from all untrusted clients, the number of guesses is restricted with (''N/T'')*24h per day.&lt;br /&gt;
&lt;br /&gt;
E.g. for ''N'' = 10 and ''T'' = 1h, any attacker will be limited with 240 attempts per day per user or 87600 attempts per user/year regardless of how large the botnet in his possession is.&lt;br /&gt;
&lt;br /&gt;
If there is a [http://password-policy-testing.wikidot.com/results#toc5 good password policy] in place that limits minimum number attempts to [http://research.microsoft.com/pubs/227130/WhatsaSysadminToDo.pdf 10&amp;lt;sup&amp;gt;6&amp;lt;/sup&amp;gt;] then the targeted attack will last (on average) 5 years.&lt;br /&gt;
|-&lt;br /&gt;
| Online attack using stolen device cookies&lt;br /&gt;
| Attacker performs long-running guessing attack against specific account(s) from known clients.&lt;br /&gt;
&lt;br /&gt;
Using valid device cookies allows the attacker to scale attacks linearly, e.g. each device cookie adds extra ''N'' attempts per ''T'' for specific user.&lt;br /&gt;
| There may be two ways to steal device cookies:&lt;br /&gt;
* Using physical access to a known client&lt;br /&gt;
* Active attack against a remote client&lt;br /&gt;
&lt;br /&gt;
In both cases if the attacker can steal device cookies on a regular basis he may have enough power to steal not only device cookies but also session cookies or even passwords. However in our security model this attack is irrelevant if device cookies are adequately protected (use '''Secure''' and '''HttpOnly''' flags).&lt;br /&gt;
&lt;br /&gt;
'''Proposal''': Accidental access to one device cookie contributes little to attack speed. Applications may implement persistent lockout for certain device cookies to address such cases. E.g. permanently lockout a device cookie after ''N''*10 failed attempts.&lt;br /&gt;
|- style=&amp;quot;background-color:#f5e68d;&amp;quot; &lt;br /&gt;
| Online attack against multiple users&lt;br /&gt;
| Attacker performs guessing attack against a specific number of accounts from untrusted clients.&lt;br /&gt;
&lt;br /&gt;
Attacker may try the same password from a long list against many (all) accounts in a system without reaching ''N'' failed attempts per account during period ''T''.&lt;br /&gt;
| There is no specific mitigation for this threat in the protocol.&lt;br /&gt;
&lt;br /&gt;
Good password policy may be a sufficient countermeasure for such attacks.&lt;br /&gt;
&lt;br /&gt;
Additionally an application may temporarily require CAPTCHA solving for authentication from '''untrusted''' clients in case there are too many authentication attempts for different accounts during a specified period of time.&lt;br /&gt;
|-&lt;br /&gt;
| Spoof device cookie&lt;br /&gt;
| Attacker may try to forge a valid device cookie for any user in a system.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|-&lt;br /&gt;
| Tamper with existing device cookie&lt;br /&gt;
| Attacker may try to tamper with a device cookie valid for one user to make it suitable for another.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|-&lt;br /&gt;
| DoS for specific account &lt;br /&gt;
| Attackers may cause permanent lockout for all untrusted devices for a specific user. Thus the user may be blocked from loggging into the system as he would need to login from a '''new device''' or to login after '''cleaning up his browser cache'''.&lt;br /&gt;
|&lt;br /&gt;
Issue a valid device cookie after visiting password reset link (an actual password reset is not necessary). Thus, if the user demonstrates his possession of a personal email account then the system may trust a client to try entering his credentials.&lt;br /&gt;
|-&lt;br /&gt;
| DoS for specific account when client is used by different accounts&lt;br /&gt;
| There are situations when the same client is legitimately used to authenticate different users. For example, a family-shared PC or tablet. Thus, after successful authentication of one user another legitimate user will be treated as user of untrusted client and will be susceptible to a DoS attack.&lt;br /&gt;
| Cases where the same client is shared between legitimate users may be considered out of scope by default.&lt;br /&gt;
&lt;br /&gt;
If such cases are critical for application usability, it may deal with them by issuing device cookies with names that contain LOGIN and analyze them accordingly. &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:JSON_Web_Token_(JWT)_Cheat_Sheet_for_Java&amp;diff=230066</id>
		<title>Talk:JSON Web Token (JWT) Cheat Sheet for Java</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:JSON_Web_Token_(JWT)_Cheat_Sheet_for_Java&amp;diff=230066"/>
				<updated>2017-05-27T21:53:23Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: Question on document scope&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi!&lt;br /&gt;
&lt;br /&gt;
In fact, his project needs more specific scoping:&lt;br /&gt;
* Do you want create lib to facilitate using JWT instead of UI sessions in a secure way? [see http://cryto.net/~joepie91/blog/2016/06/13/stop-using-jwt-for-sessions/]&lt;br /&gt;
* Do you want to provide framework that protects developers from common JWT failures?&lt;br /&gt;
* Do you want do that on top of existing libraries?&lt;br /&gt;
* Why you want to limit this project to Java?&lt;br /&gt;
&lt;br /&gt;
--[[User:Adedov|Adedov]] ([[User talk:Adedov|talk]]) 16:53, 27 May 2017 (CDT)&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=220598</id>
		<title>Slow Down Online Guessing Attacks with Device Cookies</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=220598"/>
				<updated>2016-08-23T07:01:09Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
Device cookies as additional authenticator for users devices have been discussed and used in practice for some time already. For example, it was discussed by Marc Heuse at [http://video.adm.ntnu.no/serier/5493ea75d5589 PasswordsCon 14]. Marc speculates on various techniques for blocking online attacks and comes to notion of &amp;quot;device cookie&amp;quot; as good protection alternative (see his [http://video.adm.ntnu.no/pres/549401c165887 talk] on Hydra at PasswordsCon 14, specifically from 32:50). As well as Alec Muffett at the same conference mentions &amp;quot;datr cookie&amp;quot; from Facebook (look from 10:15 of his [http://video.adm.ntnu.no/pres/54b660049af94 talk]). &lt;br /&gt;
&lt;br /&gt;
The main idea behind the protocol is to issue a special “device” cookie to every client (browser) when it is used to successfully authenticate a user in a system. The device cookie can be used to:&lt;br /&gt;
* Distinguish between known/trusted and unknown/untrusted clients&lt;br /&gt;
* Establish universal temporary lockouts for all untrusted clients&lt;br /&gt;
* Lockout trusted clients individually.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Why?=&lt;br /&gt;
There are few well-known ways to [[Blocking_Brute_Force_Attacks|deal with online attacks]]:&lt;br /&gt;
* Temporary account lockout&lt;br /&gt;
* Use CAPTCHA to slow down attacker&lt;br /&gt;
&lt;br /&gt;
Other tricks, like producing confusing answers for attacker are more like “security by obscurity” and cannot be used as first-class protection mechanism.&lt;br /&gt;
&lt;br /&gt;
Temporary account lockout after several failed attempts is too simple of a target for DoS attacks against legitimate users. There is variation of this method that locks out pair of account/IP. It is better in regarding to DoS issues but have security downsides:&lt;br /&gt;
* Attacks from botnets can be effective&lt;br /&gt;
* Attacks through proxies can be effective&lt;br /&gt;
&lt;br /&gt;
Moreover, it is not so trivial to implement account/IP lockout. Consider multiple proxies with chaining addresses in “X-Forwarded-For” header or IPv6.&lt;br /&gt;
&lt;br /&gt;
The method described in this writing may be viewed as variant of account/IP blocking. But it proposes to use a browser cookie instead of an IP address. Thus it may be more predictable from security perspective and easier to implement.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Protocol=&lt;br /&gt;
Protocol parameters:&lt;br /&gt;
* T - time period&lt;br /&gt;
* N - max number of authentication attempts allowed during ''T'' &lt;br /&gt;
&lt;br /&gt;
The sign ∎ hereafter states for end of algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Entry point for authentication request'''&lt;br /&gt;
# if the incoming request contains a device cookie:&lt;br /&gt;
#: a. ''validate device cookie''&lt;br /&gt;
#: b. if the device cookie is valid and not in the lockout list&lt;br /&gt;
#:: ''authenticate user''∎&lt;br /&gt;
# if authentication from untrusted clients is locked out for the specific user&lt;br /&gt;
#: reject authentication attempt∎&lt;br /&gt;
# else&lt;br /&gt;
#: ''authenticate user''∎&lt;br /&gt;
&lt;br /&gt;
'''Authenticate user'''&lt;br /&gt;
# check user credentials&lt;br /&gt;
# if credentials are valid&lt;br /&gt;
#: a. ''issue new device cookie to user’s client''&lt;br /&gt;
#: b. proceed with authenticated user&lt;br /&gt;
# else&lt;br /&gt;
#: a. ''register failed authentication attempt''&lt;br /&gt;
#: b. finish with failed user’s authentication&lt;br /&gt;
&lt;br /&gt;
'''Register failed authentication attempt'''&lt;br /&gt;
# register a failed authentication attempt with following information: { user, time, device cookie (if present) }.&lt;br /&gt;
# depending on whether a valid device cookie is present in the request, count the number of failed authentication attempts within period ''T'' either for&lt;br /&gt;
#: a. all untrusted clients&lt;br /&gt;
#: '''or'''&lt;br /&gt;
#: b. a specific device cookie&lt;br /&gt;
# if number of failed attempts within period ''T'' &amp;gt; ''N''&lt;br /&gt;
#: a. if a valid device cookie is presented&lt;br /&gt;
#:: put the device cookie into the lockout list for device cookies until now+''T''&lt;br /&gt;
#: b. else&lt;br /&gt;
#:: lockout all authentication attempts for a specific user from all untrusted clients until now+''T''&lt;br /&gt;
&lt;br /&gt;
'''Issue new device cookie to user’s client'''&lt;br /&gt;
Issue a browser cookie with a value like “LOGIN,NONCE,SIGNATURE”, where&lt;br /&gt;
* LOGIN - user’s login name (or internal ID) corresponding to an authenticated user&lt;br /&gt;
* NONCE - nonce of sufficient length or random value from CSRNG source &lt;br /&gt;
* SIGNATURE - HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
* secret-key - server’s secret cryptographic key.&lt;br /&gt;
&lt;br /&gt;
'''Validate device cookie'''&lt;br /&gt;
# Validate that the device cookie is formatted as described above&lt;br /&gt;
# Validate that SIGNATURE == HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
# Validate that LOGIN represents the user who is actually trying to authenticate&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
* Putting the device cookie in a lockout list has the same effect as if the client had no device cookie. So clients with device cookies are potentially allowed to make ''N'' * 2 failed authentication attempts before actual lockout.&lt;br /&gt;
* Issuing a new device cookie after each successful authentication allows us to avoid making decisions in situations like - “Should the system block a device cookie if there were registered ''N''-1 failed attempts, then one successful authentication, and then again 1 failed attempt? All within period ''T''.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Implementation Tips=&lt;br /&gt;
It is good idea to use standard format for device cookies. So, if the size of a cookie is not an issue, it is recommended to use [https://jwt.io/ JWT].&lt;br /&gt;
&lt;br /&gt;
The following standard [https://tools.ietf.org/html/rfc7519#page-9 claims] can be used:&lt;br /&gt;
* '''sub''' : LOGIN&lt;br /&gt;
* '''jti''' : NONCE&lt;br /&gt;
&lt;br /&gt;
'''Important''': If you already use JWT for storing session tokens or other security stuff make sure you cannot confuse device cookies with other types of tokens. There are two possible ways to mitigate this threat:&lt;br /&gt;
# Use different signature / encryption keys for different token types&lt;br /&gt;
# Add '''aud''' claim into device cookie token that unambiguously refers to brute force protection subsystem (e.g. &amp;quot;aud&amp;quot; : &amp;quot;brute-force-protection&amp;quot; or &amp;quot;device cookie&amp;quot;).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Threat Analysis=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:20%&amp;quot; | Threat&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Threat details&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Mitigation&lt;br /&gt;
|-&lt;br /&gt;
| Online attack against one user&lt;br /&gt;
| Attacker performs a guessing attack against a specific account from an untrusted client(s).&lt;br /&gt;
| As long as the lockout for untrusted clients blocks authN attempts for a specific user from all untrusted clients, the number of guesses is restricted with (''N/T'')*24h per day.&lt;br /&gt;
&lt;br /&gt;
E.g. for ''N'' = 10 and ''T'' = 1h, any attacker will be limited with 240 attempts per day per user or 87600 attempts per user/year regardless of how large the botnet in his possession is.&lt;br /&gt;
&lt;br /&gt;
If there is a [http://password-policy-testing.wikidot.com/results#toc5 good password policy] in place that limits minimum number attempts to [http://research.microsoft.com/pubs/227130/WhatsaSysadminToDo.pdf 10&amp;lt;sup&amp;gt;6&amp;lt;/sup&amp;gt;] then the targeted attack will last (on average) 5 years.&lt;br /&gt;
|-&lt;br /&gt;
| Online attack using stolen device cookies&lt;br /&gt;
| Attacker performs long-running guessing attack against specific account(s) from known clients.&lt;br /&gt;
&lt;br /&gt;
Using valid device cookies allows the attacker to scale attacks linearly, e.g. each device cookie adds extra ''N'' attempts per ''T'' for specific user.&lt;br /&gt;
| There may be two ways to steal device cookies:&lt;br /&gt;
* Using physical access to a known client&lt;br /&gt;
* Active attack against a remote client&lt;br /&gt;
&lt;br /&gt;
In both cases if the attacker can steal device cookies on a regular basis he may have enough power to steal not only device cookies but also session cookies or even passwords. However in our security model this attack is irrelevant if device cookies are adequately protected (use '''Secure''' and '''HttpOnly''' flags).&lt;br /&gt;
&lt;br /&gt;
'''Proposal''': Accidental access to one device cookie contributes little to attack speed. Applications may implement persistent lockout for certain device cookies to address such cases. E.g. permanently lockout a device cookie after ''N''*10 failed attempts.&lt;br /&gt;
|- style=&amp;quot;background-color:#f5e68d;&amp;quot; &lt;br /&gt;
| Online attack against multiple users&lt;br /&gt;
| Attacker performs guessing attack against a specific number of accounts from untrusted clients.&lt;br /&gt;
&lt;br /&gt;
Attacker may try the same password from a long list against many (all) accounts in a system without reaching ''N'' failed attempts per account during period ''T''.&lt;br /&gt;
| There is no specific mitigation for this threat in the protocol.&lt;br /&gt;
&lt;br /&gt;
Good password policy may be a sufficient countermeasure for such attacks.&lt;br /&gt;
&lt;br /&gt;
Additionally an application may temporarily require CAPTCHA solving for authentication from '''untrusted''' clients in case there are too many authentication attempts for different accounts during a specified period of time.&lt;br /&gt;
|-&lt;br /&gt;
| Spoof device cookie&lt;br /&gt;
| Attacker may try to forge a valid device cookie for any user in a system.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|-&lt;br /&gt;
| Tamper with existing device cookie&lt;br /&gt;
| Attacker may try to tamper with a device cookie valid for one user to make it suitable for another.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|-&lt;br /&gt;
| DoS for specific account &lt;br /&gt;
| Attackers may cause permanent lockout for all untrusted devices for a specific user. Thus the user may be blocked from loggging into the system as he would need to login from a '''new device''' or to login after '''cleaning up his browser cache'''.&lt;br /&gt;
|&lt;br /&gt;
Issue a valid device cookie after visiting password reset link (an actual password reset is not necessary). Thus, if the user demonstrates his possession of a personal email account then the system may trust a client to try entering his credentials.&lt;br /&gt;
|-&lt;br /&gt;
| DoS for specific account when client is used by different accounts&lt;br /&gt;
| There are situations when the same client is legitimately used to authenticate different users. For example, a family-shared PC or tablet. Thus, after successful authentication of one user another legitimate user will be treated as user of untrusted client and will be susceptible to a DoS attack.&lt;br /&gt;
| Cases where the same client is shared between legitimate users may be considered out of scope by default.&lt;br /&gt;
&lt;br /&gt;
If such cases are critical for application usability, it may deal with them by issuing device cookies with names that contain LOGIN and analyze them accordingly. &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=220597</id>
		<title>Slow Down Online Guessing Attacks with Device Cookies</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=220597"/>
				<updated>2016-08-23T07:00:39Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: Implementation Tips&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
Device cookies as additional authenticator for users devices have been discussed and used in practice for some time already. For example, it was discussed by Marc Heuse at [http://video.adm.ntnu.no/serier/5493ea75d5589 PasswordsCon 14]. Marc speculates on various techniques for blocking online attacks and comes to notion of &amp;quot;device cookie&amp;quot; as good protection alternative (see his [http://video.adm.ntnu.no/pres/549401c165887 talk] on Hydra at PasswordsCon 14, specifically from 32:50). As well as Alec Muffett at the same conference mentions &amp;quot;datr cookie&amp;quot; from Facebook (look from 10:15 of his [http://video.adm.ntnu.no/pres/54b660049af94 talk]). &lt;br /&gt;
&lt;br /&gt;
The main idea behind the protocol is to issue a special “device” cookie to every client (browser) when it is used to successfully authenticate a user in a system. The device cookie can be used to:&lt;br /&gt;
* Distinguish between known/trusted and unknown/untrusted clients&lt;br /&gt;
* Establish universal temporary lockouts for all untrusted clients&lt;br /&gt;
* Lockout trusted clients individually.&lt;br /&gt;
&lt;br /&gt;
=Why?=&lt;br /&gt;
There are few well-known ways to [[Blocking_Brute_Force_Attacks|deal with online attacks]]:&lt;br /&gt;
* Temporary account lockout&lt;br /&gt;
* Use CAPTCHA to slow down attacker&lt;br /&gt;
&lt;br /&gt;
Other tricks, like producing confusing answers for attacker are more like “security by obscurity” and cannot be used as first-class protection mechanism.&lt;br /&gt;
&lt;br /&gt;
Temporary account lockout after several failed attempts is too simple of a target for DoS attacks against legitimate users. There is variation of this method that locks out pair of account/IP. It is better in regarding to DoS issues but have security downsides:&lt;br /&gt;
* Attacks from botnets can be effective&lt;br /&gt;
* Attacks through proxies can be effective&lt;br /&gt;
&lt;br /&gt;
Moreover, it is not so trivial to implement account/IP lockout. Consider multiple proxies with chaining addresses in “X-Forwarded-For” header or IPv6.&lt;br /&gt;
&lt;br /&gt;
The method described in this writing may be viewed as variant of account/IP blocking. But it proposes to use a browser cookie instead of an IP address. Thus it may be more predictable from security perspective and easier to implement.&lt;br /&gt;
&lt;br /&gt;
=Protocol=&lt;br /&gt;
Protocol parameters:&lt;br /&gt;
* T - time period&lt;br /&gt;
* N - max number of authentication attempts allowed during ''T'' &lt;br /&gt;
&lt;br /&gt;
The sign ∎ hereafter states for end of algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Entry point for authentication request'''&lt;br /&gt;
# if the incoming request contains a device cookie:&lt;br /&gt;
#: a. ''validate device cookie''&lt;br /&gt;
#: b. if the device cookie is valid and not in the lockout list&lt;br /&gt;
#:: ''authenticate user''∎&lt;br /&gt;
# if authentication from untrusted clients is locked out for the specific user&lt;br /&gt;
#: reject authentication attempt∎&lt;br /&gt;
# else&lt;br /&gt;
#: ''authenticate user''∎&lt;br /&gt;
&lt;br /&gt;
'''Authenticate user'''&lt;br /&gt;
# check user credentials&lt;br /&gt;
# if credentials are valid&lt;br /&gt;
#: a. ''issue new device cookie to user’s client''&lt;br /&gt;
#: b. proceed with authenticated user&lt;br /&gt;
# else&lt;br /&gt;
#: a. ''register failed authentication attempt''&lt;br /&gt;
#: b. finish with failed user’s authentication&lt;br /&gt;
&lt;br /&gt;
'''Register failed authentication attempt'''&lt;br /&gt;
# register a failed authentication attempt with following information: { user, time, device cookie (if present) }.&lt;br /&gt;
# depending on whether a valid device cookie is present in the request, count the number of failed authentication attempts within period ''T'' either for&lt;br /&gt;
#: a. all untrusted clients&lt;br /&gt;
#: '''or'''&lt;br /&gt;
#: b. a specific device cookie&lt;br /&gt;
# if number of failed attempts within period ''T'' &amp;gt; ''N''&lt;br /&gt;
#: a. if a valid device cookie is presented&lt;br /&gt;
#:: put the device cookie into the lockout list for device cookies until now+''T''&lt;br /&gt;
#: b. else&lt;br /&gt;
#:: lockout all authentication attempts for a specific user from all untrusted clients until now+''T''&lt;br /&gt;
&lt;br /&gt;
'''Issue new device cookie to user’s client'''&lt;br /&gt;
Issue a browser cookie with a value like “LOGIN,NONCE,SIGNATURE”, where&lt;br /&gt;
* LOGIN - user’s login name (or internal ID) corresponding to an authenticated user&lt;br /&gt;
* NONCE - nonce of sufficient length or random value from CSRNG source &lt;br /&gt;
* SIGNATURE - HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
* secret-key - server’s secret cryptographic key.&lt;br /&gt;
&lt;br /&gt;
'''Validate device cookie'''&lt;br /&gt;
# Validate that the device cookie is formatted as described above&lt;br /&gt;
# Validate that SIGNATURE == HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
# Validate that LOGIN represents the user who is actually trying to authenticate&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
* Putting the device cookie in a lockout list has the same effect as if the client had no device cookie. So clients with device cookies are potentially allowed to make ''N'' * 2 failed authentication attempts before actual lockout.&lt;br /&gt;
* Issuing a new device cookie after each successful authentication allows us to avoid making decisions in situations like - “Should the system block a device cookie if there were registered ''N''-1 failed attempts, then one successful authentication, and then again 1 failed attempt? All within period ''T''.”&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Implementation Tips=&lt;br /&gt;
It is good idea to use standard format for device cookies. So, if the size of a cookie is not an issue, it is recommended to use [https://jwt.io/ JWT].&lt;br /&gt;
&lt;br /&gt;
The following standard [https://tools.ietf.org/html/rfc7519#page-9 claims] can be used:&lt;br /&gt;
* '''sub''' : LOGIN&lt;br /&gt;
* '''jti''' : NONCE&lt;br /&gt;
&lt;br /&gt;
'''Important''': If you already use JWT for storing session tokens or other security stuff make sure you cannot confuse device cookies with other types of tokens. There are two possible ways to mitigate this threat:&lt;br /&gt;
# Use different signature / encryption keys for different token types&lt;br /&gt;
# Add '''aud''' claim into device cookie token that unambiguously refers to brute force protection subsystem (e.g. &amp;quot;aud&amp;quot; : &amp;quot;brute-force-protection&amp;quot; or &amp;quot;device cookie&amp;quot;).  &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
=Threat Analysis=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:20%&amp;quot; | Threat&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Threat details&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Mitigation&lt;br /&gt;
|-&lt;br /&gt;
| Online attack against one user&lt;br /&gt;
| Attacker performs a guessing attack against a specific account from an untrusted client(s).&lt;br /&gt;
| As long as the lockout for untrusted clients blocks authN attempts for a specific user from all untrusted clients, the number of guesses is restricted with (''N/T'')*24h per day.&lt;br /&gt;
&lt;br /&gt;
E.g. for ''N'' = 10 and ''T'' = 1h, any attacker will be limited with 240 attempts per day per user or 87600 attempts per user/year regardless of how large the botnet in his possession is.&lt;br /&gt;
&lt;br /&gt;
If there is a [http://password-policy-testing.wikidot.com/results#toc5 good password policy] in place that limits minimum number attempts to [http://research.microsoft.com/pubs/227130/WhatsaSysadminToDo.pdf 10&amp;lt;sup&amp;gt;6&amp;lt;/sup&amp;gt;] then the targeted attack will last (on average) 5 years.&lt;br /&gt;
|-&lt;br /&gt;
| Online attack using stolen device cookies&lt;br /&gt;
| Attacker performs long-running guessing attack against specific account(s) from known clients.&lt;br /&gt;
&lt;br /&gt;
Using valid device cookies allows the attacker to scale attacks linearly, e.g. each device cookie adds extra ''N'' attempts per ''T'' for specific user.&lt;br /&gt;
| There may be two ways to steal device cookies:&lt;br /&gt;
* Using physical access to a known client&lt;br /&gt;
* Active attack against a remote client&lt;br /&gt;
&lt;br /&gt;
In both cases if the attacker can steal device cookies on a regular basis he may have enough power to steal not only device cookies but also session cookies or even passwords. However in our security model this attack is irrelevant if device cookies are adequately protected (use '''Secure''' and '''HttpOnly''' flags).&lt;br /&gt;
&lt;br /&gt;
'''Proposal''': Accidental access to one device cookie contributes little to attack speed. Applications may implement persistent lockout for certain device cookies to address such cases. E.g. permanently lockout a device cookie after ''N''*10 failed attempts.&lt;br /&gt;
|- style=&amp;quot;background-color:#f5e68d;&amp;quot; &lt;br /&gt;
| Online attack against multiple users&lt;br /&gt;
| Attacker performs guessing attack against a specific number of accounts from untrusted clients.&lt;br /&gt;
&lt;br /&gt;
Attacker may try the same password from a long list against many (all) accounts in a system without reaching ''N'' failed attempts per account during period ''T''.&lt;br /&gt;
| There is no specific mitigation for this threat in the protocol.&lt;br /&gt;
&lt;br /&gt;
Good password policy may be a sufficient countermeasure for such attacks.&lt;br /&gt;
&lt;br /&gt;
Additionally an application may temporarily require CAPTCHA solving for authentication from '''untrusted''' clients in case there are too many authentication attempts for different accounts during a specified period of time.&lt;br /&gt;
|-&lt;br /&gt;
| Spoof device cookie&lt;br /&gt;
| Attacker may try to forge a valid device cookie for any user in a system.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|-&lt;br /&gt;
| Tamper with existing device cookie&lt;br /&gt;
| Attacker may try to tamper with a device cookie valid for one user to make it suitable for another.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|-&lt;br /&gt;
| DoS for specific account &lt;br /&gt;
| Attackers may cause permanent lockout for all untrusted devices for a specific user. Thus the user may be blocked from loggging into the system as he would need to login from a '''new device''' or to login after '''cleaning up his browser cache'''.&lt;br /&gt;
|&lt;br /&gt;
Issue a valid device cookie after visiting password reset link (an actual password reset is not necessary). Thus, if the user demonstrates his possession of a personal email account then the system may trust a client to try entering his credentials.&lt;br /&gt;
|-&lt;br /&gt;
| DoS for specific account when client is used by different accounts&lt;br /&gt;
| There are situations when the same client is legitimately used to authenticate different users. For example, a family-shared PC or tablet. Thus, after successful authentication of one user another legitimate user will be treated as user of untrusted client and will be susceptible to a DoS attack.&lt;br /&gt;
| Cases where the same client is shared between legitimate users may be considered out of scope by default.&lt;br /&gt;
&lt;br /&gt;
If such cases are critical for application usability, it may deal with them by issuing device cookies with names that contain LOGIN and analyze them accordingly. &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=220579</id>
		<title>Slow Down Online Guessing Attacks with Device Cookies</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=220579"/>
				<updated>2016-08-22T22:07:36Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: Change one threat status to &amp;quot;mitigated&amp;quot;.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;=Intro=&lt;br /&gt;
Device cookies as additional authenticator for users devices have been discussed and used in practice for some time already. For example, it was discussed by Marc Heuse at [http://video.adm.ntnu.no/serier/5493ea75d5589 PasswordsCon 14]. Marc speculates on various techniques for blocking online attacks and comes to notion of &amp;quot;device cookie&amp;quot; as good protection alternative (see his [http://video.adm.ntnu.no/pres/549401c165887 talk] on Hydra at PasswordsCon 14, specifically from 32:50). As well as Alec Muffett at the same conference mentions &amp;quot;datr cookie&amp;quot; from Facebook (look from 10:15 of his [http://video.adm.ntnu.no/pres/54b660049af94 talk]). &lt;br /&gt;
&lt;br /&gt;
The main idea behind the protocol is to issue a special “device” cookie to every client (browser) when it is used to successfully authenticate a user in a system. The device cookie can be used to:&lt;br /&gt;
* Distinguish between known/trusted and unknown/untrusted clients&lt;br /&gt;
* Establish universal temporary lockouts for all untrusted clients&lt;br /&gt;
* Lockout trusted clients individually.&lt;br /&gt;
&lt;br /&gt;
=Why?=&lt;br /&gt;
There are few well-known ways to [[Blocking_Brute_Force_Attacks|deal with online attacks]]:&lt;br /&gt;
* Temporary account lockout&lt;br /&gt;
* Use CAPTCHA to slow down attacker&lt;br /&gt;
&lt;br /&gt;
Other tricks, like producing confusing answers for attacker are more like “security by obscurity” and cannot be used as first-class protection mechanism.&lt;br /&gt;
&lt;br /&gt;
Temporary account lockout after several failed attempts is too simple of a target for DoS attacks against legitimate users. There is variation of this method that locks out pair of account/IP. It is better in regarding to DoS issues but have security downsides:&lt;br /&gt;
* Attacks from botnets can be effective&lt;br /&gt;
* Attacks through proxies can be effective&lt;br /&gt;
&lt;br /&gt;
Moreover, it is not so trivial to implement account/IP lockout. Consider multiple proxies with chaining addresses in “X-Forwarded-For” header or IPv6.&lt;br /&gt;
&lt;br /&gt;
The method described in this writing may be viewed as variant of account/IP blocking. But it proposes to use a browser cookie instead of an IP address. Thus it may be more predictable from security perspective and easier to implement.&lt;br /&gt;
&lt;br /&gt;
=Protocol=&lt;br /&gt;
Protocol parameters:&lt;br /&gt;
* T - time period&lt;br /&gt;
* N - max number of authentication attempts allowed during ''T'' &lt;br /&gt;
&lt;br /&gt;
The sign ∎ hereafter states for end of algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Entry point for authentication request'''&lt;br /&gt;
# if the incoming request contains a device cookie:&lt;br /&gt;
#: a. ''validate device cookie''&lt;br /&gt;
#: b. if the device cookie is valid and not in the lockout list&lt;br /&gt;
#:: ''authenticate user''∎&lt;br /&gt;
# if authentication from untrusted clients is locked out for the specific user&lt;br /&gt;
#: reject authentication attempt∎&lt;br /&gt;
# else&lt;br /&gt;
#: ''authenticate user''∎&lt;br /&gt;
&lt;br /&gt;
'''Authenticate user'''&lt;br /&gt;
# check user credentials&lt;br /&gt;
# if credentials are valid&lt;br /&gt;
#: a. ''issue new device cookie to user’s client''&lt;br /&gt;
#: b. proceed with authenticated user&lt;br /&gt;
# else&lt;br /&gt;
#: a. ''register failed authentication attempt''&lt;br /&gt;
#: b. finish with failed user’s authentication&lt;br /&gt;
&lt;br /&gt;
'''Register failed authentication attempt'''&lt;br /&gt;
# register a failed authentication attempt with following information: { user, time, device cookie (if present) }.&lt;br /&gt;
# depending on whether a valid device cookie is present in the request, count the number of failed authentication attempts within period ''T'' either for&lt;br /&gt;
#: a. all untrusted clients&lt;br /&gt;
#: '''or'''&lt;br /&gt;
#: b. a specific device cookie&lt;br /&gt;
# if number of failed attempts within period ''T'' &amp;gt; ''N''&lt;br /&gt;
#: a. if a valid device cookie is presented&lt;br /&gt;
#:: put the device cookie into the lockout list for device cookies until now+''T''&lt;br /&gt;
#: b. else&lt;br /&gt;
#:: lockout all authentication attempts for a specific user from all untrusted clients until now+''T''&lt;br /&gt;
&lt;br /&gt;
'''Issue new device cookie to user’s client'''&lt;br /&gt;
Issue a browser cookie with a value like “LOGIN,NONCE,SIGNATURE”, where&lt;br /&gt;
* LOGIN - user’s login name (or internal ID) corresponding to an authenticated user&lt;br /&gt;
* NONCE - nonce of sufficient length or random value from CSRNG source &lt;br /&gt;
* SIGNATURE - HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
* secret-key - server’s secret cryptographic key.&lt;br /&gt;
&lt;br /&gt;
'''Validate device cookie'''&lt;br /&gt;
# Validate that the device cookie is formatted as described above&lt;br /&gt;
# Validate that SIGNATURE == HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
# Validate that LOGIN represents the user who is actually trying to authenticate&lt;br /&gt;
&lt;br /&gt;
==Notes==&lt;br /&gt;
* Putting the device cookie in a lockout list has the same effect as if the client had no device cookie. So clients with device cookies are potentially allowed to make ''N'' * 2 failed authentication attempts before actual lockout.&lt;br /&gt;
* Issuing a new device cookie after each successful authentication allows us to avoid making decisions in situations like - “Should the system block a device cookie if there were registered ''N''-1 failed attempts, then one successful authentication, and then again 1 failed attempt? All within period ''T''.”&lt;br /&gt;
&lt;br /&gt;
=Threat Analysis=&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:20%&amp;quot; | Threat&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Threat details&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Mitigation&lt;br /&gt;
|-&lt;br /&gt;
| Online attack against one user&lt;br /&gt;
| Attacker performs a guessing attack against a specific account from an untrusted client(s).&lt;br /&gt;
| As long as the lockout for untrusted clients blocks authN attempts for a specific user from all untrusted clients, the number of guesses is restricted with (''N/T'')*24h per day.&lt;br /&gt;
&lt;br /&gt;
E.g. for ''N'' = 10 and ''T'' = 1h, any attacker will be limited with 240 attempts per day per user or 87600 attempts per user/year regardless of how large the botnet in his possession is.&lt;br /&gt;
&lt;br /&gt;
If there is a [http://password-policy-testing.wikidot.com/results#toc5 good password policy] in place that limits minimum number attempts to [http://research.microsoft.com/pubs/227130/WhatsaSysadminToDo.pdf 10&amp;lt;sup&amp;gt;6&amp;lt;/sup&amp;gt;] then the targeted attack will last (on average) 5 years.&lt;br /&gt;
|-&lt;br /&gt;
| Online attack using stolen device cookies&lt;br /&gt;
| Attacker performs long-running guessing attack against specific account(s) from known clients.&lt;br /&gt;
&lt;br /&gt;
Using valid device cookies allows the attacker to scale attacks linearly, e.g. each device cookie adds extra ''N'' attempts per ''T'' for specific user.&lt;br /&gt;
| There may be two ways to steal device cookies:&lt;br /&gt;
* Using physical access to a known client&lt;br /&gt;
* Active attack against a remote client&lt;br /&gt;
&lt;br /&gt;
In both cases if the attacker can steal device cookies on a regular basis he may have enough power to steal not only device cookies but also session cookies or even passwords. However in our security model this attack is irrelevant if device cookies are adequately protected (use '''Secure''' and '''HttpOnly''' flags).&lt;br /&gt;
&lt;br /&gt;
'''Proposal''': Accidental access to one device cookie contributes little to attack speed. Applications may implement persistent lockout for certain device cookies to address such cases. E.g. permanently lockout a device cookie after ''N''*10 failed attempts.&lt;br /&gt;
|- style=&amp;quot;background-color:#f5e68d;&amp;quot; &lt;br /&gt;
| Online attack against multiple users&lt;br /&gt;
| Attacker performs guessing attack against a specific number of accounts from untrusted clients.&lt;br /&gt;
&lt;br /&gt;
Attacker may try the same password from a long list against many (all) accounts in a system without reaching ''N'' failed attempts per account during period ''T''.&lt;br /&gt;
| There is no specific mitigation for this threat in the protocol.&lt;br /&gt;
&lt;br /&gt;
Good password policy may be a sufficient countermeasure for such attacks.&lt;br /&gt;
&lt;br /&gt;
Additionally an application may temporarily require CAPTCHA solving for authentication from '''untrusted''' clients in case there are too many authentication attempts for different accounts during a specified period of time.&lt;br /&gt;
|-&lt;br /&gt;
| Spoof device cookie&lt;br /&gt;
| Attacker may try to forge a valid device cookie for any user in a system.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|-&lt;br /&gt;
| Tamper with existing device cookie&lt;br /&gt;
| Attacker may try to tamper with a device cookie valid for one user to make it suitable for another.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|-&lt;br /&gt;
| DoS for specific account &lt;br /&gt;
| Attackers may cause permanent lockout for all untrusted devices for a specific user. Thus the user may be blocked from loggging into the system as he would need to login from a '''new device''' or to login after '''cleaning up his browser cache'''.&lt;br /&gt;
|&lt;br /&gt;
Issue a valid device cookie after visiting password reset link (an actual password reset is not necessary). Thus, if the user demonstrates his possession of a personal email account then the system may trust a client to try entering his credentials.&lt;br /&gt;
|-&lt;br /&gt;
| DoS for specific account when client is used by different accounts&lt;br /&gt;
| There are situations when the same client is legitimately used to authenticate different users. For example, a family-shared PC or tablet. Thus, after successful authentication of one user another legitimate user will be treated as user of untrusted client and will be susceptible to a DoS attack.&lt;br /&gt;
| Cases where the same client is shared between legitimate users may be considered out of scope by default.&lt;br /&gt;
&lt;br /&gt;
If such cases are critical for application usability, it may deal with them by issuing device cookies with names that contain LOGIN and analyze them accordingly. &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Password_policy_(Draft)&amp;diff=203667</id>
		<title>Password policy (Draft)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Password_policy_(Draft)&amp;diff=203667"/>
				<updated>2015-11-20T23:27:06Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: Add links section&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''This document is an attempt to write draft replacement for [[Password length &amp;amp; complexity]] page.'''&lt;br /&gt;
&lt;br /&gt;
==What Is Password Policy==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
==Threat Model==&lt;br /&gt;
There are three main threats against to user passwords:&lt;br /&gt;
* Online attacks&lt;br /&gt;
* Offline attacks&lt;br /&gt;
* Password leaks&lt;br /&gt;
&lt;br /&gt;
===Online Attacks===&lt;br /&gt;
In this mode attacker tries to guess users passwords by sending candidate passwords directly to attacking service.&lt;br /&gt;
&lt;br /&gt;
The speed and feasibility of online attacks are defined by security mechanisms implemented by application such as rate limiting authentication requests per user, IP address, etc. As well as by overall performance of network infrastructure and application.&lt;br /&gt;
&lt;br /&gt;
===Offline Attacks===&lt;br /&gt;
If attacker have got a passwords file or a database dump or a captured traffic (e.g. Kerberos ticket or WiFi frames) and passwords are protected with some kind of crypto then attacker may mount so called offline attack.&lt;br /&gt;
&lt;br /&gt;
The speed of offline attack is defined by resources available to attacker as well as robustness of methods used to protect user's passwords. In many cases the difference is speed between online and offline mode is order of magnitude in favour of offline mode.&lt;br /&gt;
&lt;br /&gt;
===Depth vs. Breadth===&lt;br /&gt;
In context of password policy discussions it might be useful to distinguish ''targeted'' and ''untargeted'' attacks by attacker's primary goal:&lt;br /&gt;
; Targeted (depth-first) : Attacker needs to guess password of a specific user.&lt;br /&gt;
; Untargeted (breadth-first) : Attacker would be satisfied to find out any password of any account or want to collect as much valid credentials as possible. &lt;br /&gt;
&lt;br /&gt;
===Password Leaks===&lt;br /&gt;
There are plenty of threats for passwords confidentiality that have no relation to guessing techniques at all. Examples are:&lt;br /&gt;
* Phishing and social engineering attacks;&lt;br /&gt;
* Malware installed on users devices;&lt;br /&gt;
* Capturing passwords during transmissions over insecure channels;&lt;br /&gt;
* Etc.&lt;br /&gt;
&lt;br /&gt;
===Password Policy as a Mitigation to Passwords Threats===&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
==Links==&lt;br /&gt;
# [http://openwall.info/wiki/passwdqc/policy Password strength policy considerations.] by Solar Designer&lt;br /&gt;
# [http://research.microsoft.com/apps/pubs/?id=227130 An Administrator’s Guide to Internet Password Research. Dinei Florencio ˆ, Cormac Herley, and Paul C. van Oorschot. 2014]&lt;br /&gt;
# [http://research.microsoft.com/apps/pubs/?id=250408 Passwords and the Evolution of Imperfect Authentication.  Joe Bonneau, Cormac Herley, Paul C. van Oorschot, and Frank Stajano. 2015]&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Password_policy_(Draft)&amp;diff=203664</id>
		<title>Password policy (Draft)</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Password_policy_(Draft)&amp;diff=203664"/>
				<updated>2015-11-20T23:17:47Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: Created page with &amp;quot;'''This document is an attempt to write draft replacement for Password length &amp;amp; complexity page.'''  ==What Is Password Policy== TODO  ==Threat Model== There are three mai...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;'''This document is an attempt to write draft replacement for [[Password length &amp;amp; complexity]] page.'''&lt;br /&gt;
&lt;br /&gt;
==What Is Password Policy==&lt;br /&gt;
TODO&lt;br /&gt;
&lt;br /&gt;
==Threat Model==&lt;br /&gt;
There are three main threats against to user passwords:&lt;br /&gt;
* Online attacks&lt;br /&gt;
* Offline attacks&lt;br /&gt;
* Password leaks&lt;br /&gt;
&lt;br /&gt;
===Online Attacks===&lt;br /&gt;
In this mode attacker tries to guess users passwords by sending candidate passwords directly to attacking service.&lt;br /&gt;
&lt;br /&gt;
The speed and feasibility of online attacks are defined by security mechanisms implemented by application such as rate limiting authentication requests per user, IP address, etc. As well as by overall performance of network infrastructure and application.&lt;br /&gt;
&lt;br /&gt;
===Offline Attacks===&lt;br /&gt;
If attacker have got a passwords file or a database dump or a captured traffic (e.g. Kerberos ticket or WiFi frames) and passwords are protected with some kind of crypto then attacker may mount so called offline attack.&lt;br /&gt;
&lt;br /&gt;
The speed of offline attack is defined by resources available to attacker as well as robustness of methods used to protect user's passwords. In many cases the difference is speed between online and offline mode is order of magnitude in favour of offline mode.&lt;br /&gt;
&lt;br /&gt;
===Depth vs. Breadth===&lt;br /&gt;
In context of password policy discussions it might be useful to distinguish ''targeted'' and ''untargeted'' attacks by attacker's primary goal:&lt;br /&gt;
; Targeted (depth-first) : Attacker needs to guess password of a specific user.&lt;br /&gt;
; Untargeted (breadth-first) : Attacker would be satisfied to find out any password of any account or want to collect as much valid credentials as possible. &lt;br /&gt;
&lt;br /&gt;
===Password Leaks===&lt;br /&gt;
There are plenty of threats for passwords confidentiality that have no relation to guessing techniques at all. Examples are:&lt;br /&gt;
* Phishing and social engineering attacks;&lt;br /&gt;
* Malware installed on users devices;&lt;br /&gt;
* Capturing passwords during transmissions over insecure channels;&lt;br /&gt;
* Etc.&lt;br /&gt;
&lt;br /&gt;
===Password Policy as a Mitigation to Passwords Threats===&lt;br /&gt;
TODO&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Adedov&amp;diff=203663</id>
		<title>User:Adedov</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Adedov&amp;diff=203663"/>
				<updated>2015-11-20T23:15:47Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I was born in central Siberia, Russia in 1978. I lived in various places at Siberia till 2010 then moved to Moscow.&lt;br /&gt;
&lt;br /&gt;
I am software developer at Parallels [http://cp.parallels.com] since 2005. In 2012 started working on product security. Also an open source developer and occasional researcher.&lt;br /&gt;
&lt;br /&gt;
Personal projects&lt;br /&gt;
* XML-RPC library for C++, [http://libiqxmlrpc.wikidot.com Libiqxmlrpc]&lt;br /&gt;
* [http://password-policy-testing.wikidot.com/ Password Policy Testing Framework]&lt;br /&gt;
&lt;br /&gt;
Twitter: @brutemorse&lt;br /&gt;
&lt;br /&gt;
Github: [https://github.com/adedov adedov]&lt;br /&gt;
&lt;br /&gt;
==Drafts==&lt;br /&gt;
* [[Password policy (Draft)]]&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Adedov&amp;diff=203656</id>
		<title>User:Adedov</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Adedov&amp;diff=203656"/>
				<updated>2015-11-20T22:39:14Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I was born in central Siberia, Russia in 1978. I lived in various places at Siberia till 2010 then moved to Moscow.&lt;br /&gt;
&lt;br /&gt;
I am software developer at Parallels [http://cp.parallels.com] since 2005. In 2012 started working on product security. Also an open source developer and occasional researcher.&lt;br /&gt;
&lt;br /&gt;
Personal projects&lt;br /&gt;
* XML-RPC library for C++, [http://libiqxmlrpc.wikidot.com Libiqxmlrpc]&lt;br /&gt;
* [http://password-policy-testing.wikidot.com/ Password Policy Testing Framework]&lt;br /&gt;
&lt;br /&gt;
Twitter: @brutemorse&lt;br /&gt;
&lt;br /&gt;
Github: [https://github.com/adedov adedov]&lt;br /&gt;
&lt;br /&gt;
==Drafts==&lt;br /&gt;
* [[User:Adedov/Password policy]]&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Password_length_%26_complexity&amp;diff=203385</id>
		<title>Talk:Password length &amp; complexity</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Password_length_%26_complexity&amp;diff=203385"/>
				<updated>2015-11-14T12:05:39Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Several proposals for addition into article:&lt;br /&gt;
# Add threat model and a role of password complexity as possible mitigation:&lt;br /&gt;
#* Online guessing attacks&lt;br /&gt;
#* Offline guessing attacks&lt;br /&gt;
#* Breadth vs. targeted attacks&lt;br /&gt;
#* Relation between password storage and effectiveness of password policy[1]&lt;br /&gt;
# Psychology acceptance issues&lt;br /&gt;
#* If account is important for a system (e.g. staff vs. customer accounts, privileged vs. unprivileged, etc).&lt;br /&gt;
#* If service is important for a user (e.g. personal backup vs. bulletin board vs. movie ranking site vs. banking service, etc).&lt;br /&gt;
#* Theoretical limit for memorable passwords entropy per user/site, per user/all sites he use.&lt;br /&gt;
#* Password entering usability concerns (mobiles vs. desktop).&lt;br /&gt;
#* Presence of multiple factors of AuthN.&lt;br /&gt;
# Password policy implementations considerations&lt;br /&gt;
#* Preference length over &amp;quot;complexity&amp;quot; [link needed]&lt;br /&gt;
#* Gamification is a friend [link needed]&lt;br /&gt;
#* Heuristic-based over formal polices [2,3]&lt;br /&gt;
#* Known password blacklists&lt;br /&gt;
# List of approved password polices&lt;br /&gt;
#* Strong polices: passwdqc, zxcvbn&lt;br /&gt;
#* Liberal polices?&lt;br /&gt;
#* libpathwell?&lt;br /&gt;
# Other aspects of password policy&lt;br /&gt;
#* Password expiration (pros and cons) [links needed]&lt;br /&gt;
#* Password history (pros and cons)&lt;br /&gt;
#* Client-side vs server-side&lt;br /&gt;
# Password generation&lt;br /&gt;
#* Link to entropy of random passwords on Wikipedia&lt;br /&gt;
#* Pronounceable passwords&lt;br /&gt;
# Something else?&lt;br /&gt;
&lt;br /&gt;
Btw, Wikipedia's [https://en.wikipedia.org/wiki/Password_strength Password Strength] page is good enough but have no direct recommendations for developers. It is rather good compilation of different opinions and researches. At least links are very useful.&lt;br /&gt;
&lt;br /&gt;
Materials:&lt;br /&gt;
&lt;br /&gt;
* [1] [http://research.microsoft.com/apps/pubs/?id=227130 An Administrator’s Guide to Internet Password Research] by Dinei Florencio ˆ, Cormac Herley, and Paul C. van Oorschot&lt;br /&gt;
* [2] [https://www.youtube.com/watch?v=zUM7i8fsf0g Your Password Complexity Requirements are Worthless] by KoreLogic&lt;br /&gt;
* [3] [http://password-policy-testing.wikidot.com/results Testing Password Polices] by adedov@&lt;br /&gt;
&lt;br /&gt;
--[[User:Adedov|Adedov]] ([[User talk:Adedov|talk]]) 06:05, 14 November 2015 (CST)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The overall content is correct, but I have the following remarks : &lt;br /&gt;
&lt;br /&gt;
1. I corrected some syntactical errors in the text. For example, &amp;quot;is&amp;quot; was missing in the sentence &amp;quot;it is the most common form&amp;quot;, in the introduction.&lt;br /&gt;
&lt;br /&gt;
2. The introduction could insist on the idea that passwords are basically a means of authenticating users of a Web application, among other means, and that the choice of passwords or a stronger means like two-factors authentication really depends on the security needs of an application, based on risk evaluation and security specifications in the conception phase.&lt;br /&gt;
&lt;br /&gt;
3. In the introduction about the &amp;quot;Pros&amp;quot; and &amp;quot;Cons&amp;quot; of passwords, I would add in the &amp;quot;Cons&amp;quot; that we all suffer from having to manage and remember too many passwords. For a new Web application, one should consider the possibility of relying on a more global identity management system (such as some sort of &amp;quot;single sign on&amp;quot; or &amp;quot;reduced sign on&amp;quot; set for all or at least many applications in the corporation), instead of trying to generate yet another password. &lt;br /&gt;
&lt;br /&gt;
4. I think the details of password length, password complexity and password history should not be fixed too precisely, because it really depends on the security policies of each organization. The main point in general is that in security policies, there must be rules for password length (a minimum length should be defined), password complexity (the minimum complexity of passwords should be described) and password history (the minimum number of old passwords to check should be defined).  &lt;br /&gt;
&lt;br /&gt;
5. I would not present managing the history of passwords as a &amp;quot;nice to have&amp;quot; feature, but rather as a mandatory feature.&lt;br /&gt;
&lt;br /&gt;
Philippe Curmin&lt;br /&gt;
&lt;br /&gt;
== How to avoid similar passwords? ==&lt;br /&gt;
&lt;br /&gt;
In order to hinder users from using similar passwords or passwords with simple counters (&amp;quot;test1&amp;quot; -&amp;gt; &amp;quot;test2&amp;quot;) it would be nice to implement the [http://en.wikipedia.org/wiki/Levenshtein_distance Levenshtein Distance] for the change of passwords and only allow those with at least a minimum distance.&lt;br /&gt;
&lt;br /&gt;
The problem with the distance function is that I need to know the old password, which I shouldn't. If I save passwords as hashes the function doesn't work anymore.&lt;br /&gt;
&lt;br /&gt;
Is there already an algorithm to compare passwords without saving them as plain text? I can imagine something like a function that saves the structure of the phrase, i.e. &amp;quot;test1&amp;quot; consists of 4 alphabetical lowercase signs and one number - the same as in &amp;quot;test2&amp;quot;. But also in &amp;quot;ak9Me&amp;quot;. So it needs to be a bit more sophisticated.&lt;br /&gt;
&lt;br /&gt;
Any ideas?&lt;br /&gt;
&lt;br /&gt;
== Password lifetime criteria ==&lt;br /&gt;
&lt;br /&gt;
Is there any advice or direction on how often a system should require a password to be changed?&lt;br /&gt;
&lt;br /&gt;
Passwords that change too often are much less likely to be committed to memory, which leads to more use of the dreaded sticky note on the monitor.&lt;br /&gt;
For instance, if a system typically has monthly access from users, and has a 90 day password change policy, this would lead to each password only being used ~3 times before requiring change.&lt;br /&gt;
&lt;br /&gt;
Dave Elton&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Adedov&amp;diff=203347</id>
		<title>User:Adedov</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Adedov&amp;diff=203347"/>
				<updated>2015-11-13T13:57:09Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I was born in central Siberia, Russia in 1978. I lived in various places at Siberia till 2010 then moved to Moscow.&lt;br /&gt;
&lt;br /&gt;
I am software developer at Parallels [http://cp.parallels.com] since 2005. In 2012 started working on product security. Also an open source developer and occasional researcher.&lt;br /&gt;
&lt;br /&gt;
Personal projects&lt;br /&gt;
* XML-RPC library for C++, [http://libiqxmlrpc.wikidot.com Libiqxmlrpc]&lt;br /&gt;
* [http://password-policy-testing.wikidot.com/ Password Policy Testing Framework]&lt;br /&gt;
&lt;br /&gt;
Twitter: @brutemorse&lt;br /&gt;
&lt;br /&gt;
Github: [https://github.com/adedov adedov]&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Adedov&amp;diff=203346</id>
		<title>User:Adedov</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Adedov&amp;diff=203346"/>
				<updated>2015-11-13T13:56:34Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I was born in central Siberia, Russia in 1978. I lived in various places at Siberia till 2010 then moved to Moscow.&lt;br /&gt;
&lt;br /&gt;
I am software developer at Parallels [http://cp.parallels.com] since 2005. In 2012 started working on product security. Also an open source developer and occasional researcher.&lt;br /&gt;
&lt;br /&gt;
Personal projects&lt;br /&gt;
* XML-RPC library for C++, [http://libiqxmlrpc.wikidot.com Libiqxmlrpc]&lt;br /&gt;
* [http://password-policy-testing.wikidot.com/ Password Policy Testing Framework]&lt;br /&gt;
&lt;br /&gt;
Twitter: @brutemorse&lt;br /&gt;
Github: [https://github.com/adedov]&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Password_Storage_Cheat_Sheet&amp;diff=203345</id>
		<title>Talk:Password Storage Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Password_Storage_Cheat_Sheet&amp;diff=203345"/>
				<updated>2015-11-13T13:28:57Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Suggest take in account planned/actual scale of a system to protect. Bigger systems probably need more layers of defense, like additional authN server + secret salt (local parameters) + traditional KDF for storage. See Solar Designer's [http://openwall.com/presentations/YaC2012-Password-Hashing-At-Scale/ slides] from Yac 2012 (unfortunately, there is no English video).&lt;br /&gt;
&lt;br /&gt;
--[[User:Adedov|Adedov]] ([[User talk:Adedov|talk]]) 07:28, 13 November 2015 (CST)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Increasing work factor with PBKDF2 etc. can result in an application-level DoS vector. This can be abused in a passively distributed manner by inducing CSRF authentication attempts and hence standard CSRF mitigation should be applied to authentication systems too. Mitigating automated DoS attacks on this vector can be achieved with CAPTCHA but which users should be required to complete a CAPTCHA isn't as simple; linking it to a session and failed authentication attempts will not work as an automated attack can simply request a new session token. Perhaps it should be linked to IP or subnet?&lt;br /&gt;
&lt;br /&gt;
--[[User:Arran Schlosberg|Arran Schlosberg]] , 19 Feb 2014 (UTC)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Setting a unlimited length for passwords can be an easy DOS vector. http://arstechnica.com/security/2013/09/long-passwords-are-good-but-too-much-length-can-be-bad-for-security/&lt;br /&gt;
&lt;br /&gt;
--[[User:jmanico|Jim Manico]] , 16 Sept 2013 (UTC)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
More on the previous dicussions on secret salts. They are usually referred to as pepper on practice. The advantage of having a pepper for the passwords is that you can keep them on the web server. Thus, if the hacker has access to the database data and he has access to all hashed passwords (doesn't matter if they are created using PBKDF2, bcrypt or scrypt, or even simple salt+sha2), he still needs to also hack the web server to obtain the pepper, or fixed salt. It isn't cryptographically significant, but it adds yet another layer to the information the hacker has to obtain before starting to do the brute force.&lt;br /&gt;
I think it would be nice if it was possible to add it to the cheat sheet.&lt;br /&gt;
&lt;br /&gt;
--[[User:Manuel Aude Morales|Manuel Aude Morales]] , 18 March 2013 (UTC)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
I was considering adding bcrypt to the article. I checked previous versions and noticed it was in it on January, but it was taken out during editions in March. From my knowledge, bcrypt is still a widely recommended adaptative hashing function. While it has limitations (particularly, a 55 bytes limitation) and doesn't protect to all hardware accelerated attacks, it does protect against GPU and works as good as PBKDF2 for most cases. Also, scrypt hasn't existed for nearly as much as bcrypt, and thus it isn't as widely tested or supported by platforms.&lt;br /&gt;
&lt;br /&gt;
Would it be ok to add a table making a comparison between PBKDF2, bcrypt and scrypt, with suggestions on when to use (and clarifying that the three are valid options)?&lt;br /&gt;
--[[User:Manuel Aude Morales|Manuel Aude Morales]] , 18 March 2013 (UTC)&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Is there any utility in incuding credential data in the input to the protective function? I don't understand what it adds, given a sufficiently random salt. [[User:James Sanderson|James Sanderson]] ([[User talk:James Sanderson|talk]]) 17:25, 2 July 2014 (CDT)&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Logging_Cheat_Sheet&amp;diff=197538</id>
		<title>Talk:Logging Cheat Sheet</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Logging_Cheat_Sheet&amp;diff=197538"/>
				<updated>2015-07-17T13:06:31Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: Created page with &amp;quot;Why other cheatsheets bar at right? It conflicts mobile wiki viewers in particular and mobile browsers in general. --~~~~&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Why other cheatsheets bar at right? It conflicts mobile wiki viewers in particular and mobile browsers in general. --[[User:Adedov|Adedov]] ([[User talk:Adedov|talk]]) 08:06, 17 July 2015 (CDT)&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Error_Handling,_Auditing_and_Logging&amp;diff=197537</id>
		<title>Error Handling, Auditing and Logging</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Error_Handling,_Auditing_and_Logging&amp;diff=197537"/>
				<updated>2015-07-17T12:32:26Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: /* Error Handling */ PHP is not &amp;quot;functional&amp;quot; language&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Guide Table of Contents|Development Guide Table of Contents]]__TOC__&lt;br /&gt;
&lt;br /&gt;
==Objective ==&lt;br /&gt;
&lt;br /&gt;
Many industries are required by legal and regulatory requirements to be:&lt;br /&gt;
&lt;br /&gt;
* Auditable – all activities that affect user state or balances are formally tracked&lt;br /&gt;
&lt;br /&gt;
* Traceable – it’s possible to determine where an activity occurs in all tiers of the application&lt;br /&gt;
&lt;br /&gt;
* High integrity – logs cannot be overwritten or tampered with by local or remote users&lt;br /&gt;
&lt;br /&gt;
Well-written applications will dual-purpose logs and activity traces for audit and monitoring, and make it easy to track a transaction without excessive effort or access to the system. They should possess the ability to easily track or identify potential fraud or anomalies end-to-end.&lt;br /&gt;
&lt;br /&gt;
==Environments Affected ==&lt;br /&gt;
&lt;br /&gt;
All.&lt;br /&gt;
&lt;br /&gt;
==Relevant COBIT Topics ==&lt;br /&gt;
&lt;br /&gt;
DS11 – Manage Data – All sections should be reviewed, but in particular:&lt;br /&gt;
&lt;br /&gt;
DS11.4 Source data error handling&lt;br /&gt;
&lt;br /&gt;
DS11.8 Data input error handling&lt;br /&gt;
&lt;br /&gt;
==Description ==&lt;br /&gt;
&lt;br /&gt;
Error handling, debug messages, auditing and logging are different aspects of the same topic: how to track events within an application:&lt;br /&gt;
&lt;br /&gt;
 &lt;br /&gt;
&lt;br /&gt;
==Best practices ==&lt;br /&gt;
&lt;br /&gt;
* Fail safe – do not fail open&lt;br /&gt;
&lt;br /&gt;
* Dual purpose logs&lt;br /&gt;
&lt;br /&gt;
* Audit logs are legally protected – protect them&lt;br /&gt;
&lt;br /&gt;
* Reports and search logs using a read-only copy or complete replica &lt;br /&gt;
&lt;br /&gt;
==Error Handling ==&lt;br /&gt;
&lt;br /&gt;
Error handling takes two forms: structured exception handling and functional error checking. Structured exception handling is always preferred as it is easier to cover 100% of code. On the other hand it is very hard to cover 100% of all errors in languages that do not have exceptions, such as PHP 4. Code that covers 100% of errors is extraordinarily verbose and difficult to read, and can contain subtle bugs and errors in the error handling code itself.&lt;br /&gt;
&lt;br /&gt;
Motivated attackers like to see error messages as they might leak information that leads to further attacks, or may leak privacy related information. Web application error handling is rarely robust enough to survive a penetration test. &lt;br /&gt;
&lt;br /&gt;
Applications should always fail safe. If an application fails to an unknown state, it is likely that an attacker may be able to exploit this indeterminate state to access unauthorized functionality, or worse create, modify or destroy data.&lt;br /&gt;
&lt;br /&gt;
===Fail safe ===&lt;br /&gt;
&lt;br /&gt;
* Inspect the application’s fatal error handler.&lt;br /&gt;
&lt;br /&gt;
* Does it fail safe? If so, how?&lt;br /&gt;
&lt;br /&gt;
* Is the fatal error handler called frequently enough?&lt;br /&gt;
&lt;br /&gt;
* What happens to in-flight transactions and ephemeral data?&lt;br /&gt;
&lt;br /&gt;
===Debug errors ===&lt;br /&gt;
&lt;br /&gt;
* Does production code contain debug error handlers or messages?  &lt;br /&gt;
&lt;br /&gt;
* If the language is a scripting language without effective pre-processing or compilation, can the debug flag be turned on in the browser?&lt;br /&gt;
&lt;br /&gt;
* Do the debug messages leak privacy related information, or information that may lead to further successful attack?&lt;br /&gt;
&lt;br /&gt;
===Exception handling ===&lt;br /&gt;
&lt;br /&gt;
* Does the code use structured exception handlers (try {} catch {} etc) or function-based error handling? &lt;br /&gt;
&lt;br /&gt;
* If the code uses function-based error handling, does it check every return value and handle the error appropriately?&lt;br /&gt;
&lt;br /&gt;
* Would fuzz injection against the average interface fail? &lt;br /&gt;
&lt;br /&gt;
===Functional return values ===&lt;br /&gt;
&lt;br /&gt;
Many languages indicate an error condition by return value. E.g.:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
$query = mysql_query(“SELECT * FROM table WHERE id=4”, $conn);&lt;br /&gt;
&lt;br /&gt;
if ( $query === false ) {&lt;br /&gt;
&lt;br /&gt;
		// error&lt;br /&gt;
&lt;br /&gt;
} &lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Are all functional errors checked? If not, what can go wrong?&lt;br /&gt;
&lt;br /&gt;
==Detailed error messages ==&lt;br /&gt;
&lt;br /&gt;
Detailed error messages provide attackers with a mountain of useful information.&lt;br /&gt;
&lt;br /&gt;
===How to determine if you are vulnerable  ===&lt;br /&gt;
&lt;br /&gt;
* Are detailed error messages turned on? &lt;br /&gt;
&lt;br /&gt;
* Do the detailed error messages leak information that may be used to stage a further attack, or leak privacy related information? &lt;br /&gt;
&lt;br /&gt;
* Does the browser cache the error message?&lt;br /&gt;
&lt;br /&gt;
===How to protect yourself ===&lt;br /&gt;
&lt;br /&gt;
Ensure that your application has a “safe mode” to which it can return if something truly unexpected occurs. If all else fails, log the user out and close the browser window.&lt;br /&gt;
&lt;br /&gt;
Production code should not be capable of producing debug messages. If it does, debug mode should be triggered by editing a file or configuration option on the server. In particular, debug should not enabled be an option in the application itself.&lt;br /&gt;
&lt;br /&gt;
If the framework or language has a structured exception handler (i.e. try {} catch {}), it should be used in preference to functional error handling.&lt;br /&gt;
&lt;br /&gt;
If the application uses functional error handling, its use must be comprehensive and thorough.&lt;br /&gt;
&lt;br /&gt;
Detailed error messages, such as stack traces or leaking privacy related information, should never be presented to the user. Instead a generic error message should be used. This includes HTTP status response codes (i.e. 404 or 500 Internal Server error).&lt;br /&gt;
&lt;br /&gt;
==Logging ==&lt;br /&gt;
&lt;br /&gt;
===Where to log to? ===&lt;br /&gt;
&lt;br /&gt;
Logs should be written so that the log file attributes are such that only new information can be written (older records cannot be rewritten or deleted). For added security, logs should also be written to a write once / read many device such as a CD-R.&lt;br /&gt;
&lt;br /&gt;
Copies of log files should be made at regular intervals depending on volume and size (daily, weekly, monthly, etc.).  A common naming convention should be adopted with regards to logs, making them easier to index. Verification that logging is still actively working is overlooked surprisingly often, and can be accomplished via a simple cron job!&lt;br /&gt;
&lt;br /&gt;
Make sure data is not overwritten.&lt;br /&gt;
&lt;br /&gt;
Log files should be copied and moved to permanent storage and incorporated into the organization's overall backup strategy.&lt;br /&gt;
&lt;br /&gt;
Log files and media should be deleted and disposed of properly and incorporated into an organization's shredding or secure media disposal plan. Reports should be generated on a regular basis, including error reporting and anomaly detection trending.&lt;br /&gt;
&lt;br /&gt;
Be sure to keep logs safe and confidential even when backed up.&lt;br /&gt;
&lt;br /&gt;
===Handling ===&lt;br /&gt;
&lt;br /&gt;
Logs can be fed into real time intrusion detection and performance and system monitoring tools. All logging components should be synced with a timeserver so that all logging can be consolidated effectively without latency errors. This time server should be hardened and should not provide any other services to the network.&lt;br /&gt;
&lt;br /&gt;
No manipulation, no deletion while analyzing.&lt;br /&gt;
&lt;br /&gt;
===General Debugging ===&lt;br /&gt;
&lt;br /&gt;
Logs are useful in reconstructing events after a problem has occurred, security related or not. Event reconstruction can allow a security administrator to determine the full extent of an intruder's activities and expedite the recovery process.&lt;br /&gt;
&lt;br /&gt;
===Forensics evidence ===&lt;br /&gt;
&lt;br /&gt;
Logs may in some cases be needed in legal proceedings to prove wrongdoing. In this case, the actual handling of the log data is crucial.&lt;br /&gt;
&lt;br /&gt;
===Attack detection ===&lt;br /&gt;
&lt;br /&gt;
Logs are often the only record that suspicious behavior is taking place: Therefore logs can sometimes be fed real-time directly into intrusion detection systems.&lt;br /&gt;
&lt;br /&gt;
===Quality of service ===&lt;br /&gt;
&lt;br /&gt;
Repetitive polls can be protocolled so that network outages or server shutdowns get protocolled and the behavior can either be analyzed later on or a responsible person can take immediate actions.&lt;br /&gt;
&lt;br /&gt;
===Proof of validity ===&lt;br /&gt;
&lt;br /&gt;
Application developers sometimes write logs to prove to customers that their applications are behaving as expected.&lt;br /&gt;
&lt;br /&gt;
* Required by law or corporate policies.&lt;br /&gt;
&lt;br /&gt;
* Logs can provide individual accountability in the web application system universe by tracking a user's actions.&lt;br /&gt;
&lt;br /&gt;
It can be corporate policy or local law to be required to (for example) save header information of all application transactions. These logs must then be kept safe and confidential for six months before they can be deleted.&lt;br /&gt;
&lt;br /&gt;
The points from above show all different motivations and result in different requirements and strategies. This means, that before we can implement a logging mechanism into an application or system, we have to know the requirements and their later usage. If we fail in doing so this can lead to unintentional results.&lt;br /&gt;
&lt;br /&gt;
Failure to enable or design the proper event logging mechanisms in the web application may undermine an organization's ability to detect unauthorized access attempts, and the extent to which these attempts may or may not have succeeded. We will look into the most common attack methods, design and implementation errors, as well as the mitigation strategies later on in this chapter.&lt;br /&gt;
&lt;br /&gt;
There is another reason why the logging mechanism must be planned before implementation. In some countries, laws define what kind of personal information is allowed to be not only logged but also analyzed. For example, in Switzerland, companies are not allowed to log personal information of their employees (like what they do on the internet or what they write in their emails). So if a company wants to log a worker's surfing habits, the corporation needs to inform her of their plans in advance.&lt;br /&gt;
&lt;br /&gt;
This leads to the requirement of having anonymized logs or de-personalized logs with the ability to re-personalized them later on if need be. If an unauthorized person has access to (legally) personalized logs, the corporation is acting unlawful. So there can be a few (not only) legal traps that must be kept in mind.&lt;br /&gt;
&lt;br /&gt;
===Logging types ===&lt;br /&gt;
&lt;br /&gt;
Logs can contain different kinds of data. The selection of the data used is normally affected by the motivation leading to the logging. This section contains information about the different types of logging information and the reasons why we could want to log them.&lt;br /&gt;
&lt;br /&gt;
In general, the logging features include appropriate debugging information such as time of event, initiating process or owner of process, and a detailed description of the event. The following are types of system events that can be logged in an application. It depends on the particular application or system and the needs to decide which of these will be used in the logs:&lt;br /&gt;
&lt;br /&gt;
* Reading of data file access and what kind of data is read. This not only allows to see if data was read but also by whom and when.&lt;br /&gt;
&lt;br /&gt;
* Writing of data logs also where and with what mode (append, replace) data was written. This can be used to see if data was overwritten or if a program is writing at all.&lt;br /&gt;
&lt;br /&gt;
* Modification of any data characteristics, including access control permissions or labels, location in database or file system, or data ownership. Administrators can detect if their configurations were changed.&lt;br /&gt;
&lt;br /&gt;
* Administrative functions and changes in configuration regardless of overlap (account management actions, viewing any user's data, enabling or disabling logging, etc.)&lt;br /&gt;
&lt;br /&gt;
* Miscellaneous debugging information that can be enabled or disabled on the fly.&lt;br /&gt;
&lt;br /&gt;
* All authorization attempts (include time) like success/failure, resource or function being authorized, and the user requesting authorization. We can detect password guessing with these logs. These kinds of logs can be fed into an Intrusion Detection system that will detect anomalies.&lt;br /&gt;
&lt;br /&gt;
* Deletion of any data (object). Sometimes applications are required to have some sort of versioning in which the deletion process can be cancelled.&lt;br /&gt;
&lt;br /&gt;
* Network communications (bind, connect, accept, etc.). With this information an Intrusion Detection system can detect port scanning and brute force attacks.&lt;br /&gt;
&lt;br /&gt;
* All authentication events (logging in, logging out, failed logins, etc.) that allow to detect brute force and guessing attacks too.&lt;br /&gt;
&lt;br /&gt;
==Noise ==&lt;br /&gt;
&lt;br /&gt;
Noise is intentionally invoking security errors to fill an error log with entries (noise) that hide the incriminating evidence of a successful intrusion. When the administrator or log parser application reviews the logs, there is every chance that they will summarize the volume of log entries as a denial of service attempt rather than identifying the 'needle in the haystack'.&lt;br /&gt;
&lt;br /&gt;
===How to protect yourself ===&lt;br /&gt;
&lt;br /&gt;
This is difficult since applications usually offer an unimpeded route to functions capable of generating log events. If you can deploy an intelligent device or application component that can shun an attacker after repeated attempts, then that would be beneficial. Failing that, an error log audit tool that can reduce the bulk of the noise, based on repetition of events or originating from the same source for example. It is also useful if the log viewer can display the events in order of severity level, rather than just time based.&lt;br /&gt;
&lt;br /&gt;
==Cover Tracks ==&lt;br /&gt;
&lt;br /&gt;
The top prize in logging mechanism attacks goes to the contender who can delete or manipulate log entries at a granular level, &amp;quot;as though the event never even happened!&amp;quot;. Intrusion and deployment of rootkits allows an attacker to utilize specialized tools that may assist or automate the manipulation of known log files. In most cases, log files may only be manipulated by users with root / administrator privileges, or via approved log manipulation applications. As a general rule, logging mechanisms should aim to prevent manipulation at a granular level since an attacker can hide their tracks for a considerable length of time without being detected. Simple question; if you were being compromised by an attacker, would the intrusion be more obvious if your log file was abnormally large or small, or if it appeared like every other day's log?&lt;br /&gt;
&lt;br /&gt;
===How to protect yourself ===&lt;br /&gt;
&lt;br /&gt;
Assign log files the highest security protection, providing reassurance that you always have an effective 'black box' recorder if things go wrong. This includes:&lt;br /&gt;
&lt;br /&gt;
*Applications should not run with Administrator, or root-level privileges. This is the main cause of log file manipulation success since super users typically have full file system access. Assume the worst case scenario and suppose your application is exploited. Would there be any other security layers in place to prevent the application's user privileges from manipulating the log file to cover tracks?&lt;br /&gt;
&lt;br /&gt;
*Ensuring that access privileges protecting the log files are restrictive, reducing the majority of operations against the log file to alter and read.&lt;br /&gt;
&lt;br /&gt;
*Ensuring that log files are assigned object names that are not obvious and stored in a safe location of the file system.&lt;br /&gt;
&lt;br /&gt;
*Writing log files using publicly or formally scrutinized techniques in an attempt to reduce the risk associated with reverse engineering or log file manipulation.&lt;br /&gt;
&lt;br /&gt;
*Writing log files to read-only media (where event log integrity is of critical importance).&lt;br /&gt;
&lt;br /&gt;
*Use of hashing technology to create digital fingerprints. The idea is that if an attacker does manipulate the log file, then the digital fingerprint will not match and an alert generated.&lt;br /&gt;
&lt;br /&gt;
*Use of host-based IDS technology where normal behavioral patterns can be 'set in stone'. Attempts by attackers to update the log file through anything but the normal approved flow would generate an exception and the intrusion can be detected and blocked. This is one security control that can safeguard against simplistic administrator attempts at modifications.&lt;br /&gt;
&lt;br /&gt;
==False Alarms ==&lt;br /&gt;
&lt;br /&gt;
Taking cue from the classic 1966 film &amp;quot;How to Steal a Million&amp;quot;, or similarly the fable of Aesop; &amp;quot;The Boy Who Cried Wolf&amp;quot;, be wary of repeated false alarms, since this may represent an attacker's actions in trying to fool the security administrator into thinking that the technology is faulty and not to be trusted until it can be fixed.&lt;br /&gt;
&lt;br /&gt;
===How to protect yourself ===&lt;br /&gt;
&lt;br /&gt;
Simply be aware of this type of attack, take every security violation seriously, always get to the bottom of the cause event log errors rather, and don't just dismiss errors unless you can be completely sure that you know it to be a technical problem.&lt;br /&gt;
&lt;br /&gt;
===Denial of Service ===&lt;br /&gt;
&lt;br /&gt;
By repeatedly hitting an application with requests that cause log entries, multiply this by ten thousand, and the result is that you have a large log file and a possible headache for the security administrator. Where log files are configured with a fixed allocation size, then once full, all logging will stop and an attacker has effectively denied service to your logging mechanism. Worse still, if there is no maximum log file size, then an attacker has the ability to completely fill the hard drive partition and potentially deny service to the entire system. This is becoming more of a rarity though with the increasing size of today's hard disks.&lt;br /&gt;
&lt;br /&gt;
===How to protect yourself ===&lt;br /&gt;
&lt;br /&gt;
The main defense against this type of attack are to increase the maximum log file size to a value that is unlikely to be reached, place the log file on a separate partition to that of the operating system or other critical applications and best of all, try to deploy some kind of system monitoring application that can set a threshold against your log file size and/or activity and issue an alert if an attack of this nature is underway.&lt;br /&gt;
&lt;br /&gt;
==Destruction ==&lt;br /&gt;
&lt;br /&gt;
Following the same scenario as the Denial of Service above, if a log file is configured to cycle round overwriting old entries when full, then an attacker has the potential to do the evil deed and then set a log generation script into action in an attempt to eventually overwrite the incriminating log entries, thus destroying them.&lt;br /&gt;
&lt;br /&gt;
If all else fails, then an attacker may simply choose to cover their tracks by purging all log file entries, assuming they have the privileges to perform such actions. This attack would most likely involve calling the log file management program and issuing the command to clear the log, or it may be easier to simply delete the object which is receiving log event updates (in most cases, this object will be locked by the application). This type of attack does make an intrusion obvious assuming that log files are being regularly monitored, and does have a tendency to cause panic as system administrators and managers realize they have nothing upon which to base an investigation on.&lt;br /&gt;
&lt;br /&gt;
===How to protect yourself ===&lt;br /&gt;
&lt;br /&gt;
Following most of the techniques suggested above will provide good protection against this attack. Keep in mind two things:&lt;br /&gt;
&lt;br /&gt;
*Administrative users of the system should be well trained in log file management and review. 'Ad-hoc' clearing of log files is never advised and an archive should always be taken. Too many times a log file is cleared, perhaps to assist in a technical problem, erasing the history of events for possible future investigative purposes.&lt;br /&gt;
&lt;br /&gt;
*An empty security log does not necessarily mean that you should pick up the phone and fly the forensics team in. In some cases, security logging is not turned on by default and it is up to you to make sure that it is. Also, make sure it is logging at the right level of detail and benchmark the errors against an established baseline in order measure what is considered 'normal' activity.&lt;br /&gt;
&lt;br /&gt;
==Audit Trails ==&lt;br /&gt;
&lt;br /&gt;
Audit trails are legally protected in many countries, and should be logged into high integrity destinations to prevent casual and motivated tampering and destruction. &lt;br /&gt;
&lt;br /&gt;
===How to determine if you are vulnerable ===&lt;br /&gt;
&lt;br /&gt;
* Do the logs transit in the clear between the logging host and the destination?&lt;br /&gt;
&lt;br /&gt;
* Do the logs have a HMAC or similar tamper proofing mechanism to prevent change from the time of the logging activity to when it is reviewed?&lt;br /&gt;
&lt;br /&gt;
* Can relevant logs be easily extracted in a legally sound fashion to assist with prosecutions?&lt;br /&gt;
&lt;br /&gt;
===How to protect yourself ===&lt;br /&gt;
&lt;br /&gt;
* Only audit truly important events – you have to keep audit trails for a long time, and debug or informational messages are wasteful&lt;br /&gt;
&lt;br /&gt;
* Log centrally as appropriate and ensure primary audit trails are not kept on vulnerable systems, particularly front end web servers&lt;br /&gt;
&lt;br /&gt;
* Only review copies of the logs, not the actual logs themselves&lt;br /&gt;
&lt;br /&gt;
* Ensure that audit logs are sent to trusted systems&lt;br /&gt;
&lt;br /&gt;
* For highly protected systems, use write-once media or similar to provide trust worthy long term log repositories&lt;br /&gt;
&lt;br /&gt;
* For highly protected systems, ensure there is end-to-end trust in the logging mechanism. World writeable logs, logging agents without credentials (such as SNMP traps, syslog etc) are legally vulnerable to being excluded from prosecution &lt;br /&gt;
&lt;br /&gt;
==Further Reading ==&lt;br /&gt;
&lt;br /&gt;
* Oracle Auditing&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;http://www.dba-oracle.com/t_audit_table_command.htm&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Sarbanes Oxley for IT security&lt;br /&gt;
&lt;br /&gt;
&amp;lt;u&amp;gt;http://www.securityfocus.com/columnists/322&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
* Java Logging Overview&lt;br /&gt;
&amp;lt;u&amp;gt;http://java.sun.com/javase/6/docs/technotes/guides/logging/overview.html&amp;lt;/u&amp;gt;&lt;br /&gt;
&lt;br /&gt;
==Error Handling and Logging ==&lt;br /&gt;
&lt;br /&gt;
All applications have failures – whether they occur during compilation or runtime. Most programming languages will throw runtime exceptions for illegally executing code (e.g. syntax errors) often in the form of cryptic system messages. These failures and resulting system messages can lead to several security risks if not handled properly including; enumeration, buffer attacks, sensitive information disclosure, etc.  If an attack occurs it is important that forensics personnel be able to trace the attacker’s tracks via adequate logging.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ColdFusion provides structured exception handling and logging tools. These tools can help developers customize error handling to prevent unwanted disclosure, and provide customized logging for error tracking and audit trails. These tools should be combined with web server, J2EE application server, and operating system tools to create the full system/application security overview.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Error Handling'''&lt;br /&gt;
&lt;br /&gt;
Hackers can use the information exposed by error messages. Even missing templates errors (HTTP 404) can expose your server to attacks (e.g. buffer overflow, XSS, etc.). If you enable the Robust Exception Information debugging option, ColdFusion will display:&lt;br /&gt;
&lt;br /&gt;
Physical path of template &lt;br /&gt;
&lt;br /&gt;
URI of template &lt;br /&gt;
&lt;br /&gt;
Line number and line snippet &lt;br /&gt;
&lt;br /&gt;
SQL statement used (if any) &lt;br /&gt;
&lt;br /&gt;
Data source name (if any) &lt;br /&gt;
&lt;br /&gt;
Java stack trace&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
ColdFusion provides tags and functions for developers to use to customize error handling. Administrators can specify default templates in the ColdFusion Administrator (CFAM) to handle unknown or unhandled exceptions. ColdFusion’s structure exception handling works in the following order:&lt;br /&gt;
&lt;br /&gt;
Template level (ColdFusion templates and components)&lt;br /&gt;
&lt;br /&gt;
ColdFusion exception handling tags: cftry, cfcatch, cfthrow, and cfrethrow&lt;br /&gt;
&lt;br /&gt;
try and catch statements in CFScript&lt;br /&gt;
&lt;br /&gt;
Application level (Application.cfc/cfm)&lt;br /&gt;
&lt;br /&gt;
Specify custom templates for individual exceptions types with the cferror tag&lt;br /&gt;
&lt;br /&gt;
Application.cfc onError method to handle uncaught application exceptions&lt;br /&gt;
&lt;br /&gt;
System level (ColdFusion Administrator settings)&lt;br /&gt;
&lt;br /&gt;
Missing Template Handler execute when a requested ColdFusion template is not found&lt;br /&gt;
&lt;br /&gt;
Site-wide Error Handler executes globally for all unhandled exceptions on the server&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Best Practices '''&lt;br /&gt;
&lt;br /&gt;
*Do not allow exceptions to go unhandled&lt;br /&gt;
&lt;br /&gt;
*Do not allow any exceptions to reach the browser&lt;br /&gt;
&lt;br /&gt;
*Display custom error pages to users with an email link for feedback&lt;br /&gt;
&lt;br /&gt;
*Do not enable “Robust Exception Information” in production.&lt;br /&gt;
&lt;br /&gt;
*Specify custom pages for ColdFusion to display in each of the following cases: &lt;br /&gt;
**When a ColdFusion page is missing (the Missing Template Handler page) &lt;br /&gt;
**When an otherwise-unhandled exception error occurs during the processing of a page (the Site-wide Error Handler page) &lt;br /&gt;
**You specify these pages on the Settings page in the Server Settings are in the ColdFusion MX Administrator; for more information, see the ColdFusion MX Administrator Help.&lt;br /&gt;
&lt;br /&gt;
*Use the cferror tag to specify ColdFusion pages to handle specific types of errors. &lt;br /&gt;
&lt;br /&gt;
*Use the cftry, cfcatch, cfthrow, and cfrethrow tags to catch and handle exception errors directly on the page where they occur. &lt;br /&gt;
&lt;br /&gt;
*In CFScript, use the try and catch statements to handle exceptions. &lt;br /&gt;
&lt;br /&gt;
*Use the onError event in Application.cfc to handle exception errors that are not handled by try/catch code on the application pages. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Logging'''&lt;br /&gt;
&lt;br /&gt;
Log files can help with application debugging and provide audit trails for attack detection. ColdFusion provides several logs for different server functions. It leverages the Apache Log4j libraries for customized logging. It also provides logging tags to assist in application debugging. &lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following is a partial list of ColdFusion log files and their descriptions''' '''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
{| border=1&lt;br /&gt;
&lt;br /&gt;
 || Log file  || Description &lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
 || application.log || Records every ColdFusion MX error reported to a user. Application page errors, including ColdFusion MX syntax, ODBC, and SQL errors, are written to this log file.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
 || exception.log  || Records stack traces for exceptions that occur in ColdFusion.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
 || scheduler.log || Records scheduled events that have been submitted for execution. Indicates whether task submission was initiated and whether it succeeded. Provides the scheduled page URL, the date and time executed, and a task ID.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
 || server.log || Records start up messages and errors for ColdFusion MX.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
 || customtag.log || Records errors generated in custom tag processing.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
 || mail.log || Records errors generated by an SMTP mail server.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
 || mailsent.log || Records messages sent by ColdFusion MX.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
 || flash.log || Records entries for Macromedia Flash Remoting.&lt;br /&gt;
&lt;br /&gt;
|-&lt;br /&gt;
&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The CFAM contains the Logging Settings and log viewer screens. Administrators can configure the log directory, maximum log file size, and maximum number of archives. It also allows administrators to log slow running pages, CORBA calls, and scheduled task execution. The log viewer allows viewing, filtering, and searching of any log files in the log directory (default is cf_root/logs). Administrators can archive, save, and delete log files as well.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The cflog and cftrace tags allow developers to create customized logging. &amp;lt;cflog&amp;gt; can write custom messages to the Application.log, Scheduler.log, or a custom log file. The custom log file must be in the default log directory – if it does not exist ColdFusion will create it. &amp;lt;cftrace&amp;gt; tracks execution times, logic flow, and variable at the time the tag executes. It records the data in the cftrace.log (in the default logs directory) and can display this info either inline or in the debugging output of the current page request. Use &amp;lt;cflog&amp;gt; to write custom error messages, track user logins, and record user activity to a custom log file.  Use &amp;lt;cftrace&amp;gt; to track variables and application state within running requests.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Best Practices'''&lt;br /&gt;
&lt;br /&gt;
*Use &amp;lt;cflog&amp;gt; for customized logging&lt;br /&gt;
&lt;br /&gt;
*Incorporate into custom error handling&lt;br /&gt;
&lt;br /&gt;
*Record application specific messages&lt;br /&gt;
&lt;br /&gt;
*Actively monitor and fix errors in ColdFusion’s logs&lt;br /&gt;
&lt;br /&gt;
*Optimize logging settings &lt;br /&gt;
&lt;br /&gt;
*Rotate log files to keep them current &lt;br /&gt;
&lt;br /&gt;
*Keep files size manageable&lt;br /&gt;
&lt;br /&gt;
*Enable logging of slow running pages&lt;br /&gt;
&lt;br /&gt;
*Set the time interval lower than the configured Timeout Request value in the CFAM Settings screen&lt;br /&gt;
&lt;br /&gt;
*Long running page timings are recorded in the server.log&lt;br /&gt;
&lt;br /&gt;
*Use &amp;lt;cftrace&amp;gt; sparingly for audit trails&lt;br /&gt;
&lt;br /&gt;
*Use with inline=“false”&lt;br /&gt;
&lt;br /&gt;
*Use it to track user input – Form and/or URL variables&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''''Best Practices in Action'''''&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
The following code adds error handling and logging to the dbLogin and logout methods in the code from Authentication section.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&amp;lt;pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cffunction name=&amp;quot;dblogin&amp;quot; access=&amp;quot;private&amp;quot; output=&amp;quot;false&amp;quot; returntype=&amp;quot;struct&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfargument name=&amp;quot;strUserName&amp;quot; required=&amp;quot;true&amp;quot; type=&amp;quot;string&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfargument name=&amp;quot;strPassword&amp;quot; required=&amp;quot;true&amp;quot; type=&amp;quot;string&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfset var retargs = StructNew()&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cftry&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfif IsValid(&amp;quot;regex&amp;quot;, uUserName, &amp;quot;[A-Za-z0-9%]*&amp;quot;) AND IsValid(&amp;quot;regex&amp;quot;, uPassword, &amp;quot;[A-Za-z0-9%]*&amp;quot;)&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;cfquery name=&amp;quot;loginQuery&amp;quot; dataSource=&amp;quot;#Application.DB#&amp;quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
		SELECT hashed_password, salt&lt;br /&gt;
&lt;br /&gt;
		FROM UserTable&lt;br /&gt;
&lt;br /&gt;
		WHERE UserName =&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;cfqueryparam value=&amp;quot;#strUserName#&amp;quot; cfsqltype=&amp;quot;CF_SQL_VARCHAR&amp;quot; maxlength=&amp;quot;25&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/cfquery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;cfif loginQuery.hashed_password EQ Hash(strPassword &amp;amp; loginQuery.salt, &amp;quot;SHA-256&amp;quot; )&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		  &amp;lt;cfset retargs.authenticated=&amp;quot;YES&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		  &amp;lt;cfset Session.UserName = strUserName&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		  &amp;lt;cflog text=&amp;quot;#getAuthUser()# has logged in!&amp;quot; &lt;br /&gt;
&lt;br /&gt;
		  	type=&amp;quot;Information&amp;quot; &lt;br /&gt;
&lt;br /&gt;
			file=&amp;quot;access&amp;quot; &lt;br /&gt;
&lt;br /&gt;
			application=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
		  &amp;lt;!-- Add code to get roles from database --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		  &amp;lt;cfelse&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		  &amp;lt;cfset retargs.authenticated=&amp;quot;NO&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/cfif&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	  &amp;lt;cfelse&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;cfset retargs.authenticated=&amp;quot;NO&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	  &amp;lt;/cfif&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	  &amp;lt;cfcatch type=&amp;quot;database&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	  	&amp;lt;cflog text=&amp;quot;Error in dbLogin(). #cfcatch.details#&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	  		type=&amp;quot;Error&amp;quot; &lt;br /&gt;
&lt;br /&gt;
			log=&amp;quot;Application&amp;quot; &lt;br /&gt;
&lt;br /&gt;
			application=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;cfset retargs.authenticated=&amp;quot;NO&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;cfreturn retargs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	  &amp;lt;/cfcatch&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/cftry&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfreturn retargs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/cffunction&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cffunction name=&amp;quot;logout&amp;quot; access=&amp;quot;remote&amp;quot; output=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfargument name=&amp;quot;logintype&amp;quot; type=&amp;quot;string&amp;quot; required=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfif isDefined(&amp;quot;form.logout&amp;quot;)&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cflogout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfset StructClear(Session)&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	&amp;lt;cflog text=&amp;quot;#getAuthUser()# has been logged out.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
		type=&amp;quot;Information&amp;quot; &lt;br /&gt;
&lt;br /&gt;
		file=&amp;quot;access&amp;quot; &lt;br /&gt;
&lt;br /&gt;
		application=&amp;quot;yes&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfif arguments.logintype eq &amp;quot;challenge&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfset foo = closeBrowser()&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfelse&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--- replace this URL to a page logged out users should see ---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cflocation url=&amp;quot;login.cfm&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/cfif&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/cfif&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/cffunction&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cffunction name=&amp;quot;dblogin&amp;quot; access=&amp;quot;private&amp;quot; output=&amp;quot;false&amp;quot; returntype=&amp;quot;struct&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfargument name=&amp;quot;strUserName&amp;quot; required=&amp;quot;true&amp;quot; type=&amp;quot;string&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfargument name=&amp;quot;strPassword&amp;quot; required=&amp;quot;true&amp;quot; type=&amp;quot;string&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfset var retargs = StructNew()&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cftry&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfif IsValid(&amp;quot;regex&amp;quot;, uUserName, &amp;quot;[A-Za-z0-9%]*&amp;quot;) AND IsValid(&amp;quot;regex&amp;quot;, uPassword, &amp;quot;[A-Za-z0-9%]*&amp;quot;)&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;cfquery name=&amp;quot;loginQuery&amp;quot; dataSource=&amp;quot;#Application.DB#&amp;quot; &amp;gt;&lt;br /&gt;
&lt;br /&gt;
		SELECT hashed_password, salt&lt;br /&gt;
&lt;br /&gt;
		FROM UserTable&lt;br /&gt;
&lt;br /&gt;
		WHERE UserName =&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;cfqueryparam value=&amp;quot;#strUserName#&amp;quot; cfsqltype=&amp;quot;CF_SQL_VARCHAR&amp;quot; maxlength=&amp;quot;25&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/cfquery&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;cfif loginQuery.hashed_password EQ Hash(strPassword &amp;amp; loginQuery.salt, &amp;quot;SHA-256&amp;quot; )&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		  &amp;lt;cfset retargs.authenticated=&amp;quot;YES&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		  &amp;lt;cfset Session.UserName = strUserName&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		  &amp;lt;cflog text=&amp;quot;#getAuthUser()# has logged in!&amp;quot; &lt;br /&gt;
&lt;br /&gt;
		  	type=&amp;quot;Information&amp;quot; &lt;br /&gt;
&lt;br /&gt;
			file=&amp;quot;access&amp;quot; &lt;br /&gt;
&lt;br /&gt;
			application=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
		  &amp;lt;!-- Add code to get roles from database --&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		  &amp;lt;cfelse&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		  &amp;lt;cfset retargs.authenticated=&amp;quot;NO&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;/cfif&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	  &amp;lt;cfelse&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;cfset retargs.authenticated=&amp;quot;NO&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	  &amp;lt;/cfif&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	  &amp;lt;cfcatch type=&amp;quot;database&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	  	&amp;lt;cflog text=&amp;quot;Error in dbLogin(). #cfcatch.details#&amp;quot;&lt;br /&gt;
&lt;br /&gt;
	  		type=&amp;quot;Error&amp;quot; &lt;br /&gt;
&lt;br /&gt;
			log=&amp;quot;Application&amp;quot; &lt;br /&gt;
&lt;br /&gt;
			application=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;cfset retargs.authenticated=&amp;quot;NO&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
		&amp;lt;cfreturn retargs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
	  &amp;lt;/cfcatch&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/cftry&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfreturn retargs&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/cffunction&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cffunction name=&amp;quot;logout&amp;quot; access=&amp;quot;remote&amp;quot; output=&amp;quot;true&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfargument name=&amp;quot;logintype&amp;quot; type=&amp;quot;string&amp;quot; required=&amp;quot;yes&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfif isDefined(&amp;quot;form.logout&amp;quot;)&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cflogout&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfset StructClear(Session)&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cflog text=&amp;quot;#getAuthUser()# has been logged out.&amp;quot; &lt;br /&gt;
&lt;br /&gt;
		type=&amp;quot;Information&amp;quot; &lt;br /&gt;
&lt;br /&gt;
		file=&amp;quot;access&amp;quot; &lt;br /&gt;
&lt;br /&gt;
		application=&amp;quot;yes&amp;quot;&amp;gt; &lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfif arguments.logintype eq &amp;quot;challenge&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfset foo = closeBrowser()&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cfelse&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;!--- replace this URL to a page logged out users should see ---&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;cflocation url=&amp;quot;login.cfm&amp;quot;&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/cfif&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/cfif&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/cffunction&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&amp;lt;/pre&amp;gt;&lt;br /&gt;
&lt;br /&gt;
[[Guide Table of Contents|Development Guide Table of Contents]]&lt;br /&gt;
[[Category:OWASP_Guide_Project]]&lt;br /&gt;
[[Category:Error Handling]]&lt;br /&gt;
[[Category:Logging]]&lt;br /&gt;
[[Category:OWASP Logging Project]]&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Blocking_Brute_Force_Attacks&amp;diff=191658</id>
		<title>Blocking Brute Force Attacks</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Blocking_Brute_Force_Attacks&amp;diff=191658"/>
				<updated>2015-03-18T07:45:22Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: /* Device Cookies */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Blocking Brute Force Attacks ==&lt;br /&gt;
&lt;br /&gt;
A common threat web developers face is a password-guessing attack known as a brute force attack. A brute-force attack is an attempt to discover a password by systematically trying every possible combination of letters, numbers, and symbols until you discover the one correct combination that works. If your web site requires user authentication, you are a good target for a brute-force attack.&lt;br /&gt;
&lt;br /&gt;
An attacker can always discover a password through a brute-force attack, but the downside is that it could take years to find it. Depending on the password's length and complexity, there could be trillions of possible combinations. To speed things up a bit, a brute-force attack could start with dictionary words or slightly modified dictionary words because most people will use those rather than a completely random password. These attacks are called dictionary attacks or hybrid brute-force attacks. Brute-force attacks put user accounts at risk and flood your site with unnecessary traffic.&lt;br /&gt;
&lt;br /&gt;
Hackers launch brute-force attacks using widely available tools that utilize wordlists and smart rulesets to intelligently and automatically guess user passwords. Although such attacks are easy to detect, they are not so easy to prevent. For example, many HTTP brute-force tools can relay requests through a list of open proxy servers. Since each request appears to come from a different IP address, you cannot block these attacks simply by blocking the IP address. To further complicate things, some tools try a different username and password on each attempt, so you cannot lock out a single account for failed password attempts.&lt;br /&gt;
&lt;br /&gt;
==Locking Accounts==&lt;br /&gt;
&lt;br /&gt;
The most obvious way to block brute-force attacks is to simply lock out accounts after a defined number of incorrect password attempts. Account lockouts can last a specific duration, such as one hour, or the accounts could remain locked until manually unlocked by an administrator. However, account lockout is not always the best solution, because someone could easily abuse the security measure and lock out hundreds of user accounts. In fact, some Web sites experience so many attacks that they are unable to enforce a lockout policy because they would constantly be unlocking customer accounts.&lt;br /&gt;
&lt;br /&gt;
The problems with account lockouts are:&lt;br /&gt;
&lt;br /&gt;
:* An attacker can cause a denial of service (DoS) by locking out large numbers of accounts.&lt;br /&gt;
:* Because you cannot lock out an account that does not exist, only valid account names will lock. An attacker could use this fact to harvest usernames from the site, depending on the error responses.&lt;br /&gt;
:* An attacker can cause a diversion by locking out many accounts and flooding the help desk with support calls.&lt;br /&gt;
:* An attacker can continuously lock out the same account, even seconds after an administrator unlocks it, effectively disabling the account.&lt;br /&gt;
:* Account lockout is ineffective against slow attacks that try only a few passwords every hour.&lt;br /&gt;
:* Account lockout is ineffective against attacks that try one password against a large list of usernames.&lt;br /&gt;
:* Account lockout is ineffective if the attacker is using a username/password combo list and guesses correctly on the first couple of attempts.&lt;br /&gt;
:* Powerful accounts such as administrator accounts often bypass lockout policy, but these are the most desirable accounts to attack. Some systems lock out administrator accounts only on network-based logins.&lt;br /&gt;
:* Even once you lock out an account, the attack may continue, consuming valuable human and computer resources.&lt;br /&gt;
&lt;br /&gt;
Account lockout is sometimes effective, but only in controlled environments or in cases where the risk is so great that even continuous DoS attacks are preferable to account compromise. In most cases, however, account lockout is insufficient for stopping brute-force attacks. Consider, for example, an auction site on which several bidders are fighting over the same item. If the auction Web site enforced account lockouts, one bidder could simply lock the others' accounts in the last minute of the auction, preventing them from submitting any winning bids. An attacker could use the same technique to block critical financial transactions or e-mail communications.&lt;br /&gt;
&lt;br /&gt;
==Device Cookies==&lt;br /&gt;
&lt;br /&gt;
You may also consider locking out authentication attempts from known and unknown browsers or devices separately. The [[Slow Down Online Guessing Attacks with Device Cookies]] article proposes protocol for lockout mechanism based on information about if specific browser have been already used for successful login. The protocol is less susceptible to DoS attacks than plain account locking out and yet effective and easy to implement.&lt;br /&gt;
&lt;br /&gt;
==Finding Other Countermeasures==&lt;br /&gt;
&lt;br /&gt;
As described, account lockouts are usually not a practical solution, but there are other tricks to deal with brute force attacks. First, since the success of the attack is dependent on time, an easy solution is to inject random pauses when checking a password. Adding even a few seconds' pause can greatly slow a brute-force attack but will not bother most legitimate users as they log in to their accounts.&lt;br /&gt;
&lt;br /&gt;
Note that although adding a delay could slow a single-threaded attack, it is less effective if the attacker sends multiple simultaneous authentication requests.&lt;br /&gt;
&lt;br /&gt;
Another solution is to lock out an IP address with multiple failed logins. The problem with this solution is that you could inadvertently block large groups of users by blocking a proxy server used by an ISP or large company. Another problem is that many tools utilize proxy lists and send only a few requests from each IP address before moving on to the next. Using widely available open proxy lists at Web sites such as http://tools.rosinstrument.com/proxy/, an attacker could easily circumvent any IP blocking mechanism. Because most sites do not block after just one failed password, an attacker can use two or three attempts per proxy. An attacker with a list of 1,000 proxies can attempt 2,000 or 3,000 passwords without being blocked. Nevertheless, despite this method's weaknesses, Web sites that experience high numbers of attacks-adult Web sites in particular-do choose to block proxy IP addresses.&lt;br /&gt;
&lt;br /&gt;
One simple yet surprisingly effective solution is to design your Web site not to use predictable behavior for failed passwords. For example, most Web sites return an &amp;quot;HTTP 401 error&amp;quot; code with a password failure, although some web sites instead return an &amp;quot;HTTP 200 SUCCESS&amp;quot; code but direct the user to a page explaining the failed password attempt. This fools some automated systems, but it is also easy to circumvent. A better solution might be to vary the behavior enough to eventually discourage all but the most dedicated hackers. You could, for example, use different error messages each time or sometimes let a user through to a page and then prompt him again for a password.&lt;br /&gt;
&lt;br /&gt;
Some automated brute-force tools allow the attacker to set certain trigger strings to look for that indicate a failed password attempt. For example, if the resulting page contains the phrase &amp;quot;Bad username or password,&amp;quot; the tool would know the credentials failed and would try the next in the list. A simple way to fool these tools is to include also those phrases as comments in the HTML source of the page they get when they successfully authenticate.&lt;br /&gt;
&lt;br /&gt;
After one or two failed login attempts, you may want to prompt the user not only for the username and password but also to answer a secret question. This not only causes problems with automated attacks, it prevents an attacker from gaining access, even if they do get the username and password correct. You could also detect high numbers of attacks system-wide and under those conditions prompt all users for the answer to their secret questions.&lt;br /&gt;
&lt;br /&gt;
Other techniques you might want to consider are:&lt;br /&gt;
&lt;br /&gt;
:* For advanced users who want to protect their accounts from attack, give them the option to allow login only from certain IP addresses.&lt;br /&gt;
:*Assign unique login URLs to blocks of users so that not all users can access the site from the same URL.&lt;br /&gt;
:*Use a CAPTCHA to prevent automated attacks (see the sidebar &amp;quot;Using CAPTCHAs&amp;quot;).&lt;br /&gt;
:*Instead of completely locking out an account, place it in a lockdown mode with limited capabilities.&lt;br /&gt;
&lt;br /&gt;
Attackers can often circumvent many of these techniques by themselves, but by combining several techniques, you can significantly limit brute-force attacks. It might be difficult to stop an attacker who is determined to obtain a password specifically from your web site, but these techniques certainly can be effective against many attacks, including those from novice hackers. These techniques also require more work on the attacker's part, which gives you more opportunity to detect the attack and maybe even identify the attacker.&lt;br /&gt;
&lt;br /&gt;
Although brute-force attacks are difficult to stop completely, they are easy to detect because each failed login attempt records an HTTP 401 status code in your Web server logs. It is important to monitor your log files for brute-force attacks-in particular, the intermingled 200 status codes that mean the attacker found a valid password.&lt;br /&gt;
&lt;br /&gt;
Here are conditions that could indicate a brute-force attack or other account abuse:&lt;br /&gt;
&lt;br /&gt;
:*Many failed logins from the same IP address&lt;br /&gt;
:*Logins with multiple usernames from the same IP address&lt;br /&gt;
:*Logins for a single account coming from many different IP addresses&lt;br /&gt;
:*Excessive usage and bandwidth consumption from a single use&lt;br /&gt;
:*Failed login attempts from alphabetically sequential usernames or passwords&lt;br /&gt;
:*Logins with a referring URL of someone's mail or IRC client&lt;br /&gt;
:*Referring URLs that contain the username and password in the format http://user:password@www.example.com/login.htm&lt;br /&gt;
:*If protecting an adult Web site, referring URLs of known password-sharing sites&lt;br /&gt;
:*Logins with suspicious passwords hackers commonly use, such as ownsyou (ownzyou), washere (wazhere), zealots, hacksyou, and the like&lt;br /&gt;
&lt;br /&gt;
Brute force attacks are surprisingly difficult to stop completely, but with careful design and multiple countermeasures, you can limit your exposure to these attacks. Ultimately, the only best defense is to make sure that users follow basic rules for strong passwords: use long unpredictable passwords, avoid dictionary words, avoid reusing passwords, and change passwords regularly.&lt;br /&gt;
&lt;br /&gt;
==Sidebar: Using CAPTCHAS==&lt;br /&gt;
&lt;br /&gt;
A completely automated public Turing test to tell computers and humans apart, or CAPTCHA, is a program that allows you to distinguish between humans and computers. First widely used by Alta Vista to prevent automated search submissions, CAPTCHAs are particularly effective in stopping any kind of automated abuse, including brute-force attacks. They work by presenting some test that is easy for humans to pass but difficult for computers to pass; therefore, they can conclude with some certainty whether there is a human on the other end.&lt;br /&gt;
&lt;br /&gt;
For a CAPTCHA to be effective, humans must be able to answer the test correctly as close to 100 percent of the time as possible. Computers must fail as close to 100 percent of the time as possible. Ez-gimpy (www.captcha.net/cgi-bin/ez-gimpy), perhaps the most commonly used CAPTCHA, presents the user with an obscured word that the user must type to pass the test. But researchers have since written pattern recognition programs that solve ez-gimpy with 92 percent accuracy. Although these researchers have not made their programs public, all it takes is one person to do so to make ez-gimpy mostly ineffective. Researchers at Carnegie Mellon's School of Computer Science continually work to improve and introduce new CAPTCHAs (see www.captcha.net/captchas).&lt;br /&gt;
&lt;br /&gt;
If you are developing your own CAPTCHA, keep in mind that it is not how hard the question is that matters-it is how likely it is that a computer will get the correct answer. I once saw a CAPTCHA that presents the user with a picture of three zebras, with a multiple-choice question asking how many zebras were in the picture. To answer the question, you click one of three buttons. Although it would be very difficult for a computer program to both understand the question and interpret the picture, the program could just randomly guess any answer and get it correct 30 percent of the time. Although this might seem a satisfactory level of risk, it is by no means an effective CAPTCHA. If you run a free e-mail service and use a CAPTCHA such as this to prevent spammers from creating accounts in bulk, all they have to do is write a script to automatically create 1,000 accounts and expect on average that 333 of those attempts will be successful.&lt;br /&gt;
&lt;br /&gt;
Nevertheless, a simple CAPTCHA may still be effective against brute-force attacks. When you combine the chance of an attacker sending a correct username and password guess with the chance of guessing the CAPTCHA correctly, combined with other techniques described in this chapter, even a simple CAPTCHA could prove effective.&lt;br /&gt;
&lt;br /&gt;
===Figure 1: Password Authentication Delay: C#===&lt;br /&gt;
&lt;br /&gt;
 private void AuthenticateRequest(object obj, EventArgs ea)&lt;br /&gt;
  {&lt;br /&gt;
    HttpApplication objApp = (HttpApplication) obj;&lt;br /&gt;
    HttpContext objContext = (HttpContext) objApp.Context;  &lt;br /&gt;
    // If user identity is not blank, pause for a random amount of time&lt;br /&gt;
    if ( objApp.User.Identity.Name != &amp;quot;&amp;quot;)&lt;br /&gt;
      {&lt;br /&gt;
        Random rand = new Random();        &lt;br /&gt;
        Thread.Sleep(rand.Next(minSeconds, maxSeconds) * 1000);&lt;br /&gt;
      }      &lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
===Figure 2: Password Authentication Delay: VB.NET===&lt;br /&gt;
&lt;br /&gt;
 Public Sub AuthenticateRequest(ByVal obj As Object, ByVal ea As System.EventArgs)&lt;br /&gt;
  Dim objApp As HttpApplication&lt;br /&gt;
  Dim objContext As HttpContext&lt;br /&gt;
  Dim ran As Random&lt;br /&gt;
  objApp = obj&lt;br /&gt;
  objContext = objApp.Context&lt;br /&gt;
 &lt;br /&gt;
  ' If user identity is not blank, pause for a random amount of time&lt;br /&gt;
  If objApp.User.Identity.Name &amp;lt;&amp;gt; &amp;quot;&amp;quot; Then&lt;br /&gt;
    ran = New Random&lt;br /&gt;
    Thread.Sleep(ran.Next(ran.Next(minSeconds, maxSeconds) * 1000))&lt;br /&gt;
  End If&lt;br /&gt;
 End Sub&lt;br /&gt;
&lt;br /&gt;
----&lt;br /&gt;
&lt;br /&gt;
Mark Burnett (mburnett@xato.net) is an independent security consultant and author who specializes in Windows and web server security. He is an IIS MVP and author of Hacking the Code (Syngress Publishing).&lt;br /&gt;
&lt;br /&gt;
Hacking the Code, written by Mark Burnett, is a unique book that walks you through the many security threats facing ASP.NET web developers. The book provides concise solutions, code examples, and security policy to address each of these threats threat.&lt;br /&gt;
&lt;br /&gt;
[[Category:OWASP Columns]]&lt;br /&gt;
[[Category: Control]]&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Slow_Down_Brute_Force_Attacks_with_Device_Cookies&amp;diff=190769</id>
		<title>Slow Down Brute Force Attacks with Device Cookies</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Slow_Down_Brute_Force_Attacks_with_Device_Cookies&amp;diff=190769"/>
				<updated>2015-03-04T14:18:05Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: Add as alias with &amp;quot;Brute Force Attack&amp;quot; in title instead of &amp;quot;Online Guessing Attack&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;#REDIRECT [[Slow_Down_Online_Guessing_Attacks_with_Device_Cookies]]&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Talk:Blocking_Brute_Force_Attacks&amp;diff=190527</id>
		<title>Talk:Blocking Brute Force Attacks</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Talk:Blocking_Brute_Force_Attacks&amp;diff=190527"/>
				<updated>2015-03-02T08:53:31Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: Created page with &amp;quot;Hi! I'd like to add link to Slow_Down_Online_Guessing_Attacks_with_Device_Cookies article into Locking Account section as alternative way to lock accounts that still resis...&amp;quot;&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Hi! I'd like to add link to [[Slow_Down_Online_Guessing_Attacks_with_Device_Cookies]] article into Locking Account section as alternative way to lock accounts that still resistant to most modes of DoS attacks.&lt;br /&gt;
--[[User:Adedov|Adedov]] ([[User talk:Adedov|talk]]) 02:53, 2 March 2015 (CST)&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=190324</id>
		<title>Slow Down Online Guessing Attacks with Device Cookies</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=190324"/>
				<updated>2015-02-26T09:37:11Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: Change links to video.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Control]][[Category:Authentication]]&lt;br /&gt;
==Intro==&lt;br /&gt;
Device cookies as additional authenticator for users devices have been discussed and used in practice for some time already. For example, it was discussed by Marc Heuse at [http://video.adm.ntnu.no/serier/5493ea75d5589 PasswordsCon 14]. Marc speculates on various techniques for blocking online attacks and comes to notion of &amp;quot;device cookie&amp;quot; as good protection alternative (see his [http://video.adm.ntnu.no/pres/549401c165887 talk] on Hydra at PasswordsCon 14, specifically from 32:50). As well as Alec Muffett at the same conference mentions &amp;quot;datr cookie&amp;quot; from Facebook (look from 10:15 of his [http://video.adm.ntnu.no/pres/54b660049af94 talk]). &lt;br /&gt;
&lt;br /&gt;
The main idea behind the protocol is to issue a special “device” cookie to every client (browser) when it is used to successfully authenticate a user in a system. The device cookie can be used to:&lt;br /&gt;
* Distinguish between known/trusted and unknown/untrusted clients&lt;br /&gt;
* Establish universal temporary lockouts for all untrusted clients&lt;br /&gt;
* Lockout trusted clients individually.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
There are few well-known ways to [[Blocking_Brute_Force_Attacks|deal with online attacks]]:&lt;br /&gt;
* Temporary account lockout&lt;br /&gt;
* Use CAPTCHA to slow down attacker&lt;br /&gt;
&lt;br /&gt;
Other tricks, like producing confusing answers for attacker are more like “security by obscurity” and cannot be used as first-class protection mechanism.&lt;br /&gt;
&lt;br /&gt;
Temporary account lockout after several failed attempts is too simple of a target for DoS attacks against legitimate users. There is variation of this method that locks out pair of account/IP. It is better in regarding to DoS issues but have security downsides:&lt;br /&gt;
* Attacks from botnets can be effective&lt;br /&gt;
* Attacks through proxies can be effective&lt;br /&gt;
&lt;br /&gt;
Moreover, it is not so trivial to implement account/IP lockout. Consider multiple proxies with chaining addresses in “X-Forwarded-For” header or IPv6.&lt;br /&gt;
&lt;br /&gt;
The method described in this writing may be viewed as variant of account/IP blocking. But it proposes to use a browser cookie instead of an IP address. Thus it may be more predictable from security perspective and easier to implement.&lt;br /&gt;
&lt;br /&gt;
==Protocol==&lt;br /&gt;
Protocol parameters:&lt;br /&gt;
* T - time period&lt;br /&gt;
* N - max number of authentication attempts allowed during ''T'' &lt;br /&gt;
&lt;br /&gt;
The sign ∎ hereafter states for end of algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Entry point for authentication request'''&lt;br /&gt;
# if the incoming request contains a device cookie:&lt;br /&gt;
#: a. ''validate device cookie''&lt;br /&gt;
#: b. if the device cookie is valid and not in the lockout list&lt;br /&gt;
#:: ''authenticate user''∎&lt;br /&gt;
# if authentication from untrusted clients is locked out for the specific user&lt;br /&gt;
#: reject authentication attempt∎&lt;br /&gt;
# else&lt;br /&gt;
#: ''authenticate user''∎&lt;br /&gt;
&lt;br /&gt;
'''Authenticate user'''&lt;br /&gt;
# check user credentials&lt;br /&gt;
# if credentials are valid&lt;br /&gt;
#: a. ''issue new device cookie to user’s client''&lt;br /&gt;
#: b. proceed with authenticated user&lt;br /&gt;
# else&lt;br /&gt;
#: a. ''register failed authentication attempt''&lt;br /&gt;
#: b. finish with failed user’s authentication&lt;br /&gt;
&lt;br /&gt;
'''Register failed authentication attempt'''&lt;br /&gt;
# register a failed authentication attempt with following information: { user, time, device cookie (if present) }.&lt;br /&gt;
# depending on whether a valid device cookie is present in the request, count the number of failed authentication attempts within period ''T'' either for&lt;br /&gt;
#: a. all untrusted clients&lt;br /&gt;
#: '''or'''&lt;br /&gt;
#: b. a specific device cookie&lt;br /&gt;
# if number of failed attempts within period ''T'' &amp;gt; ''N''&lt;br /&gt;
#: a. if a valid device cookie is presented&lt;br /&gt;
#:: put the device cookie into the lockout list for device cookies until now+''T''&lt;br /&gt;
#: b. else&lt;br /&gt;
#:: lockout all authentication attempts for a specific user from all untrusted clients until now+''T''&lt;br /&gt;
&lt;br /&gt;
'''Issue new device cookie to user’s client'''&lt;br /&gt;
Issue a browser cookie with a value like “LOGIN,NONCE,SIGNATURE”, where&lt;br /&gt;
* LOGIN - user’s login name (or internal ID) corresponding to an authenticated user&lt;br /&gt;
* NONCE - nonce of sufficient length or random value from CSRNG source &lt;br /&gt;
* SIGNATURE - HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
* secret-key - server’s secret cryptographic key.&lt;br /&gt;
&lt;br /&gt;
'''Validate device cookie'''&lt;br /&gt;
# Validate that the device cookie is formatted as described above&lt;br /&gt;
# Validate that SIGNATURE == HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
# Validate that LOGIN represents the user who is actually trying to authenticate&lt;br /&gt;
&lt;br /&gt;
===Notes===&lt;br /&gt;
* Putting the device cookie in a lockout list has the same effect as if the client had no device cookie. So clients with device cookies are potentially allowed to make ''N'' * 2 failed authentication attempts before actual lockout.&lt;br /&gt;
* Issuing a new device cookie after each successful authentication allows us to avoid making decisions in situations like - “Should the system block a device cookie if there were registered ''N''-1 failed attempts, then one successful authentication, and then again 1 failed attempt? All within period ''T''.”&lt;br /&gt;
&lt;br /&gt;
==Threat Analysis==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:20%&amp;quot; | Threat&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Threat details&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Mitigation&lt;br /&gt;
|-&lt;br /&gt;
| Online attack against one user&lt;br /&gt;
| Attacker performs a guessing attack against a specific account from an untrusted client(s).&lt;br /&gt;
| As long as the lockout for untrusted clients blocks authN attempts for a specific user from all untrusted clients, the number of guesses is restricted with (''N/T'')*24h per day.&lt;br /&gt;
&lt;br /&gt;
E.g. for ''N'' = 10 and ''T'' = 1h, any attacker will be limited with 240 attempts per day per user or 87600 attempts per user/year regardless of how large the botnet in his possession is.&lt;br /&gt;
&lt;br /&gt;
If there is a [http://password-policy-testing.wikidot.com/results#toc5 good password policy] in place that limits minimum number attempts to [http://research.microsoft.com/pubs/227130/WhatsaSysadminToDo.pdf 10&amp;lt;sup&amp;gt;6&amp;lt;/sup&amp;gt;] then the targeted attack will last (on average) 5 years.&lt;br /&gt;
|-&lt;br /&gt;
| Online attack using stolen device cookies&lt;br /&gt;
| Attacker performs long-running guessing attack against specific account(s) from known clients.&lt;br /&gt;
&lt;br /&gt;
Using valid device cookies allows the attacker to scale attacks linearly, e.g. each device cookie adds extra ''N'' attempts per ''T'' for specific user.&lt;br /&gt;
| There may be two ways to steal device cookies:&lt;br /&gt;
* Using physical access to a known client&lt;br /&gt;
* Active attack against a remote client&lt;br /&gt;
&lt;br /&gt;
In both cases if the attacker can steal device cookies on a regular basis he may have enough power to steal not only device cookies but also session cookies or even passwords. However in our security model this attack is irrelevant if device cookies are adequately protected (use '''Secure''' and '''HttpOnly''' flags).&lt;br /&gt;
&lt;br /&gt;
'''Proposal''': Accidental access to one device cookie contributes little to attack speed. Applications may implement persistent lockout for certain device cookies to address such cases. E.g. permanently lockout a device cookie after ''N''*10 failed attempts.&lt;br /&gt;
|- style=&amp;quot;background-color:#f5e68d;&amp;quot; &lt;br /&gt;
| Online attack against multiple users&lt;br /&gt;
| Attacker performs guessing attack against a specific number of accounts from untrusted clients.&lt;br /&gt;
&lt;br /&gt;
Attacker may try the same password from a long list against many (all) accounts in a system without reaching ''N'' failed attempts per account during period ''T''.&lt;br /&gt;
| There is no specific mitigation for this threat in the protocol.&lt;br /&gt;
&lt;br /&gt;
Good password policy may be a sufficient countermeasure for such attacks.&lt;br /&gt;
&lt;br /&gt;
Additionally an application may temporarily require CAPTCHA solving for authentication from '''untrusted''' clients in case there are too many authentication attempts for different accounts during a specified period of time.&lt;br /&gt;
|-&lt;br /&gt;
| Spoof device cookie&lt;br /&gt;
| Attacker may try to forge a valid device cookie for any user in a system.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|-&lt;br /&gt;
| Tamper with existing device cookie&lt;br /&gt;
| Attacker may try to tamper with a device cookie valid for one user to make it suitable for another.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|- style=&amp;quot;background-color:#f5e68d;&amp;quot;&lt;br /&gt;
| DoS for specific account &lt;br /&gt;
| Attackers may cause permanent lockout for all untrusted devices for a specific user. Thus the user may be blocked from loggging into the system as he would need to login from a '''new device''' or to login after '''cleaning up his browser cache'''.&lt;br /&gt;
| No mitigation yet.&lt;br /&gt;
&lt;br /&gt;
'''Proposal:''' Issue a valid device cookie after visiting password reset link (an actual password reset would not be necessary). Thus, if the user demonstrates his possession of a personal email account then the system may trust his client to enter credentials.&lt;br /&gt;
|-&lt;br /&gt;
| DoS for specific account when client is used by different accounts&lt;br /&gt;
| There are situations when the same client is legitimately used to authenticate different users. For example, a family-shared PC or tablet. Thus, after successful authentication of one user another legitimate user will be treated as user of untrusted client and will be susceptible to a DoS attack.&lt;br /&gt;
| Cases where the same client is shared between legitimate users may be considered out of scope by default.&lt;br /&gt;
&lt;br /&gt;
If such cases are critical for application usability, it may deal with them by issuing device cookies with names that contain LOGIN and analyze them accordingly. &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=190261</id>
		<title>Slow Down Online Guessing Attacks with Device Cookies</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=190261"/>
				<updated>2015-02-25T10:14:59Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: Categorisation&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Category:Control]][[Category:Authentication]]&lt;br /&gt;
==Intro==&lt;br /&gt;
Device cookies as additional authenticator for users devices have been discussed and used in practice for some time already. For example, it was discussed by Marc Heuse at [http://new.livestream.com/NTNU/passwords14 PasswordsCon 14]. Marc speculates on various techniques for blocking online attacks and comes to notion of &amp;quot;device cookie&amp;quot; as good protection alternative (see his talk on Hydra at PasswordsCon 14 [http://new.livestream.com/NTNU/passwords14/videos/70678187 day 1], specifically from 00:43:00). As well as Alec Muffett at the same conference mentions &amp;quot;datr cookie&amp;quot; from Facebook (look from 4:22:00 at PasswordCon 14 [http://new.livestream.com/NTNU/passwords14/videos/70751388 day 3]). &lt;br /&gt;
&lt;br /&gt;
The main idea behind the protocol is to issue a special “device” cookie to every client (browser) when it is used to successfully authenticate a user in a system. The device cookie can be used to:&lt;br /&gt;
* Distinguish between known/trusted and unknown/untrusted clients&lt;br /&gt;
* Establish universal temporary lockouts for all untrusted clients&lt;br /&gt;
* Lockout trusted clients individually.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
There are few well-known ways to [[Blocking_Brute_Force_Attacks|deal with online attacks]]:&lt;br /&gt;
* Temporary account lockout&lt;br /&gt;
* Use CAPTCHA to slow down attacker&lt;br /&gt;
&lt;br /&gt;
Other tricks, like producing confusing answers for attacker are more like “security by obscurity” and cannot be used as first-class protection mechanism.&lt;br /&gt;
&lt;br /&gt;
Temporary account lockout after several failed attempts is too simple of a target for DoS attacks against legitimate users. There is variation of this method that locks out pair of account/IP. It is better in regarding to DoS issues but have security downsides:&lt;br /&gt;
* Attacks from botnets can be effective&lt;br /&gt;
* Attacks through proxies can be effective&lt;br /&gt;
&lt;br /&gt;
Moreover, it is not so trivial to implement account/IP lockout. Consider multiple proxies with chaining addresses in “X-Forwarded-For” header or IPv6.&lt;br /&gt;
&lt;br /&gt;
The method described in this writing may be viewed as variant of account/IP blocking. But it proposes to use a browser cookie instead of an IP address. Thus it may be more predictable from security perspective and easier to implement.&lt;br /&gt;
&lt;br /&gt;
==Protocol==&lt;br /&gt;
Protocol parameters:&lt;br /&gt;
* T - time period&lt;br /&gt;
* N - max number of authentication attempts allowed during ''T'' &lt;br /&gt;
&lt;br /&gt;
The sign ∎ hereafter states for end of algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Entry point for authentication request'''&lt;br /&gt;
# if the incoming request contains a device cookie:&lt;br /&gt;
#: a. ''validate device cookie''&lt;br /&gt;
#: b. if the device cookie is valid and not in the lockout list&lt;br /&gt;
#:: ''authenticate user''∎&lt;br /&gt;
# if authentication from untrusted clients is locked out for the specific user&lt;br /&gt;
#: reject authentication attempt∎&lt;br /&gt;
# else&lt;br /&gt;
#: ''authenticate user''∎&lt;br /&gt;
&lt;br /&gt;
'''Authenticate user'''&lt;br /&gt;
# check user credentials&lt;br /&gt;
# if credentials are valid&lt;br /&gt;
#: a. ''issue new device cookie to user’s client''&lt;br /&gt;
#: b. proceed with authenticated user&lt;br /&gt;
# else&lt;br /&gt;
#: a. ''register failed authentication attempt''&lt;br /&gt;
#: b. finish with failed user’s authentication&lt;br /&gt;
&lt;br /&gt;
'''Register failed authentication attempt'''&lt;br /&gt;
# register a failed authentication attempt with following information: { user, time, device cookie (if present) }.&lt;br /&gt;
# depending on whether a valid device cookie is present in the request, count the number of failed authentication attempts within period ''T'' either for&lt;br /&gt;
#: a. all untrusted clients&lt;br /&gt;
#: '''or'''&lt;br /&gt;
#: b. a specific device cookie&lt;br /&gt;
# if number of failed attempts within period ''T'' &amp;gt; ''N''&lt;br /&gt;
#: a. if a valid device cookie is presented&lt;br /&gt;
#:: put the device cookie into the lockout list for device cookies until now+''T''&lt;br /&gt;
#: b. else&lt;br /&gt;
#:: lockout all authentication attempts for a specific user from all untrusted clients until now+''T''&lt;br /&gt;
&lt;br /&gt;
'''Issue new device cookie to user’s client'''&lt;br /&gt;
Issue a browser cookie with a value like “LOGIN,NONCE,SIGNATURE”, where&lt;br /&gt;
* LOGIN - user’s login name (or internal ID) corresponding to an authenticated user&lt;br /&gt;
* NONCE - nonce of sufficient length or random value from CSRNG source &lt;br /&gt;
* SIGNATURE - HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
* secret-key - server’s secret cryptographic key.&lt;br /&gt;
&lt;br /&gt;
'''Validate device cookie'''&lt;br /&gt;
# Validate that the device cookie is formatted as described above&lt;br /&gt;
# Validate that SIGNATURE == HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
# Validate that LOGIN represents the user who is actually trying to authenticate&lt;br /&gt;
&lt;br /&gt;
===Notes===&lt;br /&gt;
* Putting the device cookie in a lockout list has the same effect as if the client had no device cookie. So clients with device cookies are potentially allowed to make ''N'' * 2 failed authentication attempts before actual lockout.&lt;br /&gt;
* Issuing a new device cookie after each successful authentication allows us to avoid making decisions in situations like - “Should the system block a device cookie if there were registered ''N''-1 failed attempts, then one successful authentication, and then again 1 failed attempt? All within period ''T''.”&lt;br /&gt;
&lt;br /&gt;
==Threat Analysis==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:20%&amp;quot; | Threat&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Threat details&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Mitigation&lt;br /&gt;
|-&lt;br /&gt;
| Online attack against one user&lt;br /&gt;
| Attacker performs a guessing attack against a specific account from an untrusted client(s).&lt;br /&gt;
| As long as the lockout for untrusted clients blocks authN attempts for a specific user from all untrusted clients, the number of guesses is restricted with (''N/T'')*24h per day.&lt;br /&gt;
&lt;br /&gt;
E.g. for ''N'' = 10 and ''T'' = 1h, any attacker will be limited with 240 attempts per day per user or 87600 attempts per user/year regardless of how large the botnet in his possession is.&lt;br /&gt;
&lt;br /&gt;
If there is a [http://password-policy-testing.wikidot.com/results#toc5 good password policy] in place that limits minimum number attempts to [http://research.microsoft.com/pubs/227130/WhatsaSysadminToDo.pdf 10&amp;lt;sup&amp;gt;6&amp;lt;/sup&amp;gt;] then the targeted attack will last (on average) 5 years.&lt;br /&gt;
|-&lt;br /&gt;
| Online attack using stolen device cookies&lt;br /&gt;
| Attacker performs long-running guessing attack against specific account(s) from known clients.&lt;br /&gt;
&lt;br /&gt;
Using valid device cookies allows the attacker to scale attacks linearly, e.g. each device cookie adds extra ''N'' attempts per ''T'' for specific user.&lt;br /&gt;
| There may be two ways to steal device cookies:&lt;br /&gt;
* Using physical access to a known client&lt;br /&gt;
* Active attack against a remote client&lt;br /&gt;
&lt;br /&gt;
In both cases if the attacker can steal device cookies on a regular basis he may have enough power to steal not only device cookies but also session cookies or even passwords. However in our security model this attack is irrelevant if device cookies are adequately protected (use '''Secure''' and '''HttpOnly''' flags).&lt;br /&gt;
&lt;br /&gt;
'''Proposal''': Accidental access to one device cookie contributes little to attack speed. Applications may implement persistent lockout for certain device cookies to address such cases. E.g. permanently lockout a device cookie after ''N''*10 failed attempts.&lt;br /&gt;
|- style=&amp;quot;background-color:#f5e68d;&amp;quot; &lt;br /&gt;
| Online attack against multiple users&lt;br /&gt;
| Attacker performs guessing attack against a specific number of accounts from untrusted clients.&lt;br /&gt;
&lt;br /&gt;
Attacker may try the same password from a long list against many (all) accounts in a system without reaching ''N'' failed attempts per account during period ''T''.&lt;br /&gt;
| There is no specific mitigation for this threat in the protocol.&lt;br /&gt;
&lt;br /&gt;
Good password policy may be a sufficient countermeasure for such attacks.&lt;br /&gt;
&lt;br /&gt;
Additionally an application may temporarily require CAPTCHA solving for authentication from '''untrusted''' clients in case there are too many authentication attempts for different accounts during a specified period of time.&lt;br /&gt;
|-&lt;br /&gt;
| Spoof device cookie&lt;br /&gt;
| Attacker may try to forge a valid device cookie for any user in a system.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|-&lt;br /&gt;
| Tamper with existing device cookie&lt;br /&gt;
| Attacker may try to tamper with a device cookie valid for one user to make it suitable for another.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|- style=&amp;quot;background-color:#f5e68d;&amp;quot;&lt;br /&gt;
| DoS for specific account &lt;br /&gt;
| Attackers may cause permanent lockout for all untrusted devices for a specific user. Thus the user may be blocked from loggging into the system as he would need to login from a '''new device''' or to login after '''cleaning up his browser cache'''.&lt;br /&gt;
| No mitigation yet.&lt;br /&gt;
&lt;br /&gt;
'''Proposal:''' Issue a valid device cookie after visiting password reset link (an actual password reset would not be necessary). Thus, if the user demonstrates his possession of a personal email account then the system may trust his client to enter credentials.&lt;br /&gt;
|-&lt;br /&gt;
| DoS for specific account when client is used by different accounts&lt;br /&gt;
| There are situations when the same client is legitimately used to authenticate different users. For example, a family-shared PC or tablet. Thus, after successful authentication of one user another legitimate user will be treated as user of untrusted client and will be susceptible to a DoS attack.&lt;br /&gt;
| Cases where the same client is shared between legitimate users may be considered out of scope by default.&lt;br /&gt;
&lt;br /&gt;
If such cases are critical for application usability, it may deal with them by issuing device cookies with names that contain LOGIN and analyze them accordingly. &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=190260</id>
		<title>Slow Down Online Guessing Attacks with Device Cookies</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=190260"/>
				<updated>2015-02-25T09:16:57Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: /* Intro */&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Intro==&lt;br /&gt;
Device cookies as additional authenticator for users devices have been discussed and used in practice for some time already. For example, it was discussed by Marc Heuse at [http://new.livestream.com/NTNU/passwords14 PasswordsCon 14]. Marc speculates on various techniques for blocking online attacks and comes to notion of &amp;quot;device cookie&amp;quot; as good protection alternative (see his talk on Hydra at PasswordsCon 14 [http://new.livestream.com/NTNU/passwords14/videos/70678187 day 1], specifically from 00:43:00). As well as Alec Muffett at the same conference mentions &amp;quot;datr cookie&amp;quot; from Facebook (look from 4:22:00 at PasswordCon 14 [http://new.livestream.com/NTNU/passwords14/videos/70751388 day 3]). &lt;br /&gt;
&lt;br /&gt;
The main idea behind the protocol is to issue a special “device” cookie to every client (browser) when it is used to successfully authenticate a user in a system. The device cookie can be used to:&lt;br /&gt;
* Distinguish between known/trusted and unknown/untrusted clients&lt;br /&gt;
* Establish universal temporary lockouts for all untrusted clients&lt;br /&gt;
* Lockout trusted clients individually.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
There are few well-known ways to [[Blocking_Brute_Force_Attacks|deal with online attacks]]:&lt;br /&gt;
* Temporary account lockout&lt;br /&gt;
* Use CAPTCHA to slow down attacker&lt;br /&gt;
&lt;br /&gt;
Other tricks, like producing confusing answers for attacker are more like “security by obscurity” and cannot be used as first-class protection mechanism.&lt;br /&gt;
&lt;br /&gt;
Temporary account lockout after several failed attempts is too simple of a target for DoS attacks against legitimate users. There is variation of this method that locks out pair of account/IP. It is better in regarding to DoS issues but have security downsides:&lt;br /&gt;
* Attacks from botnets can be effective&lt;br /&gt;
* Attacks through proxies can be effective&lt;br /&gt;
&lt;br /&gt;
Moreover, it is not so trivial to implement account/IP lockout. Consider multiple proxies with chaining addresses in “X-Forwarded-For” header or IPv6.&lt;br /&gt;
&lt;br /&gt;
The method described in this writing may be viewed as variant of account/IP blocking. But it proposes to use a browser cookie instead of an IP address. Thus it may be more predictable from security perspective and easier to implement.&lt;br /&gt;
&lt;br /&gt;
==Protocol==&lt;br /&gt;
Protocol parameters:&lt;br /&gt;
* T - time period&lt;br /&gt;
* N - max number of authentication attempts allowed during ''T'' &lt;br /&gt;
&lt;br /&gt;
The sign ∎ hereafter states for end of algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Entry point for authentication request'''&lt;br /&gt;
# if the incoming request contains a device cookie:&lt;br /&gt;
#: a. ''validate device cookie''&lt;br /&gt;
#: b. if the device cookie is valid and not in the lockout list&lt;br /&gt;
#:: ''authenticate user''∎&lt;br /&gt;
# if authentication from untrusted clients is locked out for the specific user&lt;br /&gt;
#: reject authentication attempt∎&lt;br /&gt;
# else&lt;br /&gt;
#: ''authenticate user''∎&lt;br /&gt;
&lt;br /&gt;
'''Authenticate user'''&lt;br /&gt;
# check user credentials&lt;br /&gt;
# if credentials are valid&lt;br /&gt;
#: a. ''issue new device cookie to user’s client''&lt;br /&gt;
#: b. proceed with authenticated user&lt;br /&gt;
# else&lt;br /&gt;
#: a. ''register failed authentication attempt''&lt;br /&gt;
#: b. finish with failed user’s authentication&lt;br /&gt;
&lt;br /&gt;
'''Register failed authentication attempt'''&lt;br /&gt;
# register a failed authentication attempt with following information: { user, time, device cookie (if present) }.&lt;br /&gt;
# depending on whether a valid device cookie is present in the request, count the number of failed authentication attempts within period ''T'' either for&lt;br /&gt;
#: a. all untrusted clients&lt;br /&gt;
#: '''or'''&lt;br /&gt;
#: b. a specific device cookie&lt;br /&gt;
# if number of failed attempts within period ''T'' &amp;gt; ''N''&lt;br /&gt;
#: a. if a valid device cookie is presented&lt;br /&gt;
#:: put the device cookie into the lockout list for device cookies until now+''T''&lt;br /&gt;
#: b. else&lt;br /&gt;
#:: lockout all authentication attempts for a specific user from all untrusted clients until now+''T''&lt;br /&gt;
&lt;br /&gt;
'''Issue new device cookie to user’s client'''&lt;br /&gt;
Issue a browser cookie with a value like “LOGIN,NONCE,SIGNATURE”, where&lt;br /&gt;
* LOGIN - user’s login name (or internal ID) corresponding to an authenticated user&lt;br /&gt;
* NONCE - nonce of sufficient length or random value from CSRNG source &lt;br /&gt;
* SIGNATURE - HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
* secret-key - server’s secret cryptographic key.&lt;br /&gt;
&lt;br /&gt;
'''Validate device cookie'''&lt;br /&gt;
# Validate that the device cookie is formatted as described above&lt;br /&gt;
# Validate that SIGNATURE == HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
# Validate that LOGIN represents the user who is actually trying to authenticate&lt;br /&gt;
&lt;br /&gt;
===Notes===&lt;br /&gt;
* Putting the device cookie in a lockout list has the same effect as if the client had no device cookie. So clients with device cookies are potentially allowed to make ''N'' * 2 failed authentication attempts before actual lockout.&lt;br /&gt;
* Issuing a new device cookie after each successful authentication allows us to avoid making decisions in situations like - “Should the system block a device cookie if there were registered ''N''-1 failed attempts, then one successful authentication, and then again 1 failed attempt? All within period ''T''.”&lt;br /&gt;
&lt;br /&gt;
==Threat Analysis==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:20%&amp;quot; | Threat&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Threat details&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Mitigation&lt;br /&gt;
|-&lt;br /&gt;
| Online attack against one user&lt;br /&gt;
| Attacker performs a guessing attack against a specific account from an untrusted client(s).&lt;br /&gt;
| As long as the lockout for untrusted clients blocks authN attempts for a specific user from all untrusted clients, the number of guesses is restricted with (''N/T'')*24h per day.&lt;br /&gt;
&lt;br /&gt;
E.g. for ''N'' = 10 and ''T'' = 1h, any attacker will be limited with 240 attempts per day per user or 87600 attempts per user/year regardless of how large the botnet in his possession is.&lt;br /&gt;
&lt;br /&gt;
If there is a [http://password-policy-testing.wikidot.com/results#toc5 good password policy] in place that limits minimum number attempts to [http://research.microsoft.com/pubs/227130/WhatsaSysadminToDo.pdf 10&amp;lt;sup&amp;gt;6&amp;lt;/sup&amp;gt;] then the targeted attack will last (on average) 5 years.&lt;br /&gt;
|-&lt;br /&gt;
| Online attack using stolen device cookies&lt;br /&gt;
| Attacker performs long-running guessing attack against specific account(s) from known clients.&lt;br /&gt;
&lt;br /&gt;
Using valid device cookies allows the attacker to scale attacks linearly, e.g. each device cookie adds extra ''N'' attempts per ''T'' for specific user.&lt;br /&gt;
| There may be two ways to steal device cookies:&lt;br /&gt;
* Using physical access to a known client&lt;br /&gt;
* Active attack against a remote client&lt;br /&gt;
&lt;br /&gt;
In both cases if the attacker can steal device cookies on a regular basis he may have enough power to steal not only device cookies but also session cookies or even passwords. However in our security model this attack is irrelevant if device cookies are adequately protected (use '''Secure''' and '''HttpOnly''' flags).&lt;br /&gt;
&lt;br /&gt;
'''Proposal''': Accidental access to one device cookie contributes little to attack speed. Applications may implement persistent lockout for certain device cookies to address such cases. E.g. permanently lockout a device cookie after ''N''*10 failed attempts.&lt;br /&gt;
|- style=&amp;quot;background-color:#f5e68d;&amp;quot; &lt;br /&gt;
| Online attack against multiple users&lt;br /&gt;
| Attacker performs guessing attack against a specific number of accounts from untrusted clients.&lt;br /&gt;
&lt;br /&gt;
Attacker may try the same password from a long list against many (all) accounts in a system without reaching ''N'' failed attempts per account during period ''T''.&lt;br /&gt;
| There is no specific mitigation for this threat in the protocol.&lt;br /&gt;
&lt;br /&gt;
Good password policy may be a sufficient countermeasure for such attacks.&lt;br /&gt;
&lt;br /&gt;
Additionally an application may temporarily require CAPTCHA solving for authentication from '''untrusted''' clients in case there are too many authentication attempts for different accounts during a specified period of time.&lt;br /&gt;
|-&lt;br /&gt;
| Spoof device cookie&lt;br /&gt;
| Attacker may try to forge a valid device cookie for any user in a system.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|-&lt;br /&gt;
| Tamper with existing device cookie&lt;br /&gt;
| Attacker may try to tamper with a device cookie valid for one user to make it suitable for another.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|- style=&amp;quot;background-color:#f5e68d;&amp;quot;&lt;br /&gt;
| DoS for specific account &lt;br /&gt;
| Attackers may cause permanent lockout for all untrusted devices for a specific user. Thus the user may be blocked from loggging into the system as he would need to login from a '''new device''' or to login after '''cleaning up his browser cache'''.&lt;br /&gt;
| No mitigation yet.&lt;br /&gt;
&lt;br /&gt;
'''Proposal:''' Issue a valid device cookie after visiting password reset link (an actual password reset would not be necessary). Thus, if the user demonstrates his possession of a personal email account then the system may trust his client to enter credentials.&lt;br /&gt;
|-&lt;br /&gt;
| DoS for specific account when client is used by different accounts&lt;br /&gt;
| There are situations when the same client is legitimately used to authenticate different users. For example, a family-shared PC or tablet. Thus, after successful authentication of one user another legitimate user will be treated as user of untrusted client and will be susceptible to a DoS attack.&lt;br /&gt;
| Cases where the same client is shared between legitimate users may be considered out of scope by default.&lt;br /&gt;
&lt;br /&gt;
If such cases are critical for application usability, it may deal with them by issuing device cookies with names that contain LOGIN and analyze them accordingly. &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=190244</id>
		<title>Slow Down Online Guessing Attacks with Device Cookies</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=Slow_Down_Online_Guessing_Attacks_with_Device_Cookies&amp;diff=190244"/>
				<updated>2015-02-24T21:50:34Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: Initial version of article.&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;==Intro==&lt;br /&gt;
This is ''by no means'' my idea. I’ve overheard the term “device cookie” from Marc Heuse at PasswordsCon 14, also Alec Muffett mentioned “datr” cookie from Facebook in his talk at the same conference. So, the only purpose for this writing is to put the idea into ready-to-implement condition and to raise public discussion about its security or may be insecurity and scarce usefulness.&lt;br /&gt;
&lt;br /&gt;
The main idea behind the protocol is to issue a special “device” cookie to every client (browser) when it is used to successfully authenticate a user in a system. The device cookie can be used to:&lt;br /&gt;
* Distinguish between known/trusted and unknown/untrusted clients&lt;br /&gt;
* Establish universal temporary lockouts for all untrusted clients&lt;br /&gt;
* Lockout trusted clients individually.&lt;br /&gt;
&lt;br /&gt;
==Why?==&lt;br /&gt;
There are few well-known ways to [[Blocking_Brute_Force_Attacks|deal with online attacks]]:&lt;br /&gt;
* Temporary account lockout&lt;br /&gt;
* Use CAPTCHA to slow down attacker&lt;br /&gt;
&lt;br /&gt;
Other tricks, like producing confusing answers for attacker are more like “security by obscurity” and cannot be used as first-class protection mechanism.&lt;br /&gt;
&lt;br /&gt;
Temporary account lockout after several failed attempts is too simple of a target for DoS attacks against legitimate users. There is variation of this method that locks out pair of account/IP. It is better in regarding to DoS issues but have security downsides:&lt;br /&gt;
* Attacks from botnets can be effective&lt;br /&gt;
* Attacks through proxies can be effective&lt;br /&gt;
&lt;br /&gt;
Moreover, it is not so trivial to implement account/IP lockout. Consider multiple proxies with chaining addresses in “X-Forwarded-For” header or IPv6.&lt;br /&gt;
&lt;br /&gt;
The method described in this writing may be viewed as variant of account/IP blocking. But it proposes to use a browser cookie instead of an IP address. Thus it may be more predictable from security perspective and easier to implement.&lt;br /&gt;
&lt;br /&gt;
==Protocol==&lt;br /&gt;
Protocol parameters:&lt;br /&gt;
* T - time period&lt;br /&gt;
* N - max number of authentication attempts allowed during ''T'' &lt;br /&gt;
&lt;br /&gt;
The sign ∎ hereafter states for end of algorithm.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Entry point for authentication request'''&lt;br /&gt;
# if the incoming request contains a device cookie:&lt;br /&gt;
#: a. ''validate device cookie''&lt;br /&gt;
#: b. if the device cookie is valid and not in the lockout list&lt;br /&gt;
#:: ''authenticate user''∎&lt;br /&gt;
# if authentication from untrusted clients is locked out for the specific user&lt;br /&gt;
#: reject authentication attempt∎&lt;br /&gt;
# else&lt;br /&gt;
#: ''authenticate user''∎&lt;br /&gt;
&lt;br /&gt;
'''Authenticate user'''&lt;br /&gt;
# check user credentials&lt;br /&gt;
# if credentials are valid&lt;br /&gt;
#: a. ''issue new device cookie to user’s client''&lt;br /&gt;
#: b. proceed with authenticated user&lt;br /&gt;
# else&lt;br /&gt;
#: a. ''register failed authentication attempt''&lt;br /&gt;
#: b. finish with failed user’s authentication&lt;br /&gt;
&lt;br /&gt;
'''Register failed authentication attempt'''&lt;br /&gt;
# register a failed authentication attempt with following information: { user, time, device cookie (if present) }.&lt;br /&gt;
# depending on whether a valid device cookie is present in the request, count the number of failed authentication attempts within period ''T'' either for&lt;br /&gt;
#: a. all untrusted clients&lt;br /&gt;
#: '''or'''&lt;br /&gt;
#: b. a specific device cookie&lt;br /&gt;
# if number of failed attempts within period ''T'' &amp;gt; ''N''&lt;br /&gt;
#: a. if a valid device cookie is presented&lt;br /&gt;
#:: put the device cookie into the lockout list for device cookies until now+''T''&lt;br /&gt;
#: b. else&lt;br /&gt;
#:: lockout all authentication attempts for a specific user from all untrusted clients until now+''T''&lt;br /&gt;
&lt;br /&gt;
'''Issue new device cookie to user’s client'''&lt;br /&gt;
Issue a browser cookie with a value like “LOGIN,NONCE,SIGNATURE”, where&lt;br /&gt;
* LOGIN - user’s login name (or internal ID) corresponding to an authenticated user&lt;br /&gt;
* NONCE - nonce of sufficient length or random value from CSRNG source &lt;br /&gt;
* SIGNATURE - HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
* secret-key - server’s secret cryptographic key.&lt;br /&gt;
&lt;br /&gt;
'''Validate device cookie'''&lt;br /&gt;
# Validate that the device cookie is formatted as described above&lt;br /&gt;
# Validate that SIGNATURE == HMAC(secret-key, “LOGIN,NONCE”)&lt;br /&gt;
# Validate that LOGIN represents the user who is actually trying to authenticate&lt;br /&gt;
&lt;br /&gt;
===Notes===&lt;br /&gt;
* Putting the device cookie in a lockout list has the same effect as if the client had no device cookie. So clients with device cookies are potentially allowed to make ''N'' * 2 failed authentication attempts before actual lockout.&lt;br /&gt;
* Issuing a new device cookie after each successful authentication allows us to avoid making decisions in situations like - “Should the system block a device cookie if there were registered ''N''-1 failed attempts, then one successful authentication, and then again 1 failed attempt? All within period ''T''.”&lt;br /&gt;
&lt;br /&gt;
==Threat Analysis==&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! style=&amp;quot;width:20%&amp;quot; | Threat&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Threat details&lt;br /&gt;
! style=&amp;quot;width:40%&amp;quot; | Mitigation&lt;br /&gt;
|-&lt;br /&gt;
| Online attack against one user&lt;br /&gt;
| Attacker performs a guessing attack against a specific account from an untrusted client(s).&lt;br /&gt;
| As long as the lockout for untrusted clients blocks authN attempts for a specific user from all untrusted clients, the number of guesses is restricted with (''N/T'')*24h per day.&lt;br /&gt;
&lt;br /&gt;
E.g. for ''N'' = 10 and ''T'' = 1h, any attacker will be limited with 240 attempts per day per user or 87600 attempts per user/year regardless of how large the botnet in his possession is.&lt;br /&gt;
&lt;br /&gt;
If there is a [http://password-policy-testing.wikidot.com/results#toc5 good password policy] in place that limits minimum number attempts to [http://research.microsoft.com/pubs/227130/WhatsaSysadminToDo.pdf 10&amp;lt;sup&amp;gt;6&amp;lt;/sup&amp;gt;] then the targeted attack will last (on average) 5 years.&lt;br /&gt;
|-&lt;br /&gt;
| Online attack using stolen device cookies&lt;br /&gt;
| Attacker performs long-running guessing attack against specific account(s) from known clients.&lt;br /&gt;
&lt;br /&gt;
Using valid device cookies allows the attacker to scale attacks linearly, e.g. each device cookie adds extra ''N'' attempts per ''T'' for specific user.&lt;br /&gt;
| There may be two ways to steal device cookies:&lt;br /&gt;
* Using physical access to a known client&lt;br /&gt;
* Active attack against a remote client&lt;br /&gt;
&lt;br /&gt;
In both cases if the attacker can steal device cookies on a regular basis he may have enough power to steal not only device cookies but also session cookies or even passwords. However in our security model this attack is irrelevant if device cookies are adequately protected (use '''Secure''' and '''HttpOnly''' flags).&lt;br /&gt;
&lt;br /&gt;
'''Proposal''': Accidental access to one device cookie contributes little to attack speed. Applications may implement persistent lockout for certain device cookies to address such cases. E.g. permanently lockout a device cookie after ''N''*10 failed attempts.&lt;br /&gt;
|- style=&amp;quot;background-color:#f5e68d;&amp;quot; &lt;br /&gt;
| Online attack against multiple users&lt;br /&gt;
| Attacker performs guessing attack against a specific number of accounts from untrusted clients.&lt;br /&gt;
&lt;br /&gt;
Attacker may try the same password from a long list against many (all) accounts in a system without reaching ''N'' failed attempts per account during period ''T''.&lt;br /&gt;
| There is no specific mitigation for this threat in the protocol.&lt;br /&gt;
&lt;br /&gt;
Good password policy may be a sufficient countermeasure for such attacks.&lt;br /&gt;
&lt;br /&gt;
Additionally an application may temporarily require CAPTCHA solving for authentication from '''untrusted''' clients in case there are too many authentication attempts for different accounts during a specified period of time.&lt;br /&gt;
|-&lt;br /&gt;
| Spoof device cookie&lt;br /&gt;
| Attacker may try to forge a valid device cookie for any user in a system.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|-&lt;br /&gt;
| Tamper with existing device cookie&lt;br /&gt;
| Attacker may try to tamper with a device cookie valid for one user to make it suitable for another.&lt;br /&gt;
| Proper crypto implementation: HMAC and random secret key.&lt;br /&gt;
|- style=&amp;quot;background-color:#f5e68d;&amp;quot;&lt;br /&gt;
| DoS for specific account &lt;br /&gt;
| Attackers may cause permanent lockout for all untrusted devices for a specific user. Thus the user may be blocked from loggging into the system as he would need to login from a '''new device''' or to login after '''cleaning up his browser cache'''.&lt;br /&gt;
| No mitigation yet.&lt;br /&gt;
&lt;br /&gt;
'''Proposal:''' Issue a valid device cookie after visiting password reset link (an actual password reset would not be necessary). Thus, if the user demonstrates his possession of a personal email account then the system may trust his client to enter credentials.&lt;br /&gt;
|-&lt;br /&gt;
| DoS for specific account when client is used by different accounts&lt;br /&gt;
| There are situations when the same client is legitimately used to authenticate different users. For example, a family-shared PC or tablet. Thus, after successful authentication of one user another legitimate user will be treated as user of untrusted client and will be susceptible to a DoS attack.&lt;br /&gt;
| Cases where the same client is shared between legitimate users may be considered out of scope by default.&lt;br /&gt;
&lt;br /&gt;
If such cases are critical for application usability, it may deal with them by issuing device cookies with names that contain LOGIN and analyze them accordingly. &lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	<entry>
		<id>https://wiki.owasp.org/index.php?title=User:Adedov&amp;diff=190193</id>
		<title>User:Adedov</title>
		<link rel="alternate" type="text/html" href="https://wiki.owasp.org/index.php?title=User:Adedov&amp;diff=190193"/>
				<updated>2015-02-24T12:54:45Z</updated>
		
		<summary type="html">&lt;p&gt;Adedov: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;I was born in central Siberia, Russia in 1978. I lived in various places at Siberia till 2010 then moved to Moscow.&lt;br /&gt;
&lt;br /&gt;
I am software developer at Parallels [http://cp.parallels.com] since 2005. In 2012 started working on product security. Also an open source developer and occasional researcher.&lt;br /&gt;
&lt;br /&gt;
Personal projects&lt;br /&gt;
* XML-RPC library for C++, [http://libiqxmlrpc.wikidot.com Libiqxmlrpc]&lt;br /&gt;
* [http://password-policy-testing.wikidot.com/ Password Policy Testing Framework]&lt;br /&gt;
&lt;br /&gt;
Twitter: @brutemorse&lt;/div&gt;</summary>
		<author><name>Adedov</name></author>	</entry>

	</feed>