Skip to content

Commit 900f2be

Browse files
committed
fix(security): toast vulnerable to XSS attack, closes #1353
1 parent 6d8fee4 commit 900f2be

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

packages/shell-chrome/src/devtools-background.js

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ chrome.runtime.onMessage.addListener(request => {
4646
if (request === 'vue-panel-load') {
4747
onPanelLoad()
4848
} else if (request.vueToast) {
49-
toast(request.vueToast.message, request.vueToast.type)
49+
toast(request.vueToast)
5050
} else if (request.vueContextMenu) {
5151
onContextMenu(request.vueContextMenu)
5252
}
@@ -65,10 +65,10 @@ function onContextMenu ({ id }) {
6565
if (typeof res !== 'undefined' && res) {
6666
panelAction(() => {
6767
chrome.runtime.sendMessage('vue-get-context-menu-target')
68-
}, 'Open Vue devtools to see component details')
68+
}, 'open-devtools')
6969
} else {
7070
pendingAction = null
71-
toast('No Vue component was found', 'warn')
71+
toast('component-not-found')
7272
}
7373
})
7474
}
@@ -113,7 +113,16 @@ function onPanelHidden () {
113113

114114
// Toasts
115115

116-
function toast (message, type = 'normal') {
116+
const toastMessages = {
117+
'open-devtools': { message: 'Open Vue devtools to see component details', type: 'normal' },
118+
'component-not-found': { message: 'No Vue component was found', type: 'warn' }
119+
}
120+
121+
function toast (id) {
122+
if (!Object.keys().includes(id)) return
123+
124+
const { message, type } = toastMessages[id]
125+
117126
const src = `(function() {
118127
__VUE_DEVTOOLS_TOAST__(\`${message}\`, '${type}');
119128
})()`

0 commit comments

Comments
 (0)