Skip to content

On Magento 2.3, form_key cookie expires immediately if cookie lifetime is set to 0 #19718

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

Closed
staradzinau opened this issue Dec 12, 2018 · 37 comments
Labels
Component: Cookie Component: PageCache Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release

Comments

@staradzinau
Copy link

Preconditions (*)

  1. Magento 2.3.0
  2. Steps for reproduce are exactly the same as mentioned in form_key cookie expires immediately if cookie lifetime is set to 0 #10527

Additional information

Commit 99a3c01 wasn't correctly merged to the actual 2.3.0 brach. Please, compare computeExpirationTime() function:
https://github.com/magento/magento2/blob/2.2.7/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php
and
https://github.com/magento/magento2/blob/2.3.0/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php

@magento-engcom-team
Copy link
Contributor

Hi @avgust1111. Thank you for your report.
To help us process this issue please make sure that you provided the following information:

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

Please make sure that the issue is reproducible on the vanilla Magento instance following Steps to reproduce. To deploy vanilla Magento instance on our environment, please, add a comment to the issue:

@magento-engcom-team give me $VERSION instance

where $VERSION is version tags (starting from 2.2.0+) or develop branches (for example: 2.3-develop).
For more details, please, review the Magento Contributor Assistant documentation.

@avgust1111 do you confirm that you was able to reproduce the issue on vanilla Magento instance following steps to reproduce?

  • yes
  • no

@magento-engcom-team magento-engcom-team added the Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed label Dec 12, 2018
@TomashKhamlai TomashKhamlai self-assigned this Dec 12, 2018
@magento-engcom-team
Copy link
Contributor

Hi @TomashKhamlai. 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.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.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. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

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

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

@orlangur
Copy link
Contributor

@avgust1111 such observations may be created directly as pull request ;) Thanks for your report.

@TomashKhamlai
Copy link
Contributor

@magento-engcom-team give me 2.3.0 instance

@magento-engcom-team
Copy link
Contributor

Hi @TomashKhamlai. Thank you for your request. I'm working on Magento 2.3.0 instance for you

@magento-engcom-team
Copy link
Contributor

Hi @TomashKhamlai, here is your Magento instance.
Admin access: https://i-19718-2-3-0.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@TomashKhamlai TomashKhamlai added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Dec 14, 2018
@TomashKhamlai
Copy link
Contributor

@avgust1111, thank you for report. I saw a label Fixed in 2.3.0 and also I was not able to reproduce issue by steps given.

@TomashKhamlai TomashKhamlai removed their assignment Dec 14, 2018
@staradzinau
Copy link
Author

