针对 Linux、Windows 和 macOS 上文件通知侧信道攻击的研究成果,展示了 inotify/FSEvents 信息泄露、按键时序和网站指纹识别。
本仓库包含论文《File Notification Attacks: Templating and Exploiting Side-Channel Leakage from the File-Notification Systems on Linux, Windows, and macOS》的制品,该论文已被 CCS '26 接收。
访问包含演示的网站:https://inoti.fyi/
完整制品(包括虚拟机镜像)归档于 Zenodo: https://zenodo.org/records/22843469
阅读论文:https://snee.la/pdf/pubs/file-notification-attacks.pdf 或 http://inoti.fyi/pubs/file-notification-attacks.pdf
作为 CCS'26 制品评估的一部分,我们提供了一个带有预打补丁内核的 Debian 13 + KDE Plasma 6 虚拟机。该虚拟机并未用于生成论文的评估结果,也不旨在复现其精确量级。
在此处获取该虚拟机:https://zenodo.org/records/22843469 (linux-vm.tar)
我们使用 Claude (Opus 4.8) 将我们的代码封装成文档完善且高性能的制品(例如,Windows 版本原本有些卡顿)。然而,它生成的代码、脚本和 makefile 均基于我们用于论文的原始代码。
该虚拟机纯粹是为了方便而存在,这样挂载每个攻击时就不需要从头搭建环境或降级内核。虚拟机中演示的底层机制与论文中描述的完全相同,但请注意,我们并未使用该虚拟机生成论文中报告的数据。由于虚拟化环境和底层硬件的原因,绝对时序可能会有所不同。
如果您想在自己的 Linux 系统上运行此程序(特别是下文中的 /dev/ 泄露部分),您使用的内核必须早于 fsnotify 修复(CVE-2025-68788)。 随附的虚拟机已经运行了存在漏洞的内核(6.12.43+deb13-amd64)。
研究结果在 Debian 13 虚拟机(linux-vm/)中复现,该虚拟机从官方 Debian live ISO 安装,使用 KDE Plasma 6(Wayland),内核早于 fsnotify 修复。已安装 inotify-tools、Qt6 开发头文件和 pkexec。其他内容均未升级,安装后内核从未被改动。请不要运行 apt upgrade 或尝试升级内核。此虚拟机镜像故意保持旧版本,未更新,且不包含最新的安全补丁。此虚拟机镜像仅用于快速验证和测试!
虚拟机中的代码、攻击和演示均镜像在 Linux/ 中。
注意:我们在每个命令块的顶部注明了应以哪个用户运行命令。有 [host],即运行虚拟机的主机;[user],即虚拟机中攻击的受害者;以及 [spyuser],需要设置,在大多数 Linux 攻击中将是攻击者。
磁盘镜像以 linux-vm-upload.qcow2 形式提供,使用 zstd 压缩。在运行 run.sh 之前将其重命名为 linux-vm.qcow2(该脚本期望此文件名):
# Run As: [host]
cd linux-vm/
mv linux-vm-upload.qcow2 linux-vm.qcow2
./run.sh
读取 zstd 压缩的 qcow2 需要 qemu-img/qemu-system-x86_64 版本 5.2 或更新(2020 年及以后),可用 qemu-img --version 检查。如果你受限于较旧的 QEMU 且无法打开该镜像,请先将其解压为扁平 qcow2:
qemu-img convert -O qcow2 linux-vm-upload.qcow2 linux-vm.qcow2
4 核、4GB 内存、GUI 显示。登录凭据为:
root,密码 password,user,密码 password,spyuser,密码 password(请勿以 spyuser 登录!)所提供的虚拟机已运行一个存在漏洞、已预先打好补丁的内核
(6.12.43+deb13-amd64),因此无需降级即可使用。你需要 QEMU
来运行此镜像(该镜像带有 GUI)。工件位于虚拟机内的
/home/user/Linux-File-Notification-Attacks。
一条命令即可在虚拟机中完成全新环境搭建:(i) 一个无特权的 spyuser
账户(非 sudo),(ii) 其自有的工件目录副本(否则,另一个
无特权账户无法进入 user 的主目录),
(iii) 以及使两份副本中的所有脚本均可执行。
# In the VM, Run As: [user]
sudo bash ~/Linux-File-Notification-Attacks/setup_attacks.sh
以下每次攻击都以 spyuser 身份运行(su - spyuser,密码 password),
但 auth-ui-redress 除外,它以 user 身份运行(下文将说明)。
证明即使文件无法被直接读取,只要其父目录可读,文件操作通知仍会被投递。
# Run As: [spyuser]
# To switch to spyuser, in a new terminal type `su - spyuser`. The password
# is `password`.
cd ~/Linux-File-Notification-Attacks/unreadable-file-bypass
./watch-syslog.sh
保持其运行,然后在另一个终端以 user 身份生成一行日志:
# Run As: [user]
logger "hello"
这个 Debian 13 镜像没有 rsyslog,因此不存在论文中所示的 /var/log/syslog 文件。脚本改为监视 /var/log/journal/<machine-id>/。思路相同,因为被监视的 .journal 文件归 root(用户)和 systemd-journal(组)所有,而这两者都不是 spyuser。
预期输出(已缩短。machine-id、时间戳以及被访问的具体 .journal 文件会有所不同):
spyuser@inotify-artifact-debian:~/.../unreadable-file-bypass$ ./watch-syslog.sh
proof we can't read the journal files directly, as spyuser:
total 36384
drwxr-sr-x+ 2 root systemd-journal 4096 Jan 24 01:24 . # <-- directory IS readable
-rw-r-----+ 1 root systemd-journal 8388608 Jan 24 01:24 system.journal # <-- but files are 640 root:systemd-journal
-rw-r-----+ 1 root systemd-journal 8388608 Jan 24 01:24 user-1000.journal
...
cat: /var/log/journal/fdcae48e.../system.journal: Permission denied # <-- we cannot read them
watching /var/log/journal/fdcae48e... for writes, run 'logger "hello"' from another terminal now ...
Setting up watches.
Watches established.
# ...meanwhile, in a second terminal [user]: $ logger "hello"
01:24:33 user-1000.journal MODIFY # <-- We are told the file changed
测量 inotify 的通知延迟。
stats.py 是 Linux 产物中唯一带有依赖(numpy)的部分,该依赖可能尚未包含在镜像中:
# Run As: [user]
python3 -c "import numpy" 2>/dev/null || sudo apt install python3-numpy
# Run As: [spyuser]
cd ~/Linux-File-Notification-Attacks/temporal-resolution
./run.sh
watcher 在测试文件上打开一个 inotify 监视,并为它收到的每个 IN_ACCESS 事件打上时间戳。accessor 以每次读取之间 5-10ms 的随机延迟读取同一个文件 1000 次,并自行对每次读取打上时间戳。stats.py 对比这两份时间戳记录,并打印读取发生与通知到达之间的平均/标准差/最小延迟,即 inotify 的时间分辨率。
预期输出(由于这是在 VM 上运行的,数字可能有所不同):
cd ~/Linux-File-Notification-Attacks/temporal-resolution
./run.sh
gcc -O2 -Wall -Wextra -pedantic -Wno-unused-parameter -o ./build/accessor accessor.c
gcc -O2 -Wall -Wextra -pedantic -Wno-unused-parameter -o ./build/watcher watcher.c
Average: 89.16470499923435us # <-- mean notification delay
Standard Deviation: 75.5170821189559us
Standard Error: 2.388059817458752us
Minimum: 18.524999973124068us # <-- best case observed
在两条 gcc 行与统计信息之间,大约有 5-10 秒的停顿且没有任何输出,这正是正在执行的 1000 次读取操作。
并非论文中的完整攻击,而只是该攻击所依赖的过滤概念验证原语:对于系统上任意位置按下的每个按键,打印一条带时间戳的通知,而无需直接读取 /dev/input。
# Run As: [spyuser]
cd ~/Linux-File-Notification-Attacks/inter-keystroke-timing
make
./find-keyboard.sh
在任意窗口中输入(也许是以 user 身份打开的新终端)。每次按键都会打印一行
KEYPRESS。抑制窗口(我们为本次演示启发式地选择了 130ms)会合并由单次
物理按键产生的多个 IN_ACCESS 事件。在实践中,我们注意到该窗口因
不同硬件(例如机械键盘、打字风格)而异。
如果自动检测选错了设备(或未选中任何设备),请在 /proc/bus/input/devices 中找到正确的
eventN 并直接传入。该二进制程序接收要监视的目录、其中的设备名称,以及可选的
抑制窗口(以秒为单位):
# Run As: [spyuser]
./build/keystroke-notify /dev/input event0 # eventN as found above
./build/keystroke-notify /dev/input event0 0.05 # with a 50ms window
在随附的 VM 上,键盘是 event0,但这在不同机器上并不稳定,因此请检查 /proc/bus/input/devices,而不要假定某个编号。
预期输出。 在 VM 窗口中输入 hello(五个按键),使用默认的 130ms 窗口:
./find-keyboard.sh
keyboard device: event0
proof we can't read it directly, as spyuser:
cat: /dev/input/event0: Permission denied # <-- the device file is unreadable
watching /dev/input for accesses to event0 (suppress window 0.130s) ...
01:24:53.802 KEYPRESS /dev/input/event0 # <-- 'h'
01:24:54.309 KEYPRESS /dev/input/event0 # <-- 'e'
01:24:54.720 KEYPRESS /dev/input/event0 # <-- 'l'
01:24:55.137 KEYPRESS /dev/input/event0 # <-- 'l'
01:24:55.554 KEYPRESS /dev/input/event0 # <-- 'o'
五次物理按键产生了五行输出。请注意,这里从不恢复哪个键被按下:该原语仅泄露每次按键的时序。
配置抑制窗口。 它是 keystroke-notify 的可选第三个参数,find-keyboard.sh 将其作为参数传递(默认值 0.13):
./find-keyboard.sh 0.05 # 50ms window
./build/keystroke-notify /dev/input event0 0 # no suppression at all
从 0.01s 开始,重复同样的五次按键,每次按键都会打印两次:
./find-keyboard.sh 0.01
watching /dev/input for accesses to event0 (suppress window 0.010s) ...
01:24:38.775 KEYPRESS /dev/input/event0 # <-- press 1, first IN_ACCESS
01:24:38.836 KEYPRESS /dev/input/event0 # <-- press 1 again, 61ms later
01:24:39.468 KEYPRESS /dev/input/event0 # <-- press 2
01:24:39.552 KEYPRESS /dev/input/event0 # <-- press 2 again, 84ms later
01:24:40.054 KEYPRESS /dev/input/event0
01:24:40.118 KEYPRESS /dev/input/event0
01:24:40.640 KEYPRESS /dev/input/event0
01:24:40.723 KEYPRESS /dev/input/event0
01:24:41.297 KEYPRESS /dev/input/event0
01:24:41.362 KEYPRESS /dev/input/event0
持续以 0.01 秒为步长增大抑制窗口,直到每次按键只产生一条通知。