Code Monkey home page Code Monkey logo

Comments (4)

harlan-zw avatar harlan-zw commented on August 20, 2024 5

To give context, you are providing a string to the children of script, which accepts raw scripts.

The primary use case for doing this, is to insert application scripts within the head, so raw scripts are allowed by default.

There are many ways you can solve this on your end:

  • use @vueuse/schema-org
  • build the schema object as an object then create the string using JSON.stringify
  • provide the children as an object (it will be encoded for you automatically)
  • just sanitise the user input when you make the string

There isn't too much this package can do to avoid you from introducing XSS vulnerabilities into your app if you really want.

I will consider the following though:

  • if the script type is application/json we can sanitise the input to be JSON
  • introduce useHeadSafe to provide a bulletproof way to avoid XSS

Both of these don't fix the "XSS", it's on the dev not to do silly things with user input

from head.

Skmt3P avatar Skmt3P commented on August 20, 2024

+1

from head.

Skmt3P avatar Skmt3P commented on August 20, 2024

Since @harlan-zw gave us this idea, I'm sure this issue is no longer a problem, but I'll share this issue's reproduction now,
https://stackblitz.com/edit/nuxt-starter-nynkwv?file=app.vue

I'm looking forward to useHeadSafe() coming to Nuxt3 👍

from head.

harlan-zw avatar harlan-zw commented on August 20, 2024

Hey, there are many XSS improvements to address this issue available since 1.1.0.

If you have any other ideas on how to improve XSS issues then please create a new issue! Happy to explore making the package as safe as possible without hindering DX.

from head.

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.