LoFP LoFP / oauth applications that require mail permissions may be legitimate, investigate and filter as needed.

Techniques

Sample rules

Description

The following analytic identifies instances where a user has actively denied consent to an OAuth application seeking permissions within the Office 365 environment. This suggests that the user either recognized something suspicious about the application or chose not to grant it the requested permissions for other reasons. This detection leverages the O365 audit logs, specifically focusing on events related to user consent actions. By filtering for denied consent actions associated with OAuth applications, the analytic captures instances where users have actively rejected permission requests. While user-denied consents can be routine, they can also be indicative of users spotting potentially suspicious or unfamiliar applications. By monitoring these denied consent attempts, security teams can gain insights into applications that might be perceived as risky or untrusted by users. It can also serve as a feedback loop for security awareness training, indicating that users are being cautious about granting permissions. If the detection is a true positive, it indicates that a user has actively prevented an OAuth application from gaining the permissions it requested. While this is a proactive security measure on the user’s part, it’s essential for security teams to review the context of the denial. Understanding why certain applications are being denied can help in refining application whitelisting policies and ensuring that no malicious applications are attempting to gain access.

Detection logic

 `o365_graph` status.errorCode=65004 
| rename userPrincipalName as user 
| rename ipAddress as src_ip 
| stats max(_time) as lastTime by user src_ip appDisplayName status.failureReason 
| `security_content_ctime(lastTime)` 
| `o365_user_consent_denied_for_oauth_application_filter`

Description

The following analytic identifies instances where a user grants consent to an application that requests mail related permissions within the Office 365 environment. This could involve permissions to read, send, or manage mail settings. It leverages the O365 audit logs, specifically events related to application permissions and user consent actions. By filtering for mail-related permissions and user-granted consents, the analytic pinpoints potential security concerns. While many legitimate applications request mail permissions for valid reasons, malicious actors can exploit these permissions for data exfiltration, spear phishing, or other malicious activities. By monitoring for user-granted mail permissions, security teams can identify and review potentially risky consents, ensuring that only trusted applications have access to sensitive email data. If the detection is a true positive, it indicates that an application now has access to the users mail data as permitted. In the hands of a malicious actor, this could lead to unauthorized data access, email forwarding, or even the sending of malicious emails from the compromised account. Its crucial to validate the legitimacy of the application and the context of the consent to prevent potential data breaches or further malicious activities.

Detection logic

`o365_management_activity` Workload=AzureActiveDirectory Operation="Consent to application." ResultStatus=Success 
| eval admin_consent =mvindex('ModifiedProperties{}.NewValue', 0) 
| search admin_consent=False 
| eval permissions =mvindex('ModifiedProperties{}.NewValue', 4) 
| rex field=permissions "Scope: (?<Scope>[^,]+)" 
| makemv delim=" " Scope 
| search Scope IN ("Mail.Read", "Mail.ReadBasic", "Mail.ReadWrite", "Mail.Read.Shared", "Mail.ReadWrite.Shared", "Mail.Send", "Mail.Send.Shared") 
| stats max(_time) as lastTime values(Scope) by Operation, user, object, ObjectId 
| `security_content_ctime(lastTime)` 
| `o365_mail_permissioned_application_consent_granted_by_user_filter`