Skip to main content

Theme extension cross-site scripting risk

Investigates untrusted values rendered without safe escaping in theme extensions.

DetailValue
Check IDTHEME_EXTENSION_XSS
SeverityHigh
How it runsAgent review
Applies toApps with a theme app extension

extensions/reviews/blocks/review-list.liquid

{% comment %}
Customer-supplied review text, rendered raw into an attribute
and an event handler. Either one executes on every storefront
visit.
{% endcomment %}
{% for review in product.metafields.app.reviews.value %}
<button onclick="showReview('{{ review.body }}')">
{{ review.body }}
</button>
{% endfor %}

Escape untrusted values and avoid raw HTML rendering.

extensions/reviews/blocks/review-list.liquid

{% comment %}
Escape the text, and hand data to JavaScript through a data
attribute rather than an inline handler.
{% endcomment %}
{% for review in product.metafields.app.reviews.value %}
<button class="js-review" data-review="{{ review.body | escape }}">
{{ review.body | escape }}
</button>
{% endfor %}

<script src="{{ 'reviews.js' | asset_url }}" defer></script>


Was this page helpful?