攻击者通过利用动画时间线(Animation timelines)中的释放后使用(use-after-free)漏洞,能够在内容进程中实现代码执行。我们已收到关于此漏洞在野被利用的报告。此漏洞影响 Firefox < 131.0.2、Firefox ESR < 128.3.1、Firefox ESR < 115.16.1、Thunderbird < 131.0.1、Thunderbird < 128.3.1 以及 Thunderbird < 115.16.0。
致谢:Fireship
“释放后使用”(use-after-free)漏洞是一种内存损坏问题,发生在程序于内存被释放(回收)后仍继续使用指向该内存的指针(或引用)时。这是一种危险状况,因为相关内存不再由程序拥有,这意味着它可能被重新分配用于其他目的,或被程序的其他部分修改。如果程序继续使用这块已释放的内存,可能导致不可预测的行为,包括崩溃、数据损坏或被攻击者利用。
内存分配与释放:
malloc() 或 new 等函数),并在使用完毕后释放内存(例如使用 free() 或 delete)。问题所在:
后果:
考虑一个 C 语言的简化示例:
#include <stdlib.h>
#include <stdio.h>
int main() {
int *ptr = (int *)malloc(sizeof(int)); // Allocate memory
*ptr = 42; // Use the allocated memory
free(ptr); // Free the memory
// Use the pointer after freeing the memory (use-after-free)
printf("%d\n", *ptr); // Undefined behavior, potential crash or exploit
return 0;
}
在该示例中:
free(ptr) 释放了该内存。ptr 仍被使用(在 printf() 语句中被解引用),这会导致未定义行为。该内存可能已被重新分配,访问它可能导致崩溃,或在更危险的情况下,导致程序被利用。攻击者可以通过精心操纵内存管理来利用释放后使用漏洞。以下是攻击者可能利用此漏洞的方式:
为防止释放后使用漏洞,开发者可以:
NULL:这可以确保即使指针在释放后被意外使用,程序也会以更可预测的方式崩溃或以受控方式运行,而不会访问无效内存。std::shared_ptr、std::unique_ptr)有助于自动管理内存,从而减少手动内存管理出错的可能性。在此特定案例中,CSS 动画时间线(负责控制网页中动画的时序)与其他浏览器组件的交互方式,导致与动画时间线关联的对象被释放,但浏览器仍继续使用该对象。
CSS 动画时间线是一个复杂的系统,它与浏览器引擎的许多不同部分交互,例如渲染引擎、DOM(文档对象模型)和 JavaScript 执行环境。管理与动画关联的对象的生命周期——尤其是当它们被动态更新或移除时——非常棘手,即使是内存管理中的微小错误也可能导致释放后使用漏洞。
在 CVE-2024-9680 的案例中,时间线对象似乎未被正确跟踪,因此它在仍被使用的情况下就被释放了。如果攻击者能够通过精心计时的动画更新或操纵反复触发此漏洞,他们就有可能利用该漏洞。
这个假设性的示例可能涉及创建一个包含一组复杂 CSS 动画的网页,并通过 JavaScript 动态操纵它们以触发释放后使用条件。
<!DOCTYPE html>
<html>
<head>
<style>
@keyframes exampleAnimation {
from { opacity: 0; }
to { opacity: 1; }
}
.animate {
animation: exampleAnimation 5s infinite;
}
</style>
</head>
<body>
<div id="targetElement" class="animate">Animating Element</div>
<script>
// Example setup: A function that continuously creates and destroys animations
// The goal here is to simulate rapid, repeated manipulations of the CSS animation timeline
function triggerVulnerability() {
const target = document.getElementById('targetElement');
// Create an animation, then remove it quickly in a loop
let i = 0;
const interval = setInterval(() => {
i++;
if (i % 2 === 0) {
target.classList.add('animate');
} else {
target.classList.remove('animate');
}
// Potentially causing a race condition or triggering the vulnerability
if (i > 1000) {
clearInterval(interval);
}
}, 1); // Rapid manipulation of the animation state
}
// Simulating dynamic DOM manipulation and timeline interaction
triggerVulnerability();
</script>
</body>
</html>
exampleAnimation),用于淡入元素的透明度。triggerVulnerability())快速地对元素添加和移除 animate 类,导致浏览器的动画时间线被反复更新,并可能迫使浏览器在短时间内连续管理对象的创建和销毁。