4 ms·
since this is for security: I'm quite uncomfortable with the way APIs are exposed to the browser instance that does the UI rendering. As far as I can see from t
by zemnmez 6y ago
since this is for security: I'm quite uncomfortable with the way APIs are exposed to the browser instance that does the UI rendering. As far as I can see from the code, extremely sensitive functions such as 'execute' are attached directly to the window [1][4], then they are invoked by postMessaging into the topmost window [2][3]. This makes XSS in essence immediate remote code execution, but more pointedly it voids some of the security guarantees about iframes, which can assumedly use window.top.postMessage() to post the 'execute' call directly to the browser. If you're developing, e.g. a chat app, you might use iframes to support, for example OEMBED -- and then even codepen oembeds may well be able to execute code.
I like this direction for applications, but browser security protocols are a nightmare to replicate properly.
I recommend using pre-existing interfaces for launching apps like custom scheme URIs, or if really necessary writing individual handlers for the heavy lifting. I think the postMessage approach is great, too but it's vital that the caller `origin` is checked. The web app shouldn't need to run arbitrary commands on the computer.
[1]: https://github.com/tauri-apps/tauri/blob/2681ad361b4295756bef560b5d74ece2a757749f/cli/tauri.js/api-src/process.ts#L10 https://github.com/tauri-apps/tauri/blob/2681ad361b4295756be...
[2]: https://github.com/tauri-apps/tauri/blob/015474657c955c7ad29463e9e88a26c34fa8e560/cli/tauri.js/templates/tauri.js#L16 https://github.com/tauri-apps/tauri/blob/015474657c955c7ad29...
[3]: https://github.com/tauri-apps/tauri/blob/c8f430297f95df16216f222772a8f989d2efd3e5/tauri/src/event.rs#L47 https://github.com/tauri-apps/tauri/blob/c8f430297f95df16216...
[4]: https://github.com/tauri-apps/tauri/blob/c8f430297f95df16216f222772a8f989d2efd3e5/tauri/src/endpoints.rs#L160 https://github.com/tauri-apps/tauri/blob/c8f430297f95df16216...
- zemnmez 6y agoThe author(s) got in contact with me about this post: it does appear that the APIs are exposed at the window level, meaning any iframe can access these functions. It's important to note that CSP does not traverse iframes, or at least, has very strict rules about how it does due to an information leak in CSP1 [1]. This means embedded content is not going to be affected by any CSP rules. OEMBED content, or sandboxed rendered markdown is going to be served from the `null` origin, meaning that frame-src rules will have no granularity. [1]: http://archive.is/UXD8j http://archive.is/UXD8j
- buffersandbeer 6y agoHas an issue been opened in their github for this? I looked quickly and didn't see one, but would love to track it.