Skip to content

Cache hole punching is broken for private blocks, private data is exposed to varnish #5083

Closed
@m1klos

Description

@m1klos

In Magento_PageCache/Observer/ProcessLayoutRenderElement.php when _isScopePrivate is true in a block, wrong block placeholder is generated, it contains private data, which is cached by Varnish. The placeholder should be empty, so it can be populated by ajax.

Steps to reproduce

  1. create a new block, and set _isScopePrivate to true (a property from abstract, originally set to false), this way we indicate we want cache hole punch for this block
  2. try to get data from customer session (e.g. check if the customer is logged in)
  3. place the block (layout xml) in a way to be used in both cached and non-cached pages, in the latter the information will be correct, on cached pages it won't get through.

Expected result

  1. The placeholder should be empty, so it can be populated by ajax.

Actual result

  1. Wrong block placeholder is generated, it contains private data, which is cached by Varnish

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions