ASP.NET ViewState Remote Code Execution

critical Web App Scanning Plugin ID 113340

Synopsis

ASP.NET ViewState Remote Code Execution

Description

The ViewState is a parameter specific to the ASP.NET framework, it's used as a breadcrumb trail when the user navigates the application preserving values and controls between different web pages. Present on the pages in the __viewstate parameter, all the values are serialized and encoded in base64 in a hidden field. In addition to the base64 encoding, the viewstate can also be signed with a MAC (Message Authentication Code) to guarantee integrity and also encrypted to guarantee confidentiality.

If the viewstate is not signed, depending on the information stored inside, an attacker might be able to modify the information stored inside and therefore possibly achieve a Remote Code Execution.

Solution

ASP.NET provides MAC validation for ViewState parameters by adding '<%@Page EnableViewStateMAC='True' %>' on the specific page or by adding '<pages enableViewStateMac='true'>' inside your web.config file.

See Also

https://cheatsheetseries.owasp.org/cheatsheets/Deserialization_Cheat_Sheet.html

https://devblogs.microsoft.com/aspnet/cryptographic-improvements-in-asp-net-4-5-pt-2/

https://docs.microsoft.com/en-us/dotnet/api/system.web.ui.page.enableviewstatemac?view=netframework-4.8

https://docs.microsoft.com/en-us/previous-versions/dotnet/articles/ms972976(v=msdn.10)

Plugin Details

Severity: Critical

ID: 113340

Type: remote

Published: 9/6/2022

Updated: 9/6/2022

Scan Template: basic, full, pci, scan

Risk Information

VPR

Risk Factor: High

Score: 7.5

CVSS v2

Risk Factor: High

Base Score: 7.6

Vector: CVSS2#AV:N/AC:H/Au:N/C:C/I:C/A:C

CVSS Score Source: Tenable

CVSS v3

Risk Factor: Critical

Base Score: 9

Vector: CVSS:3.0/AV:N/AC:H/PR:N/UI:N/S:C/C:H/I:H/A:H

CVSS Score Source: Tenable

Reference Information