You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@cloudstack.apache.org by Amogh Vasekar <am...@citrix.com> on 2013/08/05 20:36:21 UTC

Review Request 13252: SHA256 timing attack and brute force attack fix

-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/
-----------------------------------------------------------

Review request for cloudstack and John Burwell.


Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314


Repository: cloudstack-git


Description
-------

1. Fix timing attack by using a constant-time comparison function
2. Increase salt size
3. Make flow for invalid user go through full normal execution using a fake password and salt


Diffs
-----

  plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da93927 
  plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da93927 

Diff: https://reviews.apache.org/r/13252/diff/


Testing
-------

Local environment


Thanks,

Amogh Vasekar


Re: Review Request 13252: SHA256 timing attack and brute force attack fix

Posted by Amogh Vasekar <am...@citrix.com>.

> On Aug. 6, 2013, 8:57 p.m., Chiradeep Vittal wrote:
> > plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java, line 43
> > <https://reviews.apache.org/r/13252/diff/3/?file=337200#file337200line43>
> >
> >     What is the impact on upgrades? That is, I already have users with salt length 20. You might have to check with both?
> >     Also, you could make it 'final static int' I guess.

Thanks for the comment!
Changed "encode" method to refer to length of salt bytes passed instead of static length - old salts can thus still be 20 bytes.
This change will avoid a potential IndexOutOfBounds exception.


- Amogh


-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/#review24743
-----------------------------------------------------------


On Aug. 6, 2013, 9:45 p.m., Amogh Vasekar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/13252/
> -----------------------------------------------------------
> 
> (Updated Aug. 6, 2013, 9:45 p.m.)
> 
> 
> Review request for cloudstack and John Burwell.
> 
> 
> Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314
> 
> 
> Repository: cloudstack-git
> 
> 
> Description
> -------
> 
> 1. Fix timing attack by using a constant-time comparison function
> 2. Increase salt size
> 3. Make flow for invalid user go through full normal execution using a fake password and salt
> 
> 
> Diffs
> -----
> 
>   plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da939273ea10bff3b2687c9684edf8a5d0ab4b2e 
> 
> Diff: https://reviews.apache.org/r/13252/diff/
> 
> 
> Testing
> -------
> 
> Local environment
> 
> 
> Thanks,
> 
> Amogh Vasekar
> 
>


Re: Review Request 13252: SHA256 timing attack and brute force attack fix

Posted by Chiradeep Vittal <ch...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/#review24743
-----------------------------------------------------------



plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java
<https://reviews.apache.org/r/13252/#comment48851>

    What is the impact on upgrades? That is, I already have users with salt length 20. You might have to check with both?
    Also, you could make it 'final static int' I guess.



plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java
<https://reviews.apache.org/r/13252/#comment48849>

    convention is to have the } else { on the same line
    


- Chiradeep Vittal


On Aug. 5, 2013, 7:06 p.m., Amogh Vasekar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/13252/
> -----------------------------------------------------------
> 
> (Updated Aug. 5, 2013, 7:06 p.m.)
> 
> 
> Review request for cloudstack and John Burwell.
> 
> 
> Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314
> 
> 
> Repository: cloudstack-git
> 
> 
> Description
> -------
> 
> 1. Fix timing attack by using a constant-time comparison function
> 2. Increase salt size
> 3. Make flow for invalid user go through full normal execution using a fake password and salt
> 
> 
> Diffs
> -----
> 
>   plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da939273ea10bff3b2687c9684edf8a5d0ab4b2e 
> 
> Diff: https://reviews.apache.org/r/13252/diff/
> 
> 
> Testing
> -------
> 
> Local environment
> 
> 
> Thanks,
> 
> Amogh Vasekar
> 
>


Re: Review Request 13252: SHA256 timing attack and brute force attack fix

Posted by Demetrius Tsitrelis <dt...@live.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/#review24750
-----------------------------------------------------------


There is a problem on line 86 with the order of the test.  As is the code first checks to see whether there is a real user and, only if he is, will the constantTimeEquals() comparison be done:

            return realUser && constantTimeEquals(realPassword, hashedPassword);

This test should be reversed like so:

            return constantTimeEquals(realPassword, hashedPassword) && realUser;

This way authentication will take the same amount of time regardless of whether the user exists, thus mitigating the timing attack.


- Demetrius Tsitrelis


On Aug. 6, 2013, 9:51 p.m., Amogh Vasekar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/13252/
> -----------------------------------------------------------
> 
> (Updated Aug. 6, 2013, 9:51 p.m.)
> 
> 
> Review request for cloudstack and John Kinsella.
> 
> 
> Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314
> 
> 
> Repository: cloudstack-git
> 
> 
> Description
> -------
> 
> 1. Fix timing attack by using a constant-time comparison function
> 2. Increase salt size
> 3. Make flow for invalid user go through full normal execution using a fake password and salt
> 
> 
> Diffs
> -----
> 
>   plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da939273ea10bff3b2687c9684edf8a5d0ab4b2e 
> 
> Diff: https://reviews.apache.org/r/13252/diff/
> 
> 
> Testing
> -------
> 
> Local environment
> 
> 
> Thanks,
> 
> Amogh Vasekar
> 
>


Re: Review Request 13252: SHA256 timing attack and brute force attack fix

Posted by Chiradeep Vittal <ch...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/#review24818
-----------------------------------------------------------

Ship it!


Ship It!

- Chiradeep Vittal


On Aug. 7, 2013, 7:01 p.m., Amogh Vasekar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/13252/
> -----------------------------------------------------------
> 
> (Updated Aug. 7, 2013, 7:01 p.m.)
> 
> 
> Review request for cloudstack and John Kinsella.
> 
> 
> Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314
> 
> 
> Repository: cloudstack-git
> 
> 
> Description
> -------
> 
> 1. Fix timing attack by using a constant-time comparison function
> 2. Increase salt size
> 3. Make flow for invalid user go through full normal execution using a fake password and salt
> 
> 
> Diffs
> -----
> 
>   plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da939273ea10bff3b2687c9684edf8a5d0ab4b2e 
>   plugins/user-authenticators/sha256salted/test/src/com/cloud/server/auth/test/AuthenticatorTest.java 4e23d14fe43b4e334203f48196aced038ca0a196 
> 
> Diff: https://reviews.apache.org/r/13252/diff/
> 
> 
> Testing
> -------
> 
> Local environment
> 
> 
> Thanks,
> 
> Amogh Vasekar
> 
>


Re: Review Request 13252: SHA256 timing attack and brute force attack fix

Posted by Amogh Vasekar <am...@citrix.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/
-----------------------------------------------------------

(Updated Aug. 7, 2013, 7:01 p.m.)


Review request for cloudstack and John Kinsella.


Changes
-------

1. Added test case to ensure (old) 20-byte salted passwords work
2. Test cases for general authentication
3. Test cases to ensure computation time for all different scenarios are within minutely small range of each other


Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314


Repository: cloudstack-git


Description
-------

1. Fix timing attack by using a constant-time comparison function
2. Increase salt size
3. Make flow for invalid user go through full normal execution using a fake password and salt


Diffs (updated)
-----

  plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da939273ea10bff3b2687c9684edf8a5d0ab4b2e 
  plugins/user-authenticators/sha256salted/test/src/com/cloud/server/auth/test/AuthenticatorTest.java 4e23d14fe43b4e334203f48196aced038ca0a196 

Diff: https://reviews.apache.org/r/13252/diff/


Testing
-------

Local environment


Thanks,

Amogh Vasekar


Re: Review Request 13252: SHA256 timing attack and brute force attack fix

Posted by Chiradeep Vittal <ch...@gmail.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/#review24757
-----------------------------------------------------------


Can you add tests to AuthenticatorTest.java
1. authenticate('FooUser', 'FooPassword') takes as long as authenticate('ValidUser', 'ValidPassword') takes as long as authenticate('ValidUser', 'FooPassword')
2. authenticate('ValidUserWith20byteSalt', 'ValidPassword') succeeds

- Chiradeep Vittal


On Aug. 6, 2013, 9:59 p.m., Amogh Vasekar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/13252/
> -----------------------------------------------------------
> 
> (Updated Aug. 6, 2013, 9:59 p.m.)
> 
> 
> Review request for cloudstack and John Kinsella.
> 
> 
> Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314
> 
> 
> Repository: cloudstack-git
> 
> 
> Description
> -------
> 
> 1. Fix timing attack by using a constant-time comparison function
> 2. Increase salt size
> 3. Make flow for invalid user go through full normal execution using a fake password and salt
> 
> 
> Diffs
> -----
> 
>   plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da939273ea10bff3b2687c9684edf8a5d0ab4b2e 
> 
> Diff: https://reviews.apache.org/r/13252/diff/
> 
> 
> Testing
> -------
> 
> Local environment
> 
> 
> Thanks,
> 
> Amogh Vasekar
> 
>


Re: Review Request 13252: SHA256 timing attack and brute force attack fix

Posted by Demetrius Tsitrelis <dt...@live.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/#review24759
-----------------------------------------------------------

Ship it!


Ship It!

- Demetrius Tsitrelis


On Aug. 6, 2013, 9:59 p.m., Amogh Vasekar wrote:
> 
> -----------------------------------------------------------
> This is an automatically generated e-mail. To reply, visit:
> https://reviews.apache.org/r/13252/
> -----------------------------------------------------------
> 
> (Updated Aug. 6, 2013, 9:59 p.m.)
> 
> 
> Review request for cloudstack and John Kinsella.
> 
> 
> Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314
> 
> 
> Repository: cloudstack-git
> 
> 
> Description
> -------
> 
> 1. Fix timing attack by using a constant-time comparison function
> 2. Increase salt size
> 3. Make flow for invalid user go through full normal execution using a fake password and salt
> 
> 
> Diffs
> -----
> 
>   plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da939273ea10bff3b2687c9684edf8a5d0ab4b2e 
> 
> Diff: https://reviews.apache.org/r/13252/diff/
> 
> 
> Testing
> -------
> 
> Local environment
> 
> 
> Thanks,
> 
> Amogh Vasekar
> 
>


Re: Review Request 13252: SHA256 timing attack and brute force attack fix

Posted by Amogh Vasekar <am...@citrix.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/
-----------------------------------------------------------

(Updated Aug. 6, 2013, 9:59 p.m.)


Review request for cloudstack and John Kinsella.


Changes
-------

Change suggested by Demetrius


Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314


Repository: cloudstack-git


Description
-------

1. Fix timing attack by using a constant-time comparison function
2. Increase salt size
3. Make flow for invalid user go through full normal execution using a fake password and salt


Diffs (updated)
-----

  plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da939273ea10bff3b2687c9684edf8a5d0ab4b2e 

Diff: https://reviews.apache.org/r/13252/diff/


Testing
-------

Local environment


Thanks,

Amogh Vasekar


Re: Review Request 13252: SHA256 timing attack and brute force attack fix

Posted by Amogh Vasekar <am...@citrix.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/
-----------------------------------------------------------

(Updated Aug. 6, 2013, 9:51 p.m.)


Review request for cloudstack and John Kinsella.


Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314


Repository: cloudstack-git


Description
-------

1. Fix timing attack by using a constant-time comparison function
2. Increase salt size
3. Make flow for invalid user go through full normal execution using a fake password and salt


Diffs
-----

  plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da939273ea10bff3b2687c9684edf8a5d0ab4b2e 

Diff: https://reviews.apache.org/r/13252/diff/


Testing
-------

Local environment


Thanks,

Amogh Vasekar


Re: Review Request 13252: SHA256 timing attack and brute force attack fix

Posted by Amogh Vasekar <am...@citrix.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/
-----------------------------------------------------------

(Updated Aug. 6, 2013, 9:45 p.m.)


Review request for cloudstack and John Burwell.


Changes
-------

Incorporating review comments


Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314


Repository: cloudstack-git


Description
-------

1. Fix timing attack by using a constant-time comparison function
2. Increase salt size
3. Make flow for invalid user go through full normal execution using a fake password and salt


Diffs (updated)
-----

  plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da939273ea10bff3b2687c9684edf8a5d0ab4b2e 

Diff: https://reviews.apache.org/r/13252/diff/


Testing
-------

Local environment


Thanks,

Amogh Vasekar


Re: Review Request 13252: SHA256 timing attack and brute force attack fix

Posted by Amogh Vasekar <am...@citrix.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/
-----------------------------------------------------------

(Updated Aug. 5, 2013, 7:06 p.m.)


Review request for cloudstack and John Burwell.


Changes
-------

Getting the diff right 


Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314


Repository: cloudstack-git


Description
-------

1. Fix timing attack by using a constant-time comparison function
2. Increase salt size
3. Make flow for invalid user go through full normal execution using a fake password and salt


Diffs (updated)
-----

  plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da939273ea10bff3b2687c9684edf8a5d0ab4b2e 

Diff: https://reviews.apache.org/r/13252/diff/


Testing
-------

Local environment


Thanks,

Amogh Vasekar


Re: Review Request 13252: SHA256 timing attack and brute force attack fix

Posted by Amogh Vasekar <am...@citrix.com>.
-----------------------------------------------------------
This is an automatically generated e-mail. To reply, visit:
https://reviews.apache.org/r/13252/
-----------------------------------------------------------

(Updated Aug. 5, 2013, 6:57 p.m.)


Review request for cloudstack and John Burwell.


Bugs: https://issues.apache.org/jira/browse/CLOUDSTACK-2312 and https://issues.apache.org/jira/browse/CLOUDSTACK-2314


Repository: cloudstack-git


Description
-------

1. Fix timing attack by using a constant-time comparison function
2. Increase salt size
3. Make flow for invalid user go through full normal execution using a fake password and salt


Diffs (updated)
-----

  plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da93927 
  plugins/user-authenticators/sha256salted/src/com/cloud/server/auth/SHA256SaltedUserAuthenticator.java da93927 

Diff: https://reviews.apache.org/r/13252/diff/


Testing
-------

Local environment


Thanks,

Amogh Vasekar