Template escape using function constructor
See original GitHub issueHere is the escape
<p>Hello, {{ this.constructor.constructor('alert("oops")')`` }}</p>
Vue.js version
1.0.26
Reproduction Link
http://jsfiddle.net/yvt7eckL/1/
Steps to reproduce
Open the jsfiddle
What is Expected?
No alert boxes
What is actually happening?
Alert box pops up
Issue Analytics
- State:
- Created 7 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
Template literals (Template strings) - JavaScript | MDN
To escape a backtick in a template literal, put a backslash ( \ ) before the backtick. Dollar signs can be escaped as...
Read more >Error when trying to replace constructor variab [duplicate]
I'm trying to create a clock Class with infinite loop upon start function , by using explicitly declared variable for temp , it...
Read more >DOM based AngularJS sandbox escapes - PortSwigger
Value will contain a reference to the Function constructor which he sends to the generic call method's first argument. The second argument doesn ......
Read more >JavaScript: Template String - Xah Lee
String can also be created by bracketing text with ` (U+60: GRAVE ACCENT) This ... escape grave mark in template string console.log( `a\`b`...
Read more >CoffeeScript
As with functions and other block expressions, multi-line conditionals are delimited by indentation. There's also a handy postfix form, with the if or ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
The solution that vue and any other framework should put as a big disclaimer is for users to set strict content security policy and disallow inline scripts.
Sent from my iPhone
This has been discussed long ago - the issue here is that the moment you use Vue or any other client side framework to compile a template potentially generated by a malicious 3rd party, you are already busted. There are simply too many ways to get around the system when you need to evaluate arbitrary content - all XSS loopholes apply, and it is simply impractical for the framework to take on that responsibility for the user.
In practice, the simple rule is you should always be able to trust the template you pass to Vue. That’s it.
I do agree we should make this more prominent in the docs though.