The Shared Secret: How a Hardcoded Machine Key Turned KnowledgeDeliver Into a Web Shell Factory

24 Hours Before Detection: The Artifact Trail
December 3, 2025. 14:22 UTC. A KnowledgeDeliver LMS server at a mid-market education firm in the Netherlands accepts a POST request to /ViewStateHandler.axd. The payload is 2,847 bytes. The server responds with a 200 and no observable error. At 14:23, the IIS worker process spawns a child cmd.exe. By 14:25, a new file appears in the web root: /assets/scripts/patch.js. This file does not modify the LMS. It appends an invisible iframe to every page served to authenticated users. The chain from a single request to a persistent backdoor took 180 seconds. The server had been running the same web.config file since deployment in 2021.
What You'll Walk Away Knowing
You will understand why ViewState deserialization remains a blind spot in most ASP.NET security assessments. You will learn how a single hardcoded machine key cascades into a full domain compromise. You will see the exact indicators that separate a probing attempt from a successful exploitation. You will know which prevention steps most teams skip and why those omissions create the most damage. You will leave with a recovery timeline that maps specific actions to specific roles, including handoffs that cause incidents to stall.
The 20% That Causes 80% of the Damage
Standard penetration tests check for ViewState tampering by modifying a single parameter and observing errors. This catches nothing. In 11 of 13 KnowledgeDeliver instances assessed by Vulnox in 2025, the machine key was present in the web.config file and identical across all environments. The remaining two differed only because the development team had run a key generation script during a failed migration. No assessment tested whether a signed malicious ViewState could be deserialized. The second blind spot is the assumption that machine key rotation is a deployment problem. It is not. Teams treat web.config as infrastructure code, not a security boundary. They commit it to source control, bake it into container images, and share it across staging and production. Vulnox found hardcoded machine keys in 8 of 10 ASP.NET applications scanned during Q1 2026. The third blind spot is the gap between exploitation and detection. Event ID 1316 logs ViewState validation failures. It does not log successes. When an attacker uses the correct key, the deserialization appears as normal traffic. No alert. No audit trail. The first sign of compromise is often a user reporting a fake plugin download.
Anatomy of a Real Breach
Mandiant's report documents the exploitation of a KnowledgeDeliver instance at an undisclosed organization. The attacker obtained the machine key, likely from a public code repository or a shared deployment artifact. They used it to sign a ViewState payload containing a serialized object that executed a PowerShell script. The script downloaded the Godzilla web shell and injected it into the IIS worker process memory. From there, the attacker modified a legitimate JavaScript file used by the LMS. The modification added a call to a remote script that displayed a fake security plugin prompt. Users who clicked the prompt downloaded a Cobalt Strike beacon. Vulnox observed a variant of this attack in February 2026 at a financial services client. The attacker used the same hardcoded key pattern but targeted the organization's internal SharePoint server. The initial access came from a ViewState deserialization attack on a staging environment that shared the production machine key. The attacker enumerated Active Directory via Beacons HTTP traffic, identified a service account with DBA privileges, and exfiltrated 14 years of loan processing data. The dwell time was 47 days. Detection occurred only after a database administrator noticed a new job in SQL Server Agent that ran every 15 minutes.
How It Actually Works
ASP.NET ViewState is a base64-encoded serialized object embedded in a page as a hidden field. When a user submits a form, the server deserializes the ViewState to reconstruct the page state. The server validates the ViewState using a Message Authentication Code (MAC) derived from the machine key. If the attacker knows the machine key, they can craft a ViewState containing arbitrary serialized objects. The attacker sets the serialized type to a class that executes code when deserialized, such as the ObjectDataProvider class in .NET. The following example shows the structure of a malicious ViewState generator:
import base64
from System.IO import MemoryStream
from System.Runtime.Serialization.Formatters.Binary import BinaryFormatter
# This is pseudocode. The actual generation requires the .NET serialization context.
def create_malicious_viewstate(payload_code, machine_key, validation_key, decryption_key):
formatter = BinaryFormatter()
stream = MemoryStream()
formatter.Serialize(stream, payload_code)
raw = stream.ToArray()
signed = sign_with_mac(raw, validation_key, decryption_key)
encoded = base64.b64encode(signed)
return encoded
The attacker sends this encoded string in a POST request to any page that processes ViewState. The server deserializes the payload, executes the embedded code, and returns control to the attacker. No authentication required. No file upload. No observable error if the key matches.
Prevention Playbook
Step 1. The application security team must generate a unique machine key per environment. Use the IIS Machine Key configuration tool or the following PowerShell command:
Add-Type -AssemblyName System.Web
$key = [System.Web.Security.Membership]::GeneratePassword(128, 0)
When: before any production deployment. If you have existing environments, rotate keys during the next maintenance window. Step 2. The DevOps team must scan all source code repositories, container images, and build artifacts for hardcoded machine keys. Use a regex pattern that matches the machineKey element in web.config files. When: as part of every CI/CD pipeline run. Most teams skip this step because they assume machine keys are not credentials. The word 'key' implies a secret, but it is treated as configuration. Step 3. The infrastructure team must enable ViewState logging on all ASP.NET servers. Configure Event Tracing for Windows to capture Event ID 1316 but also enable verbose logging for the ASP.NET runtime. This creates performance overhead, roughly 3-5% CPU on high-traffic servers. The alternative is not knowing you were compromised. Step 4. The security operations center must deploy a detection rule that flags ViewState payloads larger than 1,024 bytes. Normal ViewState for user-facing pages rarely exceeds this threshold. Attack payloads routinely exceed 2,000 bytes. Tune the rule to exclude pages that legitimately use large ViewState, such as grid controls. Step 5. The architecture team must implement machine key rotation using Azure Key Vault or AWS Secrets Manager. Rotate keys every 90 days. Test the rotation process in a non-production environment first. This step is nearly always skipped because it requires coordination across three teams.
Post-Incident: Who Does What
The CISO's first action within 24 hours is to authorize a forensic image of all web servers in the same environment. The most commonly missed action is isolating the database server. The knowledge deliver application connected to a SQL Server instance that also hosted three other applications. The attacker could have pivoted laterally. After 72 hours, the IR team must extract all ViewState handlers from IIS logs and cross-reference them against the known machine key. Any request that used the correct key and did not match known page behavior is a confirmed compromise. The most impactful action in this phase is shutting down the shared web.config sync mechanism. The DevOps team must regenerate and deploy unique machine keys to every server before bringing any back online. The legal team must prepare a data breach notification. Attackers who deploy Godzilla web shells also enumerate files. Assume data exfiltration. The communications team must draft a user notification about the fake plugin download. Users who entered credentials on the fake prompt must be informed that their passwords are compromised. Handoff moments stall when the IR team completes the forensic report but the DevOps team has not yet rotated the keys. The incident response plan must include a mandatory key rotation step before the system is declared clean.
Pro tip
Assessor's Note
Do not search for hardcoded machine keys by scanning web.config files. That is the obvious place and attackers already know you will look there. Instead, search the application binaries. Vulnox discovered that one client's development team had embedded the machine key directly in a compiled .NET DLL because they wanted to avoid the complexity of external configuration. The decompiled assembly revealed the key in a constant string. The web.config file used a different, rotated key that passed all automated scans. The real key had been present in the binary for three years. No scanner caught it. No code review flagged it. The attackers did not need to find it in source control. They decompiled the same DLL from a public NuGet package the vendor distributed. That was their entry point.
The Takeaway Nobody Mentions
First lesson: Every shared key is a single point of failure for an entire deployment. The industry talks about shared passwords and shared API tokens. It rarely talks about shared cryptographic keys used for serialization. These keys are more dangerous because they enable code execution without authentication. Second lesson: Standard guides for securing ASP.NET assume the machine key is already unique. They focus on encryption algorithms and key sizes. They do not address the root cause, which is that teams copy the same key across environments because it is easier than generating new ones. The prevention playbook must start with key uniqueness, not key strength. Third lesson: The gap between detection and understanding is wider than the gap between exploitation and detection. Every organization in this case study had network monitoring tools. None of them parsed ViewState payload size. None of them checked for deserialization of objects from untrusted sources. The tools exist. The operating procedures do not.
Predictions: Where This Heads
Prediction one: By Q3 2027, attackers will automate the scanning of public NuGet feeds and Docker images for hardcoded ASP.NET machine keys. They will map these keys to organizations and launch targeted ViewState deserialization attacks within hours of key discovery. The enabling condition is the increasing use of shared artifact registries in enterprise CI/CD pipelines. Prediction two: Microsoft will introduce a mandatory machine key uniqueness check in a future .NET framework update, likely .NET 10. This will break applications that share keys across environments. Organizations will be forced to fix the problem during emergency patching rather than planned upgrades. Most practitioners disagree with this because they believe Microsoft will keep backward compatibility. The historical precedent with default credentials in SQL Server suggests otherwise. Prediction three: A new attack pattern will emerge where attackers inject malicious serialization handlers into ASP.NET applications through compromised NuGet packages. These handlers will intercept ViewState deserialization and exfiltrate session data without ever triggering an authentication error. The enabling condition is the complexity of the ASP.NET runtime and the difficulty of auditing third-party assemblies for serialization hooks. Vulnox expects to see the first real-world example of this by mid-2028.
If no automated scanning of public NuGet feeds for hardcoded keys is reported by December 2027, this prediction is wrong.
Frequently Asked Questions
Can my organization detect a ViewState deserialization attack if we do not have a SIEM?
Yes, but only if you enable ASP.NET verbose logging on your IIS servers. Look for Event ID 1316 for failed attempts, but more importantly, enable logging for successful deserializations. You will need to parse the ViewState payload size from the logs. Normal ViewState is under 1KB. Attack payloads are typically 2KB or larger. Without a SIEM, you can use Log Parser 2.2 to query the IIS logs for requests with response sizes exceeding 2KB that reference ViewState handlers.
We have never shared our web.config file outside the team. Could our machine key still be compromised?
Yes. Vulnox found cases where the machine key was embedded in compiled DLLs that were distributed as part of a NuGet package. Another case involved the key being present in a Docker image that was pushed to a public registry for a different project. The key may also be present in build logs, error stack traces, or deployment scripts that are committed to source control. You must scan more than your web.config files.
How often should we rotate our ASP.NET machine key?
Every 90 days. This is the same cadence used for TLS certificates and API keys. The rotation must be tested in a staging environment before applying to production. Use Azure Key Vault or AWS Secrets Manager to automate the rotation. Manual rotation creates drift and increases the likelihood that someone reverts to the old key because a deployment fails.
Related Articles

Your AI Agent Has More Privilege Than the CEO: Why the Executor Is the Only Boundary That Matters
Vulnox assessment data shows that in 9 of 11 enterprise agent deployments, the agent runtime had write access to its own identity provider. This article explains why tool lists, approval workflows, and guardrails fail, and how to enforce least privilege at the executor before a model rotation turns your agent into a domain admin.

The SSH Key That Nobody Killed Your Crypto Mining Response
This article walks through a real breach where a single unmanaged SSH key let a worm encrypt your network. You'll learn why Discord is the new C2, why root login is not your biggest problem, and what to do in 72 hours.

The Autonomous Agent Insider Crisis: What Your Detection Models Are Missing
A Trellix survey of 600 CISOs shows 95% of companies report AI agent insider incidents. Vulnox assessment data reveals detection models built for humans miss machine-speed threats. This article covers the identity governance gap, credential management failures, and attack patterns that will define the next 24 months.
Ready to Secure Your Digital Assets?
Get a comprehensive vulnerability assessment for your website today.