Microsoft has issued a warning about an emerging threat involving ViewState code injection attacks. These attacks exploit ASP.NET machine keys, which are meant to protect ViewState data from tampering and unauthorized disclosure. Developers sometimes use machine keys that are publicly available through code documentation or repositories, which attackers can use to craft malicious payloads. When attackers acquire these machine keys, they can inject malicious message authentication codes (MACs) into ViewState data, allowing the ASP.NET runtime to decrypt and execute it on targeted servers.
Once the malicious ViewState data is processed, attackers gain remote code execution (RCE) capabilities on the web server, specifically those running Internet Information Services (IIS).
This opens the door for further exploitation, including the deployment of malicious frameworks such as Godzilla, which offers command execution and shellcode injection capabilities. Microsoft highlighted a specific case from December 2024, where an attacker leveraged a publicly known machine key to compromise a targeted IIS web server.
The company has identified over 3,000 publicly disclosed machine keys that could be used in these attacks. Unlike previously known attacks that used stolen or compromised keys sold on dark web forums, the keys found in public repositories pose a more significant risk. These keys are accessible by anyone and may have been unknowingly integrated into development code, increasing the likelihood of exploitation. The widespread availability of these keys makes them a highly accessible resource for attackers, thus intensifying the threat landscape for organizations that have not properly safeguarded their machine keys.
To mitigate the risk of these attacks, Microsoft recommends several best practices for developers. These include securely generating unique machine keys, avoiding default or publicly disclosed keys, and encrypting key elements to block access to plaintext secrets. Furthermore, upgrading to ASP.NET 4.8 to enable Antimalware Scan Interface (AMSI) capabilities and hardening Windows Servers with attack surface reduction rules can help reduce vulnerability. If a publicly disclosed key is suspected to have been exploited, Microsoft advises comprehensive investigation and, in some cases, reformatting and reinstallation of compromised servers to prevent long-term persistence of threats.