Firefox 的全新网站隔离安全架构

与任何网页浏览器一样,Firefox 会从不受信任的网站,甚至可能是恶意网站加载代码,并在您的计算机上运行。为了保护您免受恶意网站的新型攻击,并符合 Mozilla 的安全原则,我们着手重新设计桌面版 Firefox。

网站隔离建立在新的安全架构之上,该架构通过将(网页)内容隔离开来,并在其自己的操作系统进程中加载每个网站,从而扩展了当前的保护机制。

这种新的安全架构允许 Firefox 完全隔离来自不同网站的代码,从而防御恶意网站试图访问您访问的其他网站的敏感信息。

更详细地来说,无论何时您打开一个网站并输入密码、信用卡号或任何其他敏感信息,您都希望确保此信息的安全并防止恶意攻击者访问。

作为第一道防线,Firefox 实施了各种安全机制,例如 同源策略,该策略可以防止攻击者在加载到同一个应用程序时访问此类信息。

不幸的是,网页在不断发展,恶意攻击者的技术也在不断发展。为了完全保护您的私人信息,现代网页浏览器不仅需要在应用程序层提供保护,还需要完全隔离不同网站的内存空间 - Firefox 中的全新网站隔离安全架构提供了这些安全保障。

为什么隔离内存空间至关重要

2018 年初,安全研究人员发现了两个主要的漏洞,被称为 熔断幽灵。研究人员利用了现代硬件执行的基本假设,并证明了不受信任的代码如何访问和读取进程地址空间中的任何内存,即使是在像 JavaScript 这样高级的语言中(它为几乎所有网站提供支持)。

虽然由操作系统、CPU 和主要网页浏览器供应商部署的权宜之计快速抵消了攻击,但它们带来了性能成本,并且旨在暂时使用。在公开宣布攻击时,Firefox 团队迅速 降低了高精度计时器的精度,并禁用了允许实现此类计时器的 API,以确保用户的安全。

展望未来,很明显我们需要从根本上重新构建 Firefox 的安全设计,以缓解此类漏洞的未来变体。

让我们仔细看看下面的示例,它演示了攻击者如何在执行幽灵式攻击时访问您的私人数据。

