T1606.002: SAML Tokens
An adversary may forge SAML tokens with any permissions claims and lifetimes if they possess a valid SAML token-signing certificate. The default lifetime of a SAML token is one hour, but the validity period can be specified in the NotOnOrAfter
value of the conditions ...
element in a token. This value can be changed using the AccessTokenLifetime
in a LifetimeTokenPolicy
. Forged SAML tokens enable adversaries to authenticate across services that use SAML 2.0 as an SSO (single sign-on) mechanism.
An adversary may utilize Private Keys to compromise an organization's token-signing certificate to create forged SAML tokens. If the adversary has sufficient permissions to establish a new federation trust with their own Active Directory Federation Services (AD FS) server, they may instead generate their own trusted token-signing certificate. This differs from Steal Application Access Token and other similar behaviors in that the tokens are new and forged by the adversary, rather than stolen or intercepted from legitimate users.
An adversary may gain administrative Azure AD privileges if a SAML token is forged which claims to represent a highly privileged account. This may lead to Use Alternate Authentication Material, which may bypass multi-factor and other authentication protection mechanisms.
Positive Technologies products that cover the technique
MaxPatrol SIEM knowledge base
Method 1 (AWS, Azure) — Monitoring of successful login events ConsoleLogin (for AWS) or AssumeRoleWithSAML ('sign-in' in Azure AD) when there are no corresponding events 4769 (on DC), 1200 (on ADFS), and 1202 (on ADFS) for the domain. Method 2 — Monitoring of events with ID 1007 (certificate export from the ADFS server, the Microsoft-Windows-CertificateServicesClient-Lifecycle-System log) as the Golden SAML attack requires the ADFS signing certificate and its private key. — Monitoring of events related to PowerShell command execution (IDs 4103 and 4104) where command line input contains 'Export-PfxCertificate' or 'certutil -exportPFX'. — Monitoring of events related to certutil.exe execution where command line input contains 'certutil.exe -exportPFX'. — Monitoring of Sysmon events with ID 18 and PipeName '\Microsoft##wid sql\query'. This is used to detect the ADFSdump tool. When used, processes commonly associated with this pipe should be excluded. An adversary may also obtain admin access to ADFS and add a new trusted ADFS instead of retrieving the certificate and private key. This may allow them to bypass the above detection mechanisms. To detect such an attack, ADFS events should be monitored (Method 3). Method 3 — An event with ID 307 (The Federation Service configuration was changed) is associated with one or several events having ID 510 and the same Instance ID. Event 510 is helpful as it contains all modifications. It is also recommended to check events containing 'Configuration: Type: IssuanceAuthority' where Property Value references an unfamiliar domain.
Expert Required. The technique is detected only with the combination of «PT Product + Expert»
Detection
ID | DS0006 | Data source and component | Web Credential: Web Credential Creation | Description | Monitor for creation of access tokens using SAML tokens which do not have corresponding 4769 and 1200 events in the domain. |
---|
ID | DS0028 | Data source and component | Logon Session: Logon Session Metadata | Description | Consider modifying SAML responses to include custom elements for each service provider. Monitor these custom elements in service provider access logs to detect any anomalous requests. |
---|
ID | DS0006 | Data source and component | Web Credential: Web Credential Usage | Description | Monitor for the use of access tokens to access services such as email that were created using SAML tokens which do not have corresponding 1202 events (i.e. “The Federation Service validated a new credential”) in the domain. |
---|
ID | DS0028 | Data source and component | Logon Session: Logon Session Creation | Description | Monitor for logins using SAML tokens which do not have corresponding 4769 and 1200 events in the domain. These logins may occur on any on-premises resources as well as from any cloud environment that trusts the certificate. |
---|
ID | DS0002 | Data source and component | User Account: User Account Authentication | Description | Monitor for user authentication attempts, when requesting access tokens to services, that failed because of Conditional Access Policies (CAP). Some SAML tokens features, such as the location of a user, may not be as easy to claim. |
---|
ID | DS0009 | Data source and component | Process: Process Creation | Description | This search looks for arguments to certutil.exe indicating the manipulation or extraction of Certificate. This certificate can then be used to sign new authentication tokens specially inside Federated environments such as Windows ADFS. Analytic 1 - Certutil.exe Certificate Extraction
|
---|
Mitigation
ID | M1015 | Name | Active Directory Configuration | Description | For containing the impact of a previously forged SAML token, rotate the token-signing AD FS certificate in rapid succession twice, which will invalidate any tokens generated using the previous certificate. |
---|
ID | M1026 | Name | Privileged Account Management | Description | Restrict permissions and access to the AD FS server to only originate from privileged access workstations. |
---|
ID | M1047 | Name | Audit | Description | Enable advanced auditing on AD FS. Check the success and failure audit options in the AD FS Management snap-in. Enable Audit Application Generated events on the AD FS farm via Group Policy Object. |
---|
ID | M1018 | Name | User Account Management | Description | Ensure that user accounts with administrative rights follow best practices, including use of privileged access workstations, Just in Time/Just Enough Administration (JIT/JEA), and strong authentication. Reduce the number of users that are members of highly privileged Directory Roles. |
---|