bluerobotics / bluerobotics/cockpit
DIY widget: user JavaScript is not sandboxed
- Dominant language
- TypeScript
- Stars
- 198
- Forks
- 63
- Avg merge
- 2d 7h
- Merged PRs (30d)
- 57
Description
The DIY widget runs whatever the operator (or a shared widget JSON) typed, in Cockpit's own page, with Cockpit's privileges. A bad or hostile script can read/write the data lake, fire actions, and take the rest of the UI down with it.
Reproduce: open Edit Mode, add a Do It Yourself widget, put `document.body.innerHTML = ''` (or an uncaught throw inside a `listenDataLakeVariable` callback) in the JS pane, apply. The script is appended as a `` on `document.body` and runs as first-party code. Sharing a DIY widget is therefore the same class of risk as pasting a script into the console.
`executeUserScript` in `src/components/widgets/DoItYourself.vue` creates that `<script>` and appends it to the document. There is no iframe, worker, or CSP isolation. Related symptoms live in #1729, #1591 and #2299; those are about crashes and leftover timers, not isolation.
Contributor guide
No contributing guide indexed for this repository
Research direction
Start by reading executeUserScript in src/components/widgets/DoItYourself.vue and reproduce the document.body.innerHTML change or uncaught callback error described in the issue. Determine an isolation boundary for DIY widget scripts; done means the script cannot access Cockpit data, actions, or page privileges, and its failures do not take down the rest of the UI.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript, typescript
- Domain
- frontend, security
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100