Credential Access via Windows Credential Manager PowerShell Scripts
Adversaries leverage PowerShell scripts to programmatically access and extract stored credentials from the Windows Credential Manager vault.
Adversaries frequently target the Windows Credential Manager to perform credential access, as this utility stores sensitive user passwords, service account credentials, and web application secrets. Attackers utilize PowerShell scripts to interface with the Windows.Security.Credentials.PasswordVault API or dynamically compile code to bypass standard monitoring. By invoking these methods, unauthorized actors can enumerate and decrypt secrets stored within the vault. This activity is a common post-exploitation technique used to facilitate lateral movement or privilege escalation within an environment. Defenders must monitor PowerShell Script Block Logging (Event ID 4104) to identify the execution of these specific API calls and helper classes used by offensive tools to dump credentials.
Attack Chain
- Attacker gains initial access or code execution on the target Windows system.
- Attacker prepares a PowerShell script intended to interact with the Windows Credential Manager.
- Script uses New-Object to instantiate the Windows.Security.Credentials.PasswordVault class.
- Script may utilize Microsoft.CSharp.CSharpCodeProvider to compile arbitrary code in memory to interact with system APIs.
- Script invokes methods like Get-PasswordVaultCredentials or Get-CredManCreds to retrieve stored data.
- The retrieved credentials are serialized or stored in an ArrayList within the script.
- Attacker exfiltrates the dumped credentials from the compromised host to attacker-controlled infrastructure.
Impact
Successful exploitation allows an attacker to obtain cleartext credentials or cached tokens for local and domain users, enabling unauthorized access to internal resources, sensitive applications, and increased privileges within the target organization.
Recommendation
Deploy the following Sigma rule to detect credential dumping attempts via PowerShell. Ensure PowerShell Script Block Logging is enabled on all endpoints.
- Enable Windows Event ID 4104 (PowerShell Script Block Logging) via Group Policy.
- Monitor for the execution of scripts containing 'Windows.Security.Credentials.PasswordVault' or associated compiler classes.
- Tune alerts to ignore approved administrative maintenance scripts that legitimately interact with the system vault.
Immediate actions
Deploy the Sigma detection rule to the SIEM.
Threat Hunt
Search for 4104 logs containing PasswordVault or CSharpCodeProvider strings.
Data: PowerShell script block logs
Detection coverage 1
Detect Credential Dumping from Windows Credential Manager via PowerShell
mediumDetects the use of PowerShell to access the Windows Credential Manager, typically used by attackers to dump stored credentials.
Detection queries are available on the platform. Get full rules →