sadpandajoe commented on code in PR #43504:
URL: https://github.com/apache/superset/pull/43504#discussion_r3858543077
##########
superset/views/base.py:
##########
@@ -812,6 +813,14 @@ def get_spa_template_context(
# No custom URL either, use default SVG
spinner_svg = get_default_spinner_svg()
+ # Serve the spinner as an <img> data URI (see spa.html). SVG loaded via
<img>
+ # can't execute scripts, so rendering doesn't depend on
sanitize_svg_content.
+ spinner_svg_data_uri = None
+ if spinner_svg:
+ spinner_svg_data_uri = "data:image/svg+xml;base64," + base64.b64encode(
+ spinner_svg.encode("utf-8")
+ ).decode("ascii")
Review Comment:
Agreed—the truthy value is encoded without a string check, so a malformed
persisted theme can make each SPA request fail with `AttributeError`. Could
this treat a non-string `brandSpinnerSvg` as absent before encoding?
##########
superset/templates/superset/spa.html:
##########
@@ -144,11 +144,14 @@
{% set tokens = theme_tokens | default({}) %}
{% set spinner_style = "width: 70px; height: auto; position: absolute;
top: 50%; left: 50%; transform: translate(-50%, -50%);" %}
- {% if spinner_svg %}
- <!-- Inline SVG: Either custom theme SVG or default spinner -->
- <div style="{{ spinner_style }}">
- {{ spinner_svg | safe }}
- </div>
+ {% if spinner_svg_data_uri %}
Review Comment:
This XSS-containment change has no regression coverage: the existing theme
tests do not exercise a malicious `brandSpinnerSvg` through this template, so
reverting to inline SVG would still pass. Could we add a test that asserts the
rendered splash only uses a base64 data-URI image for that input?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]