最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

magento2 - user logged in as another user, when FPC set to varnish - Stack Overflow

matteradmin3PV0评论
  • Magento 2.4.7-p4
  • Varnish 7.5
  • PHP 8.3

We are running Magento 2.4.7-p4 with Varnish 7.5 as the Full Page Cache (FPC) and PHP 8.3. The Varnish configuration has been set up following Magento's recommended guidelines. However, we are facing a critical issue where some users report being suddenly logged in as another user, gaining access to My Account, and being able to edit sensitive information like addresses.

When we switch back to Magento’s built-in cache, the issue disappears.

sub vcl_recv {
    
        ....
    

        if (req.url ~ "^/rest/" || req.url ~ "/customer" || req.url ~ "/account" || req.url ~ "/checkout" || req.url ~ "/catalogsearch" || req.url ~ "/health_check.php" || req.url ~ "/sitemap*.xml" || req.url ~ "/sitemap" || req.url ~ "/feeds" || req.url ~ "\.xml$" || req.url ~ "^/swagger/") {
          
            return (pass);
        }
        
        if (req.http.Cookie) {
            if (req.http.Cookie ~ "(PHPSESSID)" || req.url ~ "(account|admin|cart|checkout|customer)") {
                return (pass);
            }
        }
    ...
}
sub vcl_backend_response {

   ....

    if (beresp.status == 200 || beresp.status == 404) {
        return (deliver);
    } elsif (beresp.http.Cache-Control ~ "private") {
        set beresp.uncacheable = true;
        set beresp.ttl = 0s;
        return (deliver);
    }

   ....

}
Post a comment

comment list (0)

  1. No comments so far