19.09.2017 Views

the-web-application-hackers-handbook

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

200 Chapter 6 n Attacking Au<strong>the</strong>ntication<br />

n A well-designed password recovery mechanism needs to prevent accounts<br />

from being compromised by an unauthorized party and minimize any<br />

disruption to legitimate users.<br />

n Features such as password “hints” should never be used, because <strong>the</strong>y<br />

mainly help an attacker trawl for accounts that have obvious hints set.<br />

n The best automated solution for enabling users to regain control of accounts<br />

is to e-mail <strong>the</strong> user a unique, time-limited, unguessable, single-use recovery<br />

URL. This e-mail should be sent to <strong>the</strong> address that <strong>the</strong> user provided<br />

during registration. Visiting <strong>the</strong> URL allows <strong>the</strong> user to set a new password.<br />

After this has been done, a second e-mail should be sent, indicating<br />

that a password change was made. To prevent an attacker from denying<br />

service to users by continually requesting password reactivation e-mails,<br />

<strong>the</strong> user’s existing credentials should remain valid until <strong>the</strong>y are changed.<br />

n To fur<strong>the</strong>r protect against unauthorized access, <strong>application</strong>s may present<br />

users with a secondary challenge that <strong>the</strong>y must complete before gaining<br />

access to <strong>the</strong> password reset function. Be sure that <strong>the</strong> design of this<br />

challenge does not introduce new vulnerabilities:<br />

n The challenge should implement <strong>the</strong> same question or set of questions<br />

for everyone, mandated by <strong>the</strong> <strong>application</strong> during registration.<br />

If users provide <strong>the</strong>ir own challenge, it is likely that some of <strong>the</strong>se will<br />

be weak, and this also enables an attacker to enumerate valid accounts<br />

by identifying those that have a challenge set.<br />

n Responses to <strong>the</strong> challenge should contain sufficient entropy that <strong>the</strong>y<br />

cannot be easily guessed. For example, asking <strong>the</strong> user for <strong>the</strong> name of<br />

his first school is preferable to asking for his favorite color.<br />

n Accounts should be temporarily suspended following a number of<br />

failed attempts to complete <strong>the</strong> challenge, to prevent brute-force attacks.<br />

n The <strong>application</strong> should not leak any information in <strong>the</strong> event of failed<br />

responses to <strong>the</strong> challenge — regarding <strong>the</strong> validity of <strong>the</strong> username,<br />

any suspension of <strong>the</strong> account, and so on.<br />

n Successful completion of <strong>the</strong> challenge should be followed by <strong>the</strong><br />

process described previously, in which a message is sent to <strong>the</strong> user’s<br />

registered e-mail address containing a reactivation URL. Under no<br />

circumstances should <strong>the</strong> <strong>application</strong> disclose <strong>the</strong> user’s forgotten<br />

password or simply drop <strong>the</strong> user into an au<strong>the</strong>nticated session. Even<br />

proceeding directly to <strong>the</strong> password reset function is undesirable. The<br />

response to <strong>the</strong> account recovery challenge will in general be easier<br />

for an attacker to guess than <strong>the</strong> original password, so it should not<br />

be relied upon on its own to au<strong>the</strong>nticate <strong>the</strong> user.

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!