Two hand-drawn diagrams, with the first labeled “Without Site Isolation, we might load both of these sites in the same process :( ”. Two browser windows with partially visible sites “attacker.com” and “my-bank” partial site, are loaded in the same process - process 16. On top of the banking window, there is a cartoon face that looks happy, personifying the browser. The attacker site window contains a face that is looking at the banking window, with a mischievous smile. In the second diagram, labeled “Attacker.com executes a sophisticated attack”, we see the same two browser windows loaded in process 16 and a 1 column table labelled “memory where my-bank’s data is stored in process 16” underneath the banking window. It has two entries: “credit card info” and “login password”. A hand extending from the malicious site reaches toward the table (aka memory of the second window), signifying that the malicious site is able to access sensitive data belonging to the banking window because it is in the same process. The personified browser character is looking towards the malicious site, and exhibits feelings of concern and worry, with exclamation marks floating around the face.

如果没有网站隔离,Firefox 可能会在处理敏感信息的网站的同一个进程中加载恶意网站。在最坏的情况下,恶意网站可能会执行幽灵式攻击来获取访问另一个网站内存的权限。

假设您打开了两个网站 - www.my-bank.com 和 www.attacker.com。如上图所示,使用当前的网页浏览器架构,来自这两个网站的网页内容有可能最终加载到同一个操作系统进程中。更糟糕的是,使用幽灵式攻击会允许 attacker.com 查询和访问 my-bank.com 网站的数据。

尽管存在现有的安全缓解措施,但提供抵御幽灵式攻击所需的内存保护的唯一方法是依赖使用操作系统的进程隔离来隔离来自不同网站的内容的安全保证。

当前浏览器架构的背景

Firefox 网页浏览器在启动后,会在内部生成一个特权进程(也称为父进程),然后该进程会启动和协调多个(网页)内容进程的活动 - 父进程是最特权的进程,因为它被允许执行任何最终用户可以执行的操作。

这种多进程架构允许 Firefox 将更复杂或不太可信的代码分离到进程中,其中大多数进程对操作系统资源或用户文件的访问权限有限。因此,权限较低的代码将需要请求权限较高的代码执行它本身无法执行的操作。

例如,内容进程必须请求父进程保存下载,因为它没有写入磁盘的权限。换句话说,如果攻击者设法破坏了内容进程,它还必须(滥用)一个 API 来说服父进程代表它采取行动。

更详细地来说,(截至 2021 年 4 月)Firefox 的父进程启动了固定数量的进程:八个网页内容进程、最多两个额外的半特权网页内容进程,以及四个用于网页扩展、GPU 操作、网络和媒体解码的实用程序进程。

虽然将内容分离到当前的八个网页内容进程中已经提供了坚实的基础,但它不符合 Mozilla 的安全标准,因为它允许两个完全不同的网站最终出现在同一个操作系统进程中,因此共享进程内存。为了解决这个问题,我们的目标是创建一个将每个网站都加载到其自身进程中的网站隔离架构。

A hand drawn diagram titled “Loading Sites with Current Browser Architecture”. On the left hand-side, from top to bottom, there are four browser windows with different sites loaded. The first window, www.my-bank.com, is loaded in process 3. The second window is loaded in process 4. The third window is loaded in process 5. The last window with a url - “www.attacker.com” - is loaded in process 3, same as the first window. On the right hand-side of the drawing, there is a table titled “List of Content Processes”. The table contains two columns: “site” and “pid”, which stands for process id. In the table, the first window, my-bank.com, and the last attacker.com window have the same PID.

如果没有网站隔离,Firefox 不会将网页内容分离到不同的进程中,并且不同的网站有可能加载到同一个进程中。

假设您在不同的标签页中打开了一些网站:www.my-bank.com、www.getpocket.com、www.mozilla.org 和 www.attacker.com。如上图所示,my-bank.com 和 attacker.com 有可能最终加载到同一个操作系统进程中,这将导致它们共享进程内存。正如我们在前面的示例中看到的那样,使用这种分离模型,攻击者可以执行幽灵式攻击来访问 my-bank.com 的数据。

A hand drawn diagram titled “Loading Subframes With Current Browser Architecture”. There is one browser window drawn. The window, www.attacker.com, embeds a page from a different site, www.my-bank.com. The top level page and the subframe are loaded in the same process - process 3.

如果没有网站隔离,浏览器将加载嵌入的页面(例如银行页面或广告)到与顶级文档相同的进程中。

虽然理解将网站加载到不同的标签页中很简单,但网站也有可能通过所谓的子帧嵌入到其他网站中 - 如果您曾经访问过有广告的网站,这些广告可能就是子帧。如果您曾经拥有个人网站,并且您在其内嵌入了包含您喜欢的歌曲的 YouTube 视频,那么 YouTube 视频就嵌入在一个子帧中。

在一个更危险的情况下,恶意网站可能会在子帧中嵌入一个合法网站,并试图欺骗您输入敏感信息。使用当前的架构,如果一个页面包含来自不同网站的任何子帧,它们通常会与外部标签页位于同一个进程中。

这将导致页面及其所有子帧共享进程内存,即使子帧来自不同的网站。在成功执行幽灵式攻击的情况下,顶级网站可能会访问它不应该访问的敏感信息,这些信息来自它嵌入的子帧(反之亦然) - Firefox 中的全新网站隔离安全架构将有效地使恶意网站更难执行此类攻击。

网站隔离在 Firefox 中的工作原理

在桌面版 Firefox 中启用网站隔离时,每个唯一网站都会加载到一个单独的进程中。更详细地来说,加载“https://mozilla.org”以及加载“http://getpocket.com”会导致网站隔离将这两个网站分离到它们自己的操作系统进程中,因为它们不被视为“同网站”。

同样,“https://getpocket.com”(注意 http 和 https 之间的区别)也将加载到一个单独的进程中 - 因此最终所有三个网站都将在不同的进程中加载。

为了完整起见,某些域名(例如“.github.io”或“.blogspot.com”)过于通用,无法识别“网站”。这就是为什么我们使用 社区维护 的有效顶级域名 (eTLD) 列表来帮助区分不同网站。

由于“github.io”被列为 eTLD,“a.github.io”和“b.github.io”将加载到不同的进程中。在我们正在进行的示例中,网站“www.my-bank.com”和“www.attacker.com”不被视为彼此的“同网站”,并将被隔离到单独的进程中。

Two hand-drawn diagrams, with the first labeled “With Site Isolation, we will load these sites in different processes”. It shows two browser windows, one www.attacker.com , loaded in process 5, and www.my-bank.com loaded in process 16. On top of the banking window, there is a cartoon face that looks happy, personifying the browser. In contrast, the webpage area of the www.attacker.com window, contains a face that is looking at the banking window, with a mischievous smile. In the second diagram, labeled “Attacker.com tries to execute a sophisticated attack”, we see the same two browser windows. There is a 1 column table labelled “memory where my-bank’s data is stored in process 16” underneath the banking window . It has two entries: “credit card info” and “login password”. A hand extending from the malicious site tries to reach towards the table (aka memory of the banking window), but is unable to reach it, due to the process boundary. The face of the malicious site is frowning and looks unhappy, while the face, representing the browser, continues to look happy and carefree. The second window’s data is safe from the malicious site.

使用网站隔离,Firefox 将每个网站加载到其自身的进程中,从而隔离彼此的内存,并依赖操作系统的安全保证。

假设现在您打开了相同的两个网站:www.attacker.com 和 www.my-bank.com,如上图所示。网站隔离识别出这两个网站不是“同网站”,因此网站隔离架构将完全将来自 attacker.com 和 my-bank.com 的内容分离到单独的操作系统进程中。

这种来自不同网站的内容的进程分离提供了所需的内存保护,以允许安全的浏览体验,使网站更难执行幽灵式攻击,并最终为我们的用户提供安全的浏览体验。

The window, www.attacker.com, embeds a page from a different site, www.my-bank.com. The top level page is loaded in process 3 and the subframe corresponding to the bank site is loaded in process 5. The two sites are, thus, isolated from each other in different operating system processes.

使用网站隔离,Firefox 将来自不同网站的子帧加载到其自身的进程中。

与将网站加载到两个不同的标签页中相同的是,将两个不同的网站加载到子帧中时也会进行分离。让我们回顾一下前面的示例,其中页面包含子帧,使用网站隔离,与顶级页面不是“同网站”的子帧将加载到不同的进程中。

在上图中,我们看到页面 www.attacker.com 嵌入了一个来自 www.my-bank.com 的页面,并加载到不同的进程中。将顶级文档和来自不同网站的子帧加载到各自的进程中,可以确保它们彼此隔离内存,从而提供强大的安全保障。

网站隔离的额外优势

通过使用网站隔离架构,我们能够为 Firefox 带来额外的安全强化措施,以保护您和您的数据安全。除了提供抵御可能的安全威胁的额外保护层之外,网站隔离还带来了其他优势

  • 通过将更多页面放到单独的进程中,我们可以确保在一个页面上进行繁重的计算或垃圾回收不会降低其他进程中页面响应能力。
  • 使用更多进程来加载网站使我们能够将工作分散到多个 CPU 内核,并更有效地使用底层硬件。
  • 由于更精细的网站分离,子帧或标签崩溃不会影响加载到不同进程中的网站,从而导致应用程序稳定性提高,用户体验更好。

展望未来

我们目前正在桌面浏览器 Nightly 和 Beta 上为一部分用户测试网站隔离,并且很快就会向更多桌面用户推出。但是,如果您现在就想享受改进的安全架构带来的益处,您可以从 这里 下载 Nightly 或 Beta 浏览器,然后按照以下步骤操作

如何在 Firefox Nightly 上启用网站隔离

  1. 导航到 about:preferences#experimental
  2. 选中“Fission(网站隔离)”复选框以启用。
  3. 重新启动 Firefox。

如何在 Firefox Beta 或正式版上启用网站隔离

  1. 导航到 about:config。
  2. 将 `fission.autostart` 首选项设置为 `true`。
  3. 重新启动 Firefox。

有关我们如何将网站和子框架分组在一起的技术细节,您可以查看我们新的进程管理器工具“about:processes”(在地址栏中输入)并关注项目: https://wiki.mozilla.org/Project_Fission

在 Firefox 桌面版上启用网站隔离后,Mozilla 将其安全保证提升到一个新的高度,并通过依靠操作系统级进程隔离的内存保护机制来保护您免受新型恶意攻击。如果您有兴趣为 Mozilla 的开源项目做出贡献,您可以帮助我们提交错误报告 这里,如果您在启用网站隔离时遇到任何问题。

致谢

网站隔离(Fission 项目)是一个庞大而漫长的项目。感谢所有为这项工作做出贡献的才华横溢且敬业的同事!与那些热衷于构建我们想要的世界网络的人一起工作是一种荣幸:自由、包容、独立且安全!特别感谢 Neha Kochar、Nika Layzell、Mike Conley、Melissa Thermidor、Chris Peterson、Kashav Madan、Andrew McCreight、Peter Van der Beken、Tantek Çelik 和 Christoph Kerschbaumer 的宝贵意见和讨论。最后,感谢 Morgan Rae Reschenberg 帮助我撰写替代文本,以符合我们网络可访问性原则的高标准,并使互联网上的每个人都能轻松获取网站隔离带来的益处。

关于 Anny Gakhokidze

高级平台工程师,负责 Firefox 的网站隔离和 DOM 相关功能。

Anny Gakhokidze 的更多文章...