magento / magento2

Prior to making any Submission(s), you must sign an Adobe Contributor License Agreement, available here at: https://opensource.adobe.com/cla.html. All Submissions you make to Adobe Inc. and its affiliates, assigns and subsidiaries (collectively “Adobe”) are subject to the terms of the Adobe Contributor License Agreement.
http://www.magento.com
Open Software License 3.0
11.29k stars 9.27k forks source link

Cookie mage-messages has secure flag not set #38681

Open mdevrees opened 2 weeks ago

mdevrees commented 2 weeks ago

Preconditions and environment

Steps to reproduce

  1. Trigger the creation of the mage-messages cookie by for example adding a product to cart
  2. In \Magento\Theme\Controller\Result\MessagePlugin::setCookie the mage-messages cookie is created
  3. In the setCookie method the $publicCookieMetadata->setSecure($this->sessionConfig->getCookieSecure()); is not set / missing and apparently not marking the mage-messages as secure. If I add setSecure the mage-messages cookie is marked secure:

Screenshot 2024-04-30 at 14 16 20

Expected result

I expected the mage-messages cookie to be also set as secure.

Actual result

The mage-messages cookie isn't marked as secure.

Additional information

I've tried searching for this specific issue in the github issue tracker but could not find any.

Release note

No response

Triage and priority

m2-assistant[bot] commented 2 weeks ago

Hi @mdevrees. Thank you for your report. To speed up processing of this issue, 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:

m2-assistant[bot] commented 2 weeks ago

Hi @engcom-Hotel. 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: :point_down:

engcom-Hotel commented 2 weeks ago

Hello @mdevrees,

Thanks for the report and collaboration!

We have tried to reproduce the issue in the 2.4-develop branch and we have observed that the mage-messages cookie not secure. But it seems it is working as expected.

Please go through the documentation related to it:

https://experienceleague.adobe.com/en/docs/commerce-admin/start/compliance/privacy/compliance-cookie-law#mage-messages

And let us know the use case where you need this cookie should be secure.

Thanks

mdevrees commented 1 week ago

Hi @engcom-Hotel

Seeing the compliance cookie law regarding mage-messages, then yes, you are correct in it not being (or having to be) secure. The cookie not being secure was a point of action coming from a security scan. In order to comply with that, I added the change mentioned in the Steps to Reproduce in the description of this ticket.

engcom-Hotel commented 1 week ago

Thank you, @mdevrees, for your response!

Given that this issue has been flagged in your security scan, it's possible that others may encounter it too. Therefore, we'll proceed by treating this as a "feature request."

Appreciate it!