Forums / Bug Reports / [Fixed v1.5.1] page_not_found on session timeout?

[Fixed v1.5.1] page_not_found on session timeout?

Locked

Started by lat9 on 31 Jan 2012, 5:40 PM · Views: 1,999

Results 1 to 6 of 6
This thread is locked. New replies are disabled.
31 Jan 2012, 5:40 PM
#1
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,137
Plugin Contributions:
56

[Fixed v1.5.1] page_not_found on session timeout?

Running 1.5.0 locally with no add-ons. If a customer signs in, adds something to their cart, and starts the checkout process but then gets distracted so that the session timeout kicks in, the next time they press a "Continue" button they're taken to the page_not_found page.

I've traced this issue down to the following code section within /includes/init_includes/init_sanitize.php:

  $csrfBlackListLocal = array();
  $csrfBlackList = (isset($csrfBlackListCustom)) ? array_merge($csrfBlackListLocal, $csrfBlackListCustom) : $csrfBlackListLocal;
  if (! isset ( $_SESSION ['securityToken'] ))
  {
    $_SESSION ['securityToken'] = md5 ( uniqid ( rand (), true ) );
  }
  if ((isset ( $_GET ['action'] ) || isset($_POST['action']) ) && $_SERVER['REQUEST_METHOD'] == 'POST')
  {
    $mainPage = isset($_GET['main_page']) ? $_GET['main_page'] : FILENAME_DEFAULT;
    if (!in_array($mainPage, $csrfBlackList))
    {
      if ((! isset ( $_SESSION ['securityToken'] ) || ! isset ( $_POST ['securityToken'] )) || ($_SESSION ['securityToken'] !== $_POST ['securityToken']))
      {
        zen_redirect ( zen_href_link ( FILENAME_PAGE_NOT_FOUND, '', $request_type ) );
      }
    }
  }

What is happening is that the securityToken is getting reset (due to the session timeout) so that the value in the $_SESSION is not equal to the value in the $_POST array. While the $mainPage value is valid, the $csrfBlackList array value is empty, resulting ultimately in a redirect to the page_not_found page.

I'm not sure what the $csrfBlackList code is supposed to be doing (it was added for v1.5.0), so I'm wont to simply remove it.

Any help would be appreciated.

31 Jan 2012, 10:40 PM
#2
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,137
Plugin Contributions:
56

Re: [Fixed v1.5.1] page_not_found on session timeout?

FWIW, commenting out the entire code fragment above results in the session timeout redirecting to the time_out page (like it does in previous versions). Any word on what function that code fragment's intended function is/was?

4 Feb 2012, 1:09 PM
#4
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,137
Plugin Contributions:
56

Re: [Fixed v1.5.1] page_not_found on session timeout?

caffeitalia, for this issue to be related to yours the customer would need to be signed into your store and then leave your store's page idle for 24+ minutes.

Any word from the devs on this issue?

17 Jul 2012, 4:23 PM
#5
drbyte avatar

drbyte

Sensei

Join Date:
Jan 2004
Posts:
63,511
Plugin Contributions:
176

Re: [Fixed v1.5.1] page_not_found on session timeout?

The change that will be in the next release is as follows:```
zen_redirect ( zen_href_link ( FILENAME_PAGE_NOT_FOUND, '', $request_type ) );

    zen_redirect ( zen_href_link ( FILENAME_TIME_OUT, '', $request_type ) );

.
Zen Cart - putting the dream of business ownership within reach of anyone!
Donate to: DrByte directly or to the Zen Cart team as a whole

Remember: Any code suggestions you see here are merely suggestions. You assume full responsibility for your use of any such suggestions, including any impact ANY alterations you make to your site may have on your PCI compliance.
Furthermore, any advice you see here about PCI matters is merely an opinion, and should not be relied upon as "official". Official PCI information should be obtained from the PCI Security Council directly or from one of their authorized Assessors.

18 Jul 2012, 5:54 PM
#6
lat9 avatar

lat9

Administrator

Join Date:
Sep 2009
Location:
Stuart, FL
Posts:
14,137
Plugin Contributions:
56

Re: [Fixed v1.5.1] page_not_found on session timeout?

Thanks for the update, DrByte. I'll make that change to my 1.5.0 installations.