-
-
Notifications
You must be signed in to change notification settings - Fork 488
Description
Describe the bug
I discovered a way to craft malicious markdown files that will cause the obsidian-dataview plugin to execute arbitrary commands on users’ systems. This is due to the unsafe use of eval within the evalInContext function located in src/api/inline-api.ts.
This has been assigned a CVE of CVE-2021-42057 for tracking.
To Reproduce
The following proof-of-concept can be used to display a file on a user’s system by executing the cat command:
```dataviewjs
require("child_process").exec("cat /etc/passwd",(_0,stdout,_1) => dv.span(stdout));""
```
A malicious user could leverage this vulnerability to execute arbitrary code on other users' systems by getting them to open an untrusted markdown file. This is especially dangerous in environments where users share vaults.
Expected behavior
DataviewJS should not make an unsafe call to eval using user supplied input.
Additional Context
Shortly after we privately disclosed this issue, @blacksmithgu promptly changed the default behavior of Dataview to no longer enable JavaScript Queries by default (see release 0.4.13). This helps protect new dataview users and provides a way for existing dataview users to mitigate this issue by disabling the JavaScript Query functionality when opening untrusted markdown.
@blacksmithgu is currently working on additional solutions and provided permission for us to open a public issue here for tracking.