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

Admin user can call arbitrary Module class's constructor via Cart Price Rules #35135

Open
5 tasks
oskar-olaussen opened this issue Feb 24, 2022 · 13 comments
Open
5 tasks
Labels
Area: UI Framework Component: SalesRule Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: ready for dev Reported on 2.4.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch

Comments

@oskar-olaussen
Copy link

Preconditions (*)

  1. Magento 2.4.3

Steps to reproduce (*)

  1. Create a new Cart Price Rule
    Screenshot from 2022-02-24 09-30-10

  2. Modify value of Conditions option value in browser's inspect. For example:
    Screenshot from 2022-02-24 09-09-23

  3. Select the option that you have modified.

Expected result (*)

  1. Validation error

Actual result (*)

  1. Inserted class is created and Magento tries to call methods on it. Have not found an actual exploit but this seems to be really bad practice at best.
    Screenshot from 2022-02-24 09-40-01

Please provide Severity assessment for the Issue as Reporter. This information will help during Confirmation and Issue triage processes.

  • Severity: S0 - Affects critical data or functionality and leaves users without workaround.
  • Severity: S1 - Affects critical data or functionality and forces users to employ a workaround.
  • Severity: S2 - Affects non-critical data or functionality and forces users to employ a workaround.
  • Severity: S3 - Affects non-critical data or functionality and does not force users to employ a workaround.
  • Severity: S4 - Affects aesthetics, professional look and feel, “quality” or “usability”.
@m2-assistant
Copy link

m2-assistant bot commented Feb 24, 2022

Hi @oskar-olaussen. Thank you for your report.
To speed up processing of this issue, make sure that you provided the following information:

  • Summary of the issue
  • Information on your environment
  • Steps to reproduce
  • Expected and actual results

Make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, Add a comment to the issue:

@magento give me 2.4-develop instance - upcoming 2.4.x release

For more details, review the Magento Contributor Assistant documentation.

Add a comment to assign the issue: @magento I am working on this

To learn more about issue processing workflow, refer to the Code Contributions.


⚠️ According to the Magento Contribution requirements, all issues must go through the Community Contributions Triage process. Community Contributions Triage is a public meeting.

🕙 You can find the schedule on the Magento Community Calendar page.

📞 The triage of issues happens in the queue order. If you want to speed up the delivery of your contribution, join the Community Contributions Triage session to discuss the appropriate ticket.

✏️ Feel free to post questions/proposals/feedback related to the Community Contributions Triage process to the corresponding Slack Channel

@m2-assistant
Copy link

m2-assistant bot commented Feb 24, 2022

Hi @engcom-November. Thank you for working on this issue.
In order to make sure that issue has enough information and ready for development, please read and check the following instruction: 👇

  • 1. Verify that issue has all the required information. (Preconditions, Steps to reproduce, Expected result, Actual result).

    DetailsIf the issue has a valid description, the label Issue: Format is valid will be added to the issue automatically. Please, edit issue description if needed, until label Issue: Format is valid appears.

  • 2. Verify that issue has a meaningful description and provides enough information to reproduce the issue. If the report is valid, add Issue: Clear Description label to the issue by yourself.

  • 3. Add Component: XXXXX label(s) to the ticket, indicating the components it may be related to.

  • 4. Verify that the issue is reproducible on 2.4-develop branch

    Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
    - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!

  • 5. Add label Issue: Confirmed once verification is complete.

  • 6. Make sure that automatic system confirms that report has been added to the backlog.

@engcom-November
Copy link
Contributor

engcom-November commented Feb 24, 2022

Verified the issue on Magento 2.4-develop branch
On modifying option value of Conditions section in browser's inspect of Cart Price Rule, and selecting the same value in UI that has been modified, error is displayed and user is redirected to dashboard page.
image

image

