Detection rules › Sublime MQL
Suspicious Office 365 app authorization (OAuth) link
Message contains a suspicious Office 365 app authorization (OAuth) link. The app may be compromised or was stood up for malicious purposes. Once the app has been authorized, the attacker will have read or write permissions to the user's Office 365 account.
Threat classification
Sublime's own taxonomy (not MITRE ATT&CK).
| Category | Values |
|---|---|
| Attack types | Credential Phishing |
Event coverage
| Message attribute |
|---|
| attachments (collection) |
| body |
| body.current_thread |
| type |
Rule body MQL
type.inbound
and (
// links in email body
any([body.links, body.current_thread.links],
any(.,
.href_url.domain.domain == 'login.microsoftonline.com'
and (
strings.ilike(.href_url.query_params,
'*offline_access*',
'*.readwrite*',
'*.read*',
'*ctx=*',
'*prompt=none*'
)
or (
strings.icontains(.href_url.path, '/common/reprocess')
and strings.icontains(.href_url.query_params, 'ctx=')
and strings.icontains(.href_url.query_params, 'sessionId=')
)
)
)
)
// links in PDF, HTML, DOCX and PPTX attachments
or any(filter(attachments, .file_type in ("pdf", "html", "docx", "pptx")),
any(file.explode(.),
any(.scan.url.urls,
.domain.domain == 'login.microsoftonline.com'
and (
strings.ilike(.query_params,
'*offline_access*',
'*.readwrite*',
'*.read*',
'*ctx=*',
'*prompt=none*'
)
or (
strings.icontains(.path, '/common/reprocess')
and strings.icontains(.query_params, 'ctx=')
and strings.icontains(.query_params, 'sessionId=')
)
)
)
)
)
or any(attachments,
(
.file_type == "ics"
or .file_extension == "ics"
or .content_type in ("application/ics", "text/calendar")
)
//
// This rule makes use of a beta feature and is subject to change without notice
// using the beta feature in custom rules is not suggested until it has been formally released
//
and any(beta.file.parse_ics(.).events,
any(.links,
.href_url.domain.domain == 'login.microsoftonline.com'
and (
strings.ilike(.href_url.query_params,
'*offline_access*',
'*.readwrite*',
'*.read*',
'*ctx=*',
'*prompt=none*'
)
or (
strings.icontains(.href_url.path, '/common/reprocess')
and strings.icontains(.href_url.query_params, 'ctx=')
and strings.icontains(.href_url.query_params,
'sessionId='
)
)
)
)
)
)
)
Detection logic
Scope: inbound message.
Message contains a suspicious Office 365 app authorization (OAuth) link. The app may be compromised or was stood up for malicious purposes. Once the app has been authorized, the attacker will have read or write permissions to the user's Office 365 account.
- inbound message
any of:
any of
[body.links, body.current_thread.links]where:any of
.where all hold:- .href_url.domain.domain is 'login.microsoftonline.com'
any of:
.href_url.query_params matches any of 5 patterns
*offline_access**.readwrite**.read**ctx=**prompt=none*
all of:
- .href_url.path contains '/common/reprocess'
- .href_url.query_params contains 'ctx='
- .href_url.query_params contains 'sessionId='
any of
filter(attachments)where:any of
file.explode(.)where:any of
.scan.url.urlswhere all hold:- .domain.domain is 'login.microsoftonline.com'
any of:
.query_params matches any of 5 patterns
*offline_access**.readwrite**.read**ctx=**prompt=none*
all of:
- .path contains '/common/reprocess'
- .query_params contains 'ctx='
- .query_params contains 'sessionId='
any of
attachmentswhere all hold:any of:
- .file_type is 'ics'
- .file_extension is 'ics'
- .content_type in ('application/ics', 'text/calendar')
any of
beta.file.parse_ics(.).eventswhere:any of
.linkswhere all hold:- .href_url.domain.domain is 'login.microsoftonline.com'
any of:
.href_url.query_params matches any of 5 patterns
*offline_access**.readwrite**.read**ctx=**prompt=none*
all of:
- .href_url.path contains '/common/reprocess'
- .href_url.query_params contains 'ctx='
- .href_url.query_params contains 'sessionId='
Inspects: attachments[].content_type, attachments[].file_extension, attachments[].file_type, body.current_thread.links, body.links, type.inbound. Sensors: beta.file.parse_ics, file.explode, strings.icontains, strings.ilike.
Indicators matched (19)
| Field | Match | Value |
|---|---|---|
[body.links, body.current_thread.links][][].href_url.domain.domain | equals | login.microsoftonline.com |
strings.ilike | substring | *offline_access* |
strings.ilike | substring | *.readwrite* |
strings.ilike | substring | *.read* |
strings.ilike | substring | *ctx=* |
strings.ilike | substring | *prompt=none* |
strings.icontains | substring | /common/reprocess |
strings.icontains | substring | ctx= |
strings.icontains | substring | sessionId= |
attachments[].file_type | member | pdf |
attachments[].file_type | member | html |
attachments[].file_type | member | docx |
7 more
attachments[].file_type | member | pptx |
file.explode(filter(attachments)[])[].scan.url.urls[].domain.domain | equals | login.microsoftonline.com |
attachments[].file_type | equals | ics |
attachments[].file_extension | equals | ics |
attachments[].content_type | member | application/ics |
attachments[].content_type | member | text/calendar |
beta.file.parse_ics(attachments[]).events[].links[].href_url.domain.domain | equals | login.microsoftonline.com |