andrei-majer/bitlocker-hardening
GitHub: andrei-majer/bitlocker-hardening
通过自动将 BitLocker 从仅 TPM 模式切换为 TPM+PIN 模式,缓解 CVE-2026-45585 物理绕过漏洞的 PowerShell 脚本。
Stars: 3 | Forks: 0
# 🔐 yellowkey 缓解措施
### 针对 CVE-2026-45585 (YellowKey) 的 BitLocker TPM+PIN 加固
**针对 WinRE BitLocker 绕过漏洞的自动化缓解方案 —— 目前尚无完整补丁**
[](https://nvd.nist.gov/vuln/detail/CVE-2026-45585)
[](https://www.microsoft.com/en-us/windows)
[](https://learn.microsoft.com/en-us/powershell/)
[](https://opensource.org/licenses/MIT)
## 🔍 漏洞详情
**YellowKey** 是一个已公开披露的 BitLocker 绕过漏洞,它能让拥有物理访问权限的攻击者在受 BitLocker 保护的 Windows 11 磁盘上获得不受限制的 shell 访问权限 —— 无需恢复密钥,无需 PIN 码,也无需任何凭据。
Windows 恢复环境 (`WinRE`) 内的一个组件 (`autofstx.exe`) 会执行一项事务性 NTFS 重放例程,该例程会删除 `winpeshl.ini`。其副作用是启动了一个具有对已解密卷完全访问权限的 shell。攻击者可以通过将特定文件夹复制到 USB 驱动器(或直接复制到 EFI 分区)、重启进入 WinRE 并按住 CTRL 键来触发此漏洞。
| | 详情 |
|---|---|
| **CVE** | [CVE-2026-45585](https://nvd.nist.gov/vuln/detail/CVE-2026-45585) |
| **CVSS Score** | 6.8 (中危) |
| **CVSS Vector** | `CVSS:3.1/AV:P/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H` |
| **CWE** | CWE-77 (命令注入) |
| **攻击向量** | 需要物理访问权限 |
| **披露日期** | 2026年5月19日 |
| **补丁** | 暂无 —— Microsoft 仅发布了手动缓解措施 |
| **MSRC 公告** | [msrc.microsoft.com/update-guide/vulnerability/CVE-2026-45585](https://msrc.microsoft.com/update-guide/vulnerability/CVE-2026-45585) |
| **PoC** | 已公开 ([Nightmare-Eclipse/YellowKey](https://github.com/Nightmare-Eclipse/YellowKey)) |
| **受影响版本** | Windows 11 (24H2, 25H2, 26H1), Windows Server 2022/2025 |
| **不受影响版本** | Windows 10 |
## 💡 缓解措施
从 **仅 TPM** 切换到 **TPM+PIN** 可以完全阻止该攻击。由于在启动时需要输入 PIN 码,无论 WinRE shell 是如何被触发的,攻击者都无法解密驱动器 —— 如果没有正确的 PIN 码,TPM 将不会释放卷主密钥。
该脚本会处理阻止 `manage-bde` 默认添加 PIN 保护器的组策略前置条件,然后在一次运行中安全地将驱动器从仅 TPM 模式过渡到 TPM+PIN 模式。
## ⚡ 脚本功能
```
Run Add-BitLockerTPMPin.ps1 (admin)
│
▼
[Version Check] ──→ exits gracefully on Windows 10 (not affected)
│
▼
[BitLocker Status Check] ──→ confirms encryption is active on C:
│
▼
[Group Policy Fix] ──→ sets UseAdvancedStartup + UseTPMPIN + UseEnhancedPin
│ (required — manage-bde rejects TPM+PIN without these)
▼
[gpupdate /force] ──→ applies policy immediately without reboot
│
▼
[manage-bde -protectors -add C: -TPMAndPIN] ──→ prompts for PIN interactively
│
▼
[List Protectors] ──→ shows all current protectors for verification
│
▼
[Remove TPM-only Protector] ──→ optional, prompted with confirmation
```
## 🚀 快速开始
### 前置条件
- Windows 11 (24H2 或更高版本) 或 Windows Server 2022/2025
- C: 盘已启用 BitLocker
- 管理员权限
- 在运行前可访问恢复密钥(将其存储在您的 Microsoft 帐户中或将其打印出来)
### 运行
```
# 在具有管理员权限的 PowerShell 提示符中,将以下内容作为两个独立的命令运行:
Set-ExecutionPolicy Bypass -Scope Process -Force
```
```
# 所有受 BitLocker 保护的驱动器(自动检测):
.\Add-BitLockerTPMPin.ps1
# 或者针对特定驱动器:
.\Add-BitLockerTPMPin.ps1 -Drive C
.\Add-BitLockerTPMPin.ps1 -Drive D
```
系统将以交互方式提示您为每个驱动器设置 PIN 码。支持字母数字 PIN 码(脚本会通过注册表启用增强型 PIN 码)。
## 📖 用法
### 交互式流程
```
BitLocker-protected drives found:
C:\ FullyEncrypted Protection: On
D:\ FullyEncrypted Protection: On
Group Policy keys set. Refreshing policy...
==============================
Drive: C:\
==============================
Adding TPM+PIN protector. You will be prompted for a PIN.
PIN must be 6+ characters. Alphanumeric is supported.
Type the PIN to use to protect the volume:
Confirm the PIN by typing it again:
Key Protectors Added:
TPM And PIN:
ID: {XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX}
Current protectors on C:\:
...
TPM-only protector found: {YYYYYYYY-YYYY-YYYY-YYYY-YYYYYYYYYYYY}
Remove TPM-only protector on C:\? This leaves only TPM+PIN. (y/N): y
TPM-only protector removed.
==============================
Drive: D:\
==============================
D:\ has no TPM protector — TPM+PIN applies to the OS drive only. Skipping.
Done. Verify with: manage-bde -status
© 2026 Andrei Majer
[](https://github.com/andrei-majer) [](https://www.linkedin.com/in/andrei-majer/)
标签:AI合规, BitLocker, IPv6, Libemu, PowerShell, 安全防护, 数据加密, 漏洞缓解