How to fix: ASP.NET ViewState Without MAC Protection
An ASP.NET ViewState field was found without a corresponding __VIEWSTATEMAC field in the page markup, or with enableViewStateMac explicitly disabled. This check reads the rendered HTML only: a sibling __VIEWSTATEMAC field is one way ASP.NET represents a MAC, but some versions/configurations embed the MAC inside __VIEWSTATE itself instead, which cannot be confirmed without decoding the ViewState payload. Treat the no-sibling-field case as needing manual verification rather than a confirmed vulnerability; an explicit enableViewStateMac="false" in the markup is a confirmed misconfiguration.
Why it matters
Forged ViewState enables deserialization attacks against ASP.NET's ObjectStateFormatter. An attacker who knows the machineKey (or when no MAC is required) can craft a ViewState payload that executes arbitrary .NET code on the server.
ASP.NET's ViewState stores page state between requests. The MAC (Message Authentication Code) prevents tampering. Without it, an attacker can inject malicious serialized objects into the ViewState, exploiting .NET deserialization gadget chains.
How to fix it
- 1Never set EnableViewStateMac=false or ViewStateEncryptionMode=Never.
- 2Ensure <machineKey> is configured with a strong random validationKey.
- 3Consider enabling ViewState encryption: ViewStateEncryptionMode='Always'.
- 4Upgrade to .NET 4.5.2+ which enforces ViewState MAC by default.
Code examples
Web.config ViewState protection
<configuration>
<system.web>
<!-- Always require MAC validation -->
<pages enableViewStateMac="true" viewStateEncryptionMode="Always" />
<machineKey
validationKey="[strong-random-key]"
decryptionKey="[strong-random-key]"
validation="HMACSHA256"
decryption="AES" />
</system.web>
</configuration>References
Detected automatically by VulnRadar. The check id is aspnet-viewstate-no-mac, stable across every scan so you can filter or diff on it.
More host validation checks
- HighHost Header Injection Risk
- MediumSymfony Debug Token Header Exposed
- HighHTTP Request Smuggling Indicator
- HighHTTP Basic Authentication Over Non-HTTPS
- HighCache Poisoning via Unkeyed Headers
- LowSequential Numeric ID in URL (IDOR Risk)
- HighConfirmed Open Redirect via Location Header
- HighConfirmed Open Redirect via Meta Refresh
Questions
- How severe is ASP.NET ViewState Without MAC Protection?
- VulnRadar rates this medium severity in the host validation category. The severity is fixed per check, not scored per site, so the same finding is the same severity on every scan.
- Does VulnRadar check for this automatically?
- Yes. It runs as part of every scan under the check id aspnet-viewstate-no-mac, which stays the same between runs so you can filter, diff, or gate CI on it.
- Which standards does ASP.NET ViewState Without MAC Protection map to?
- It maps to CWE-345. In the OWASP Top 10 it falls under A08:2021.
Missing a check?
The detection set is open. If you know a misconfiguration this does not catch, propose it: the issue template asks for the threat model, how to detect it, the false-positive risk, and a test fixture, which is the same thing a maintainer would have to work out anyway.