Skip to content

Conversation

@ceeram
Copy link
Contributor

@ceeram ceeram commented Aug 25, 2017

Use hmac for digest nonces

@ceeram ceeram self-assigned this Aug 25, 2017
@codecov-io
Copy link

codecov-io commented Aug 25, 2017

Codecov Report

Merging #11103 into master will increase coverage by <.01%.
The diff coverage is 100%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master   #11103      +/-   ##
============================================
+ Coverage     94.88%   94.88%   +<.01%     
- Complexity    12841    12865      +24     
============================================
  Files           437      437              
  Lines         32742    32792      +50     
============================================
+ Hits          31067    31116      +49     
- Misses         1675     1676       +1
Impacted Files Coverage Δ Complexity Δ
src/Auth/DigestAuthenticate.php 100% <100%> (ø) 32 <0> (ø) ⬇️
src/View/Helper/TextHelper.php 98.49% <0%> (-0.32%) 48% <0%> (+24%)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update adbbef6...82ac898. Read the comment docs.

@markstory markstory added this to the 3.5.1 milestone Aug 25, 2017
{
$expiryTime = microtime(true) + $this->getConfig('nonceLifetime');
$signatureValue = md5($expiryTime . ':' . $this->getConfig('secret'));
$signatureValue = hash_hmac('sha256', $expiryTime . ':' . $this->getConfig('secret'), Security::getSalt());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you have to change the validation of the nonce as well?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes it should, will take care of that

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is also a generateNonce method in the test case that is still using md5() as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated both

$time = $time ?: microtime(true);
$expiryTime = $time + $expires;
$signatureValue = md5($expiryTime . ':' . $secret);
$signatureValue = hash_hmac('sha1', $expiryTime . ':' . $secret, $secret);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just me, or shouldn't this be sha256? seems to be causing some trouble for me.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are you suggesting sha256 for the stronger algorithm?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no, due to inconsistency with the validNonce function

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I totally missed that 😊. I'll get it fixed.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great! Thanks. Had me pulling my hair out.

if ($expires < microtime(true)) {
return false;
}
$check = hash_hmac('sha1', $expires . ':' . $this->getConfig('secret'), $this->getConfig('secret'));
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this just me, or shouldn't this be sha256? seems to be causing some trouble for me.

markstory added a commit that referenced this pull request Nov 22, 2017
The generation and validation sides of Digest authentication were using
different algorithms which results in broken digest authentication.

Refs #11103
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants