Skip to content

[BUG] Turn twitter cards off by default to avoid security issues #2536

@shankari

Description

@shankari
  • replace the result of pip list | grep dash below
dash                      2.9.3
dash-auth                 2.0.0
dash-bootstrap-components 1.4.1
dash-core-components      2.0.0
dash-extensions           0.1.13
dash-html-components      2.0.0
dash-table                5.0.0
  • if frontend related, tell us your Browser, Version and OS

    • OS: OSX
    • Browser Firefox
    • Version 102.10

Describe the bug

Deploying a dash app with pages allows attackers to embed code into the webapp. This is a potential security vulnerability since it allows attackers to execute arbitrary code in the context of the dash sandbox.

Concretely, if use_pages is true, dash calls self._pages_meta_tags()

if self.use_pages:

which always adds the twitter and og meta tags

<meta property="twitter:card" content="summary_large_image">

The twitter meta tag includes the URL

            <!-- Twitter Card data -->
            <meta property="twitter:card" content="summary_large_image">
            <meta property="twitter:url" content="{flask.request.url}">
            <meta property="twitter:title" content="{title}">
            <meta property="twitter:description" content="{description}">
            <meta property="twitter:image" content="{image_url}">

So if the dash app is involved with a URL that includes a <script> tag, the script specified in the tag will be executed.

Example URL

[dash_app_base_url]/?'"--></style></scRipt><scRipt>netsparker(0x000F45)</scRipt>

This causes our dash app to fail cyber security/pen testing scans.

A workaround is to a custom index_string which removes all meta tags, but that has the disadvantage of not including any meta tags, even the ones that we might want.

A better option would be to make the twitter and og meta tags opt-in; it is not clear that specifying a twitter card is necessary for all deployers.

I am happy to submit a PR (include_card_configs property) if that would help

Screenshots


Vulnerability report

Screenshot 2023-05-21 at 9 54 22 PM

Page source includes the embedded script

Screenshot 2023-05-21 at 9 52 51 PM

Example of an embedded alert in firefox

Screenshot 2023-05-21 at 9 57 17 PM

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions