Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Possible to bypass XSS filter with nodeNS #168

Closed
hpate-omicron opened this issue Mar 25, 2020 · 3 comments
Closed

Possible to bypass XSS filter with nodeNS #168

hpate-omicron opened this issue Mar 25, 2020 · 3 comments

Comments

@hpate-omicron
Copy link
Contributor

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)
@lydell
Copy link

lydell commented Mar 6, 2021

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

This is close, but not quite what the issue is.

Compare nodeNS:

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

…with keyedNodeNS:

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

nodeNS first parameter is named wrong, and noScript is uselessly called on it. Here’s my suggestion:

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

@wclr
Copy link

wclr commented Apr 20, 2021

Seems there is just just a little mistake made by @evancz.

@evancz
Copy link
Member

evancz commented May 12, 2022

Fixed in 9a389f8 which should be published shortly with version 1.0.3. Thank you for the report, and thank you to @jfmengels for organizing the XSS issues and coordinating on testing.

@evancz evancz closed this as completed May 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants