ViewState Tampering
ViewState tampering attacks occur when an attacker modifies the ViewState of an ASP.NET application to exploit the server-side logic of the web application. ViewState, a method for preserving page and control values between postbacks, can be a vector for attack if not properly secured.
In ASP.NET, ViewState is used to maintain the state of a web page across postbacks. It's stored in a hidden field and sent back and forth between the client and server. ViewState is Base64-encoded and, optionally, can be encrypted and validated for tampering. If ViewState is not encrypted or lacks proper validation (MAC - Message Authentication Code (MAC)|Message Authentication Code), it can be read and modified by anyone who can intercept the HTTP request.
An attacker intercepts the HTTP request and decodes the Base64-encoded ViewState. Suppose the ViewState contains information like user roles or access levels, which are not encrypted or validated for integrity. The attacker modifies the ViewState to elevate their privileges. For example, they could change a value that represents their user role from "user" to "admin".
The attacker then re-encodes the modified ViewState and sends it back to the server as part of a POST request. If the server does not properly validate the ViewState, it accepts the tampered data. The attacker might gain unauthorized access to functionalities or data intended only for higher privilege users, like an admin.