GithubHelp home page GithubHelp logo

Comments (5)

collimarco avatar collimarco commented on June 8, 2024 2

I made some testing now and unfortunately Editor.js seems vulnerable:

  1. Just try to add a link and type javascript:alert('test') as the URL
  2. The href is added to the page without any sanitization
  3. Save and reload the document from JSON
  4. Again, the JSON is converted to HTML without any sanitization (you will see <a href="javascript:alert('test')"> in the code)

from editor.js.

collimarco avatar collimarco commented on June 8, 2024

Another test:

  1. Add some code to the text in the saved JSON, like "This is a paragraph <script> alert('xss') </script>"
  2. If you load the Editor.js with that JSON, the script is injected in the page
  3. However from my test the script doesn't seem to be executed, probably because the HTML is appended to the DOM (and I think that append or similar functions don't execute the scripts)

from editor.js.

collimarco avatar collimarco commented on June 8, 2024

Editor.js sanitizes all content in several cases: on render, on paste, and on save.
https://editorjs.io/inline-tool-sanitizing/

This sentence is strange, because it's not the behavior that I am seeing.

from editor.js.

ConnectGrid avatar ConnectGrid commented on June 8, 2024

Not sure which server-side language you use, but that shouldn't matter much. The output of EditorJS is JSON, so you convert that to whatever object representation your server-side language supports, sanitize each block, and then convert back to JSON. This should be fairly easy to do in the server side programming, and you have full control over it.

from editor.js.

collimarco avatar collimarco commented on June 8, 2024

you convert that to whatever object representation your server-side language supports, sanitize each block, and then convert back to JSON

I've done that properly for our application, but it's really a tedious task: you need to unwrap the JSON and parse each field. And you need to implement that for each block that you use, it's not a single function.

I guess that many applications are vulnerable and simply load the saved JSON data into Editor.js.

from editor.js.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.