Exception stack trace:
[2022-02-24T08:57:03.500455+00:00] main.ERROR: Class Magento\Quote\Model\CoponManagement does not exist [] [] [2022-02-24T08:57:03.501371+00:00] main.CRITICAL: ReflectionException: Class Magento\Quote\Model\CoponManagement does not exist in /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Code/Reader/ClassReader.php:34 Stack trace: #0 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Code/Reader/ClassReader.php(34): ReflectionClass->__construct() #1 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/ObjectManager/Definition/Runtime.php(54): Magento\Framework\Code\Reader\ClassReader->getConstructor() #2 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/ObjectManager/Factory/Compiled.php(100): Magento\Framework\ObjectManager\Definition\Runtime->getParameters() #3 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/ObjectManager/ObjectManager.php(56): Magento\Framework\ObjectManager\Factory\Compiled->create() #4 /var/www/html/mg24/magento2/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewConditionHtml.php(30): Magento\Framework\ObjectManager\ObjectManager->create() #5 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml->execute() #6 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->___callParent() #7 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->Magento\Framework\Interception\{closure}() #8 /var/www/html/mg24/magento2/generated/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewConditionHtml/Interceptor.php(23): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->___callPlugins() #9 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/Action/Action.php(111): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->execute() #10 /var/www/html/mg24/magento2/app/code/Magento/Backend/App/AbstractAction.php(151): Magento\Framework\App\Action\Action->dispatch() #11 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Backend\App\AbstractAction->dispatch() #12 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->___callParent() #13 /var/www/html/mg24/magento2/app/code/Magento/Backend/App/Action/Plugin/Authentication.php(145): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->Magento\Framework\Interception\{closure}() #14 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() #15 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->Magento\Framework\Interception\{closure}() #16 /var/www/html/mg24/magento2/generated/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewConditionHtml/Interceptor.php(32): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->___callPlugins() #17 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/FrontController.php(245): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->dispatch() #18 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse() #19 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest() #20 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch() #21 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent() #22 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() #23 /var/www/html/mg24/magento2/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins() #24 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch() #25 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/Bootstrap.php(264): Magento\Framework\App\Http->launch() #26 /var/www/html/mg24/magento2/pub/index.php(30): Magento\Framework\App\Bootstrap->run() #27 {main} {"report_id":"1c3786db3e0b891f7f12cd3a55831f0964f8f4721c03158dcb3493cb1e05eef7"} []

@engcom-November engcom-November added the Issue: needs update Additional information is require, waiting for response label Feb 24, 2022
@hostep
Copy link
Contributor

hostep commented Feb 24, 2022

@nathanjosiah, just tagging you in here, sounds security related.

@github-jira-sync-bot
Copy link

❌ You don't have permission to export this issue.

@nathanjosiah
Copy link
Contributor

nathanjosiah commented Feb 25, 2022

@hostep I don't see an issue with this. When the rule model loads the post data there is a check that the requested class implements the ConditionInterface. The error in this report is due to a typo (Magento\Quote\Model\CoponManagement should be Magento\Quote\Model\CouponManagement) but even if it was correct, the class is loaded into memory but never instantiated because it doesn't implement that interface. In fact, it will throw a Class does not implement condition interface error which is simply logged and then completely ignored. Any class that implements that interface seems like it should be allowed in this context.

@oskarolaussen
Copy link
Contributor

oskarolaussen commented Feb 25, 2022

@nathanjosiah Thanks for the response! Not currently on my work computer but I'm fairly certain that by following the steps I provided the error logged was about the method setId not existing in the class provided, implying that the class was instantiated and then the method was called on it. The code uses the object manager directly so are you sure the flow goes through the factory referenced?

@engcom-November
Copy link
Contributor

Verified the issue again on Magento 2.4-develop branch by correcting typo mistake. Please find the observations below:
On modifying option value of Conditions section in browser's inspect of Cart Price Rule, and selecting the same value in UI that has been modified, error is displayed and user is redirected to dashboard page.
image

image

[2022-03-07T08:08:28.132405+00:00] main.CRITICAL: Error: Call to undefined method Magento\Quote\Model\CouponManagement::setId() in /var/www/html/mg24/magento2/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewConditionHtml.php:31 Stack trace: #0 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml->execute() #1 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->___callParent() #2 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->Magento\Framework\Interception\{closure}() #3 /var/www/html/mg24/magento2/generated/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewConditionHtml/Interceptor.php(23): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->___callPlugins() #4 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/Action/Action.php(111): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->execute() #5 /var/www/html/mg24/magento2/app/code/Magento/Backend/App/AbstractAction.php(151): Magento\Framework\App\Action\Action->dispatch() #6 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Backend\App\AbstractAction->dispatch() #7 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->___callParent() #8 /var/www/html/mg24/magento2/app/code/Magento/Backend/App/Action/Plugin/Authentication.php(145): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->Magento\Framework\Interception\{closure}() #9 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(135): Magento\Backend\App\Action\Plugin\Authentication->aroundDispatch() #10 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->Magento\Framework\Interception\{closure}() #11 /var/www/html/mg24/magento2/generated/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewConditionHtml/Interceptor.php(32): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->___callPlugins() #12 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/FrontController.php(245): Magento\SalesRule\Controller\Adminhtml\Promo\Quote\NewConditionHtml\Interceptor->dispatch() #13 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/FrontController.php(212): Magento\Framework\App\FrontController->getActionResponse() #14 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/FrontController.php(147): Magento\Framework\App\FrontController->processRequest() #15 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(58): Magento\Framework\App\FrontController->dispatch() #16 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(138): Magento\Framework\App\FrontController\Interceptor->___callParent() #17 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/Interception/Interceptor.php(153): Magento\Framework\App\FrontController\Interceptor->Magento\Framework\Interception\{closure}() #18 /var/www/html/mg24/magento2/generated/code/Magento/Framework/App/FrontController/Interceptor.php(23): Magento\Framework\App\FrontController\Interceptor->___callPlugins() #19 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/Http.php(116): Magento\Framework\App\FrontController\Interceptor->dispatch() #20 /var/www/html/mg24/magento2/generated/code/Magento/Framework/App/Http/Interceptor.php(23): Magento\Framework\App\Http->launch() #21 /var/www/html/mg24/magento2/lib/internal/Magento/Framework/App/Bootstrap.php(264): Magento\Framework\App\Http\Interceptor->launch() #22 /var/www/html/mg24/magento2/pub/index.php(30): Magento\Framework\App\Bootstrap->run() #23 {main} [] []

@nathanjosiah
Copy link
Contributor

@oskarolaussen @engcom-November I see the issue, it is with the Html retrieval controller https://github.com/magento/magento2/blob/2.4-develop/app/code/Magento/SalesRule/Controller/Adminhtml/Promo/Quote/NewActionHtml.php#L32

This is definitely not ideal and there should be a validation check here but I don't see how this could be attacked with how it is currently written. I have created a ticket for this internally as a defense-in-depth ticket but it looks very unlikely to be exploitable as-is. There would need to be a class that can cause harm by having setId and/or setType methods and the arguments to those method have to be strings that are solely used to perform some type of malicious behavior. It's theoretically possible but would require some terrible class design for it to be plausible.

Ticket created https://jira.corp.magento.com/browse/AC-2571

@engcom-November
Copy link
Contributor

Thanks for the update @nathanjosiah. Confirming the issue.

@engcom-November engcom-November added Area: UI Framework Component: SalesRule Reported on 2.4.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed labels Mar 8, 2022
@m2-community-project m2-community-project bot removed the Issue: needs update Additional information is require, waiting for response label Mar 8, 2022
@github-jira-sync-bot
Copy link

✅ Jira issue https://jira.corp.magento.com/browse/AC-2581 is successfully created for this GitHub issue.

@m2-assistant
Copy link

m2-assistant bot commented Mar 8, 2022

✅ Confirmed by @engcom-November. Thank you for verifying the issue.
Issue Available: @engcom-November, You will be automatically unassigned. Contributors/Maintainers can claim this issue to continue. To reclaim and continue work, reassign the ticket to yourself.

@engcom-Hotel engcom-Hotel added the Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. label Mar 8, 2022
@m2-assistant
Copy link

m2-assistant bot commented Jun 6, 2022

Hi @SergeyP18. Thank you for working on this issue.
Looks like this issue is already verified and confirmed. But if you want to validate it one more time, please, go though the following instruction:

    1. Add/Edit Component: XXXXX label(s) to the ticket, indicating the components it may be related to.
    1. Verify that the issue is reproducible on 2.4-develop branch
      Details- Add the comment @magento give me 2.4-develop instance to deploy test instance on Magento infrastructure.
      - If the issue is reproducible on 2.4-develop branch, please, add the label Reproduced on 2.4.x.
      - If the issue is not reproducible, add your comment that issue is not reproducible and close the issue and stop verification process here!
    1. If the issue is not relevant or is not reproducible any more, feel free to close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area: UI Framework Component: SalesRule Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed Priority: P1 Once P0 defects have been fixed, a defect having this priority is the next candidate for fixing. Progress: ready for dev Reported on 2.4.3 Indicates original Magento version for the Issue report. Reproduced on 2.4.x The issue has been reproduced on latest 2.4-develop branch
Projects
Status: Pull Request In Progress
8 participants