Skip to content

Commit 24c6189

Browse files
committed
MC-15311: [Sec] PageBuilder XSS Injection Possible Through Block on HTML Code Content Type For CSS Classes Attribute & in TinyMCE
Escape customVar directives on storefront
1 parent 722a9e0 commit 24c6189

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

app/code/Magento/PageBuilder/Plugin/Filter/TemplatePlugin.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,32 @@ public function afterFilter(\Magento\Framework\Filter\Template $subject, string
105105
return $result;
106106
}
107107

108+
/**
109+
* Determine if custom variable directive's return value needs to be escaped and do so if true
110+
*
111+
* @param \Magento\Framework\Filter\Template $subject
112+
* @param \Closure $proceed
113+
* @param $construction
114+
* @return string
115+
*/
116+
public function aroundCustomvarDirective(
117+
\Magento\Framework\Filter\Template $subject,
118+
\Closure $proceed,
119+
$construction
120+
) {
121+
// Determine the need to escape the return value of observed method.
122+
// Admin context requires store ID of 0; in that context return value should be escaped
123+
$shouldEscape = $subject->getStoreId() !== null && (int) $subject->getStoreId() === 0;
124+
125+
if (!$shouldEscape) {
126+
return $proceed();
127+
}
128+
129+
$result = $proceed($construction);
130+
131+
return htmlspecialchars($result);
132+
}
133+
108134
/**
109135
* Create a DOM document from a given string
110136
*

0 commit comments

Comments
 (0)