vue-untrusted-bind
An object the component did not build spread onto a component chosen at run time.
- Group
- Code
- Runs
- Runs under ur scan:
ur scan --rule vue-untrusted-bind - Level
- warning
- Reads
- Every file
- Fix
- None: which keys an element needs is the component's to decide
Why
v-bind="obj" sets every key of obj as an attribute or a property of the element or component it is written on. An object that comes from data, such as a dashboard's configuration, a report, or a property its parent fills from either, lets whoever wrote the data choose attributes such as href, innerHTML, style, event handlers, or the properties of the component it reaches, which on a <component :is> is chosen at run time too. Bind the properties the element needs one by one, or pick the known keys from the object first.
The fix, as Ur suggests it: bind the known properties one by one.
For agents
Bind the attributes and properties an element needs one by one; spread with v-bind="obj" only objects the component builds itself, such as $attrs.
Example
app/report_item.vue<script>
export default {
props: { item: { type: Object, required: true } },
};
</script>
<template>
<component :is="item.type" v-bind="item" />
</template>
$ ur scan --rule vue-untrusted-bind
warning[vue-untrusted-bind]: `v-bind` spreads a property its parent chooses onto a component chosen at run time
--> ./app/report_item.vue:8:30 `v-bind="item"`
= hint: bind the known properties one by one
= see: CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), MITRE (2024-11-19), https://cwe.mitre.org/data/definitions/79.html
scanned 1 file (no framework recognized)
vue-untrusted-bind: 1 high, 0 medium
1 finding and 0 of medium confidence
Source
CWE-79: Improper Neutralization of Input During Web Page Generation ('Cross-site Scripting'), MITRE (2024-11-19).