XPCSafeJSObjectWrapper 是做什么的?
Mozilla Firefox 的 XPCSafeJSObject 包装器实际上是做什么的?
MDC的文档如下:
创建此包装器是为了解决 XPCNativeWrapper 的一些问题。 特别是,某些扩展希望能够安全地访问非本机实现的内容定义对象(以及在没有强大行为保证的情况下访问 XPCNativeWrapper 下的底层 JavaScript 对象)。 XPCSJOW 充当 chrome 代码之间的缓冲区。
这并没有告诉我很多。 特别是,我不知道通过 XPCSafeObject 访问对象与直接访问它们有何不同。
编辑:据我所知,包装器的总体目的是保护特权代码免受非特权代码的侵害。 我不明白(并且似乎没有记录)的是 XPCSafeJSObject 到底是如何做到这一点的。
它是否只是在访问属性之前放弃特权?
What does Mozilla Firefox's XPCSafeJSObject wrapper actually do?
MDC's documentation is as follows:
This wrapper was created to address some problems with XPCNativeWrapper. In particular, some extensions want to be able to safely access non-natively-implemented content defined objects (and to access the underlying JavaScript object under an XPCNativeWrapper without its strong behavior guarantees). XPCSJOW act as a buffer between the chrome code.
This doesn't tell me a lot. In particular, I can't tell how accessing objects via XPCSafeObject is any different to accessing them directly.
Edit: I understand that the purpose of the wrappers in general is to protect privileged code from unprivileged code. What I don't understand (and doesn't seem to be documented) is how exactly XPCSafeJSObject does this.
Does it just drop privileges before accessing a property?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
实际上 XPCSafeJSObjectWrapper 用于所有内容对象,包括窗口和文档(这实际上是最常用的地方。)我相信它的发明主要是为了阻止 XSS 攻击自动变成权限升级攻击(通过对浏览器本身进行 XSS) 。 至少现在,如果发现 XSS 攻击(不幸的是人们会继续寻找),它不会危害整个浏览器。 这是 XPCNativeWrapper 的自然发展,XPCNativeWrapper 最初是浏览器防御 XSS 攻击的手动方式(因此很容易被扩展意外误用)。
Actually XPCSafeJSObjectWrapper is used for all content objects, including windows and documents (which is in fact where it's most usually needed.) I believe it was invented mainly to stop XSS attacks automatically turning into privilege escalation attacks (by doing XSS against the browser itself). At least now if an XSS attack is found (and people will unfortunately keep looking) it doesn't compromise the whole browser. It's a natural development from the XPCNativeWrapper which was originally a manual (and therefore prone to accidental misuse by extensions) way for the browser to defend itself from XSS attacks.
包装器只是确保任何被评估的代码都在没有 chrome 权限的情况下被评估。 不使用此包装器直接访问对象可以允许代码以 chrome 权限运行,然后让该代码执行几乎任何操作。
The wrapper just ensures that any code that gets evaluated gets evaluated without chrome privileges. Accessing objects directly without this wrapper can allow for code to run with chrome privileges, which then lets that code do just about anything.
包装器的目的通常是在与非特权代码交互时保护特权代码。 非特权代码的作者可能会重新定义 JavaScript 对象来执行恶意操作,例如重新定义属性的 getter 来执行不良操作作为副作用。 当特权代码尝试访问该属性时,它会将不良代码作为特权代码执行。 包装器可以防止这种情况发生。 此页面描述了这个想法。
XPCSafeJSObject 为非本机实现的 JavaScript 对象(即不是窗口、文档等,而是用户定义的对象)提供了一个包装器。
编辑:有关其实现方式,请查看 源代码(目前我还没有完全加载。)另请在 DXR 上搜索 XPCSafeJSObject 以获取其他相关源文件。
The purpose of the wrappers in general is to protect Privileged code when interacting with unprivileged code. The author of the unprivileged code might redefine a JavaScript object to do something malicious, like redefine the getter of a property to execute something bad as a side effect. When the privileged code tries to access the property it would execute the bad code as privileged code. The wrapper prevents this. This page describes the idea.
XPCSafeJSObject provide a wrapper for non-natively implemented JavaScript objects (i.e. not window, document, etc. but user defined objects.)
Edit: For how it's implemented, check out the source code (it's not loading completely for me at the moment.) Also search for XPCSafeJSObject on DXR for other relevant source files.