@TomashKhamlai , please, note: I'm talking specifically about the commit 99a3c01 and its changes, which was merged into the 2.2.X branch, but it wasn't merged correctly into the 2.3.X branch.
Because of this problem with the commit, we still have to hardcode a logic of the cookie expiration settings in order to make it work both on 2.2.X and 2.3.X.
The bug from the old issue (#10527) cannot be reproduced because of some other changes, but the initial problem (an impossibility to set a cookie which expires at the end of session time programmatically) still persists in the 2.3.X branch, despite it works properly in 2.2.7
Kindly review the difference in the computeExpirationTime() function
https://github.com/magento/magento2/blob/2.2.7/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php:
2.2.7:

if (isset($metadataArray[CookieMetadata::KEY_DURATION])
                && $metadataArray[CookieMetadata::KEY_DURATION] !== PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME
            ) {

and
https://github.com/magento/magento2/blob/2.3.0/lib/internal/Magento/Framework/Stdlib/Cookie/PhpCookieManager.php:
2.3.0:
if (isset($metadataArray[CookieMetadata::KEY_DURATION])) {

As you can see, it's necessary to add at least the second part of condition, e.g:
&& $metadataArray[CookieMetadata::KEY_DURATION] !== PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME

This is the problem I'm reporting

@TomashKhamlai TomashKhamlai reopened this Dec 14, 2018
@TomashKhamlai
Copy link
Contributor

We will check it again.

@staradzinau
Copy link
Author

@TomashKhamlai , thanks, I will be waiting for updates

@sivaschenko
Copy link
Member

Hi @avgust1111 , thanks for your report. Can you please provide the actual steps to reproduce, actual and expected result for us to verify the issue.

@staradzinau
Copy link
Author

Hello, @sivaschenko
In fact, I didn't face with such an issue in the native Magento workflow. During extension developing, I've reproduced an impossibility to set a cookie which expires at the end of session time on 2.3.X programmatically in the correct way, without hardcoded logic.
Here are exact details.

  • Create an instance of Magento\Framework\Stdlib\Cookie\PublicCookieMetadata class
  • Set all required parameters, and call setDuration() function with $duration = Magento\Framework\Stdlib\Cookie\PhpCookieManager::EXPIRE_AT_END_OF_SESSION_TIME
  • Set some public cookie using Magento\Framework\Stdlib\CookieManagerInterface and its function setPublicCookie() with PublicCookieMetadata instance from previous steps

Actual result for 2.3.X: specific cookie is not set
Expected result: public cookie, which expires at the end of session time is set correctly

Please, investigate such an issue on 2.3.X.

@csdougliss
Copy link
Contributor

Can confirm this bug in 2.3.0..

@ghost
Copy link

ghost commented Dec 19, 2018

@craigcarnell, did you reproduced the issue on clean Magento 2.3.0 or on Magento 2.3.0 upgraded from 2.2.x?

@ghost ghost added Progress: needs update and removed Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch labels Dec 19, 2018
@csdougliss
Copy link
Contributor

Upgraded, I don't have time to install Magento for every single bug I find :)

@ghost ghost self-assigned this Dec 19, 2018
@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-andrii. 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.3-develop branch

    Details- Add the comment @magento-engcom-team give me 2.3-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.3-develop branch, please, add the label Reproduced on 2.3.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. Verify that the issue is reproducible on 2.2-develop branch.

    Details- Add the comment @magento-engcom-team give me 2.2-develop instance to deploy test instance on Magento infrastructure.
    - If the issue is reproducible on 2.2-develop branch, please add the label Reproduced on 2.2.x

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

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

@ghost ghost added Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Component: Cookie and removed Progress: needs update labels Dec 19, 2018
@ghost ghost added the Component: PageCache label Dec 19, 2018
@ghost
Copy link

ghost commented Dec 19, 2018

@magento-engcom-team give me 2.3.0 instance

@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-andrii. Thank you for your request. I'm working on Magento 2.3.0 instance for you

@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-andrii, here is your Magento instance.
Admin access: https://i-19718-2-3-0.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@ghost
Copy link

ghost commented Dec 19, 2018

@avgust1111, @craigcarnell could you please copy the whole function function updateCookieFormKey from app/code/Magento/PageCache/Plugin/RegisterFormKeyFromCookie.php or vendor/magento/module-page-cache/Plugin/RegisterFormKeyFromCookie.php and paste it to the comment?

@ghost ghost added Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Progress: needs update Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed and removed Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Progress: needs update labels Dec 19, 2018
@magento-engcom-team magento-engcom-team removed the Issue: Confirmed Gate 3 Passed. Manual verification of the issue completed. Issue is confirmed label Dec 19, 2018
@magento-engcom-team
Copy link
Contributor

@engcom-backlog-andrii Thank you for verifying the issue.

Unfortunately, not enough information was provided to created internal ticket. Please consider adding the following:

Once all required information is added, please add label "Issue: Confirmed" again.
Thanks!

@ghost
Copy link

ghost commented Dec 19, 2018

@avgust1111, please update the issue content to follow format required by Issue Reporting Guidelines

@ghost
Copy link

ghost commented Dec 20, 2018

@magento-engcom-team give me 2.2-develop instance

@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-andrii. Thank you for your request. I'm working on Magento 2.2-develop instance for you

@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-andrii, here is your Magento instance.
Admin access: https://i-19718-2-2-develop.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@ghost
Copy link

ghost commented Dec 20, 2018

@magento-engcom-team give me 2.2.7 instance

@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-andrii. Thank you for your request. I'm working on Magento 2.2.7 instance for you

@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-andrii, here is your Magento instance.
Admin access: https://i-19718-2-2-7.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@TomashKhamlai TomashKhamlai added the Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch label Dec 20, 2018
@ghost ghost closed this as completed Dec 20, 2018
@csdougliss
Copy link
Contributor

csdougliss commented Jan 3, 2019

@TomashKhamlai Why was this closed?? This is a major bug, I have to login to the admin several times..

@ghost
Copy link

ghost commented Jan 3, 2019

@craigcarnell, I can reproduce it only on 2.1-develop. Please try to reproduce this problem in the provided instance.

@ghost
Copy link

ghost commented Jan 3, 2019

@magento-engcom-team give me 2.3.0 instance

@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-tomash. Thank you for your request. I'm working on Magento 2.3.0 instance for you

@magento-engcom-team
Copy link
Contributor

Hi @engcom-backlog-tomash, here is your Magento instance.
Admin access: https://i-19718-2-3-0.instances.magento-community.engineering/admin
Login: admin Password: 123123q
Instance will be terminated in up to 3 hours.

@ghost ghost removed the Progress: needs update label Jan 3, 2019
@csdougliss
Copy link
Contributor

@TomashKhamlai i've found my issue, might not be related to this, will create a ticket.

@ghost ghost removed their assignment Jan 9, 2019
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Component: Cookie Component: PageCache Fixed in 2.2.x The issue has been fixed in 2.2 release line Fixed in 2.3.x The issue has been fixed in 2.3 release line Issue: Cannot Reproduce Cannot reproduce the issue on the latest `2.4-develop` branch Issue: Format is not valid Gate 1 Failed. Automatic verification of issue format is failed Reproduced on 2.1.x The issue has been reproduced on latest 2.1 release
Projects
None yet
Development

No branches or pull requests

6 participants