Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(client): XSS vulnerability in components tab #726

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions packages/applet/src/components/state/StateFieldViewer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
import type { CustomInspectorState, InspectorCustomState } from '@vue/devtools-kit'
import type { EditorAddNewPropType } from '~/composables/state-editor'
import { rpc } from '@vue/devtools-core'
import { DevToolsV6PluginAPIHookKeys, DevToolsV6PluginAPIHookPayloads, formatInspectorStateValue, getInspectorStateValueType, getRaw, toEdit, toSubmit } from '@vue/devtools-kit'
import { DevToolsV6PluginAPIHookKeys, DevToolsV6PluginAPIHookPayloads, escape, formatInspectorStateValue, getInspectorStateValueType, getRaw, toEdit, toSubmit } from '@vue/devtools-kit'
import { isArray, isObject, sortByKey } from '@vue/devtools-shared'
import { vTooltip, VueButton, VueIcon } from '@vue/devtools-ui'
import { computed, ref, watch } from 'vue'
Expand Down Expand Up @@ -71,7 +71,7 @@ const normalizedDisplayedValue = computed(() => {
const _value = type.value === 'custom' && !_type ? `"${displayedValue.value}"` : (displayedValue.value === '' ? `""` : displayedValue.value)
const normalizedType = type.value === 'custom' && _type === 'ref' ? getInspectorStateValueType(_value) : type.value
const selectText = type.value === 'string' ? 'select-text' : ''
const result = `<span title="${type.value === 'string' ? props.data.value : ''}" class="${normalizedType}-state-type flex whitespace-nowrap ${selectText}">${_value}</span>`
const result = `<span title="${type.value === 'string' ? escape(props.data.value as unknown as string) : ''}" class="${normalizedType}-state-type flex whitespace-nowrap ${selectText}">${_value}</span>`

if (extraDisplayedValue)
return `${result} <span class="text-gray-500">(${extraDisplayedValue})</span>`
Expand Down
1 change: 1 addition & 0 deletions packages/devtools-kit/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export type * from './core/component-inspector'
export { INFINITY, NAN, NEGATIVE_INFINITY, UNDEFINED } from './core/component/state/constants'
export { formatInspectorStateValue, getInspectorStateValueType, getRaw, toEdit, toSubmit } from './core/component/state/format'
export { isPlainObject } from './core/component/state/is'
export { escape } from './core/component/state/util'
export type * from './core/component/types'
export { updateDevToolsClientDetected } from './core/devtools-client/detected'
export type * from './core/open-in-editor'
Expand Down
Loading