防止网络工作者使用 IndexedDB
我正在开发一个应用程序,其中有多个网络工作者一起运行。这些网络工作者是由第三方开发的,不受信任。他们互相提供postmessage API。
我想让网络工作者能够安全地访问本地存储。 IndexedDB 是标准选择,但是我需要确保恶意网络工作者无法干扰另一个网络工作者的数据。
我最初的想法是我可以以某种方式“域”每个网络工作者。每个人都可以访问自己的 IndexedDB 片段,并且无法看到其他网络工作者放入其他片段中的存储。目前,我认为这是不可能的,因为我需要工作人员一起存在于一个 iframe 中。
我的下一个想法是拥有一个具有 IndexedDB 访问权限的受信任的 Webworker,并为所有其他 Webworker 设置沙箱规则,这样他们根本无法使用 IndexedDB,而是必须与受信任的 Webworker 的 API 进行通信存储和检索本地数据。我目前的理解是,如果我使用两个 iframe,我就可以让它工作,其中第一个 iframe 可以访问 IndexedDB 并运行受信任的 webworker,第二个 iframe 位于不同的域中,非恶意 webworker 知道不要使用贮存。
我不是两个 iframe 解决方案的忠实粉丝 - 它很复杂,具有性能开销,并且需要 webworker 开发人员知道他们无法安全地使用本地存储,即使他们实际上具有访问权限 - 我正在寻找一种更好的沙箱方法远离indexeddb的特定网络工作者。
I'm working on an application where I have multiple webworkers running together. These webworkers are developed by third parties, and are not trusted. They provide postmessage APIs to each other.
I would like to enable the webworkers to have safe access to local storage. IndexedDB is the standard choice, however I need to ensure that a malicious webworker cannot interfere with the data of another webworker.
My original idea was that I could 'domain' each webworker somehow. Each one gets access to its own piece of IndexedDB, and cannot see the storage put in other pieces by other webworkers. At the moment, I do not believe this is possible since I need the workers to exist together in one iframe.
My next idea was to have a single, trusted webworker that has IndexedDB access, and set up sandbox rules for all of the other webworkers such that they can't use IndexedDB at all, but instead must communicate with the API of the trusted webworker to store and retrieve local data. My current understanding is that I can get this to work if I use two iframes, where the first iframe has access to IndexedDB and runs the trusted webworker, and the second iframe is in a different domain where non-malicious webworkers know not to use the storage.
I am not a huge fan of the two iframe solution - it's complex, has performance overheads, and requires webworker devs to know they can't safely use localstorage even though they actually have access - and I'm looking for a better way to sandbox specific webworkers away from indexeddb.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论