Microsoft IIS Connection String Decryption via aspnet_regiis
An attacker with Microsoft IIS web server access can decrypt and dump hardcoded connection strings, such as MSSQL service account passwords, using the aspnet_regiis utility, potentially leading to credential compromise.
This threat involves the decryption of Microsoft IIS connection strings using the aspnet_regiis utility. An attacker who has gained unauthorized access to an IIS web server, typically through a webshell or similar exploit, can leverage this technique to extract sensitive information. The aspnet_regiis tool, a legitimate .NET utility, is misused to decrypt connection strings, which often contain hardcoded credentials for databases like MSSQL. This allows the attacker to potentially compromise service accounts and gain further access to the compromised network. The described behavior has been observed in relation to espionage campaigns targeting telecommunications in South Asia, as detailed by Symantec. Defenders should be aware that successful exploitation allows for lateral movement and data exfiltration.
Attack Chain
- The attacker gains initial access to a Microsoft IIS web server, often through exploiting a vulnerability that enables webshell deployment.
- The attacker uses the webshell to execute commands on the compromised server.
- The attacker uses
aspnet_regiis.exewith the-pdfor-pdoptions to decrypt theconnectionStringssection of the web.config file. - The command
aspnet_regiis.exe -pdf connectionStrings <application_path>is used to decrypt the connection strings for a specific application. - The attacker retrieves the decrypted connection strings, which may contain usernames, passwords, and connection details for MSSQL or other databases.
- The attacker uses the compromised credentials to access the database server and potentially other systems on the network, achieving lateral movement.
- The attacker may then exfiltrate sensitive data from the database server.
- The attacker uses gathered credentials to perform further actions or maintain persistence.
Impact
Successful exploitation can lead to the exposure of sensitive database credentials, allowing attackers to access and exfiltrate confidential information. This can result in significant data breaches, financial losses, and reputational damage. Depending on the compromised accounts’ privileges, attackers could gain control over critical systems and services. Compromised credentials may allow lateral movement to other systems and applications within the network.
Recommendation
- Deploy the Sigma rule “Detect IIS Connection String Decryption” to your SIEM and tune for your environment to detect the usage of
aspnet_regiis.exewith connection string decryption parameters. - Monitor process creation events for
aspnet_regiis.exewith arguments containingconnectionStrings,-pdf, or-pd(per the detection rule) to identify potential exploitation attempts. - Implement strict access controls on IIS web servers to limit the ability of attackers to execute arbitrary commands.
- Review IIS web server configurations for weak or hardcoded credentials in connection strings and implement secure credential management practices.
- Enable Sysmon process creation logging to capture command line arguments for executed processes and facilitate detection of malicious activity.
Detection coverage 3
Detect IIS Connection String Decryption
highDetects the usage of aspnet_regiis.exe to decrypt IIS connection strings, potentially indicating credential access attempts.
Detect Renamed aspnet_regiis Connection String Decryption
highDetects the usage of a renamed aspnet_regiis.exe to decrypt IIS connection strings.
Detect aspnet_regiis connectionStrings Decryption via command line
highDetects aspnet_regiis with connectionStrings decryption parameters in command line arguments.
Detection queries are kept inside the platform. Get full rules →