Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport Magento security Update 2.3.5-p2 from 20200728 APSB20-47 #1138

Closed
wants to merge 1 commit into from

Conversation

theroch
Copy link
Contributor

@theroch theroch commented Aug 7, 2020

Description (*)

  • Update _validateSecretKey in Mage_Adminhtml_Controller_Action to avoid time attacks related to CVE-2020-9690
  • It is important to provide the user-supplied string as the second parameter, rather than the first.

Related Pull Requests

  • none

Fixed Issues (if relevant)

  • none

Manual testing scenarios (*)

  1. Do several action in backend

Questions or comments

  • I've reviewed the p2 patch, but I think the other fixed CVEs are realted to M2 only.

Contribution checklist (*)

  • Pull request has a meaningful description of its purpose
  • All commits are accompanied by meaningful commit messages
  • All automated tests passed successfully (all builds are green)

 * Update _validateSecretKey in Mage_Adminhtml_Controller_Action to avoid time attacks related to CVE-2020-9690
 * It is important to provide the user-supplied string as the second parameter, rather than the first.

Signed-off-by: Frank Rochlitzer <[email protected]>
@github-actions github-actions bot added Component: Adminhtml Relates to Mage_Adminhtml Component: Core Relates to Mage_Core Component: lib/Zend labels Aug 7, 2020
@Flyingmana
Copy link
Contributor

Thank you a lot for checking this and contributing.
I added you to our internal advisories regarding this.

When you contact us over the recommended way (noted in https://github.com/OpenMage/magento-lts/blob/1.9.4.x/SECURITY.md ) we can handle this in private and better coordinate the release of security relevant information and releases.

Regarding the Patch, we use hash_equals() already on other places direct, so we do not need the fallback.
Also its a risk for itself to copy this and not using it via a composer dependency, as there may be related security issues in the future and we would not get an info about it this way.
(using such dependencies via composer is on our list)

@theroch
Copy link
Contributor Author

theroch commented Aug 7, 2020

@Flyingmana
Thx for your explanations and sorry for breaking the reporting process. It was the first time providing security related information for me. I will stick to it next time.

Should the PR to be closed now?

@theroch theroch closed this Aug 7, 2020
@theroch theroch deleted the bp_security_APSB20-47 branch August 7, 2020 11:40
@Flyingmana
Copy link
Contributor

No Problem, its also for us the first time to go through this process as a whole :)

@joshua-bn
Copy link
Contributor

joshua-bn commented Aug 21, 2020

I implemented this locally:

    protected function _validateSecretKey(): bool
    {
        if (in_array($this->getRequest()->getActionName(), $this->_publicActions)) {
            return true;
        }

        $secretKey = (string) $this->getRequest()->getParam(Mage_Adminhtml_Model_Url::SECRET_KEY_PARAM_NAME, null);
        $adminSecretKey = (string) $this->getAdminUrlModel()->getSecretKey();

        return $secretKey && hash_equals($adminSecretKey, $secretKey);
    }

    protected function getAdminUrlModel(): Mage_Adminhtml_Model_Url
    {
        return Mage::getSingleton('adminhtml/url');
    }

@colinmollenhour
Copy link
Member

I definitely like @joshua-bn solution better, far less code. hash-equals is supported since PHP 5.6 so no reason to have a helper and a library to replace one simple function.

@joshua-bn
Copy link
Contributor

joshua-bn commented Aug 21, 2020

lol, as you said that I realized I made a mistake when I was cleaning it up.

edited it again because I use return type hints locally with PHP 7.4.

@Flyingmana
Copy link
Contributor

This was resolved as part of the latest release (see security advisory and mentioned CVE in changelog)

@Flyingmana
Copy link
Contributor

Fun fact, we already have a polyfill in our code for the hash_equals function, for the old php versions

@joshua-bn
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Adminhtml Relates to Mage_Adminhtml Component: Core Relates to Mage_Core duplicate security
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants