Skip to content

Possible to bypass XSS filter with nodeNS #168

Description

@hpate-omicron

SSCCE: Ellie

module Main exposing (main)

import Html
import VirtualDom exposing (nodeNS)


main =
    nodeNS "http://www.w3.org/2000/svg"
        "script"
        []
        [ Html.text "alert('Hi')" ]

The user John J on Slack found it, he had this research. Slack link

The crux of it seems to be that nodeNS arguments are swapped between Elm and JS, on the elm side the tag is the first argument passed into nodeNS. Link to code

nodeNS : String -> String -> List (Attribute msg) -> List (Node msg) -> Node msg
nodeNS tag =
  Elm.Kernel.VirtualDom.nodeNS (Elm.Kernel.VirtualDom.noScript tag)

But on the JS side it is expecting the tag as the second argument

var _VirtualDom_nodeNS = F2(function(namespace, tag)

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