plotly / dash

Data Apps & Dashboards for Python. No JavaScript Required.

Home Page:https://plotly.com/dash

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] Possible XSS issue within metadata

chrispymm opened this issue · comments

Describe your context

dash                 2.8.0
dash-core-components 2.0.0
dash-html-components 2.0.0
dash-table           5.0.0

Describe the bug
When accessing this url (or similar)

http://0.0.0.0:8050/wp-content/plugins/dzs-videogallery/deploy/designer/preview.php?swfloc="><script>alert(document.domain)</script>

I see an alert pop up on the screen with the document.domain showing that the JS within the url was inserted into the page.

Inspecting the page I can see that the metadata in the head contains opengraph tags for a twitter card, and the twitter:url tag has the offending JS appended after it

<meta name="description" content="">
<!-- Twitter Card data -->
<meta property="twitter:card" content="summary_large_image">
<meta property="twitter:url" content="http://0.0.0.0:8050/wp-content/plugins/dzs-videogallery/deploy/designer/preview.php?swfloc="><script>alert(document.domain)</script>

Our app is using an index string as per the docs, but this issue appears even without it.

app.index_string = """
<!DOCTYPE html>
<html>
    <head>
        {%metas%}
        <title>{%title%}</title>
        {%favicon%}
        {%css%}
    </head>
    <body>
        {%app_entry%}
        {%config%}
        {%scripts%}
        {%renderer%}
    </body>
</html>
"""

I am unsure where the twitter card metadata is coming from, our app does not add it (as far as I can see) but the dash docs only claim to add 3 meta tags by default, none of which is twitter/og related. Is this part of dash?

Another maybe related note, providing an array of meta tags to the Dash command as per the docs does not change the tags that are output.

Expected behavior

No JS alert should be seen. Url should be escaped before insertion into the page.

I am aware this could be specific to our app, but I can find nothing within our code that is modifying these tags, so it appears to be an issue with dash. Any help or guidance would be appreciated.

Related to #2536

Thanks for reminding me @AnnMarieW!

@chrispymm can you try updating to the latest Dash v2.14? We included a fix for #2536 (#2540) in Dash v2.10 that I suspect fixes your flavor too.

Thanks @alexcjohnson, I've updated to 2.14.2 and that has resolved the issue. My apologies, I know I upgraded as part of my attempts to solve the issue, and only raised the issue because it hadn't worked! But clearly I made a mistake somewhere 🤦‍♂️.