This issue was moved to a discussion.
You can continue the conversation there. Go to discussion →
Should Mithril vnodes be fully JSON-compatible? #2356
Labels
Type: Breaking Change
For any feature request or suggestion that could reasonably break existing code
Type: Enhancement
For any feature request or suggestion that isn't a bug fix
Description + Why
Currently, Mithril's vnodes are fully JSON-compatible, and this was previously exploited very deliberately in v0.2.x by
mithril-objectify
. However, as explained by Dan Abramov, it can run you into trouble if you're not careful with a JSON API. Of course, we typically err towards the side of trusting developers to do the right thing, but a hacked third-party server could just as easily return a{tag: "div", attrs: {innerHTML: "<img src='bad.png' onerror='alert(\"You just got pwned!\")'>"}, children: []}
, leaving a server-driven XSS vector and a very annoying time debugging if the JSON happens to have a top-level tag.Possible Implementation & Open Questions
I'd add a
"vnode tag": Symbol.for("m.vnode")
to each vnode and have Mithril detect that, falling back to the string"m.vnode tag"
. For convenience and internal use, I'd add the following method to detect this:The open question is should I even do this? If there's no real significant risk and us documenting our detection (which we already do) is sufficient on its own, this bug could just be closed and if others run into this issue, we just show them the docs.
Is this something you're interested in working on?
Yes, if this ends up materializing into something we decide to do.
The text was updated successfully, but these errors were encountered: