-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Adding Azure EntraID rules #1463
base: develop
Are you sure you want to change the base?
Changes from all commits
a97eb8a
b207506
a9dffa1
4d4826b
89cb8d0
7c11db5
550a261
007868b
5f66fc1
f7e7cb0
a520480
e948327
191c58c
ac2c56f
a189443
5379376
2da2ce6
cac72b4
b34e2df
41f2eea
09ca481
d7066b6
08e1839
3fc314f
2c47bf1
24db394
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
from panther_msft_helpers import azure_rule_context, azure_success | ||
|
||
|
||
def rule(event): | ||
if not azure_success(event) or event.get("operationName") != "Invite external user": | ||
return False | ||
|
||
user_who_sent_invite = event.deep_get( | ||
"properties", "initiatedBy", "user", "userPrincipalName", default="" | ||
) | ||
user_who_received_invite = event.deep_walk( | ||
"properties", "additionalDetails", "value", return_val="last", default="" | ||
) | ||
domain = user_who_sent_invite.split("@")[-1] | ||
|
||
different_domain = not user_who_received_invite.endswith(domain) | ||
|
||
return different_domain | ||
|
||
|
||
def title(event): | ||
user_who_sent_invite = event.deep_get( | ||
"properties", "initiatedBy", "user", "userPrincipalName", default="" | ||
) | ||
user_who_received_invite = event.deep_walk( | ||
"properties", "additionalDetails", "value", return_val="last", default="" | ||
) | ||
|
||
return ( | ||
f"{user_who_sent_invite} invited {user_who_received_invite} to join as an EntraID member." | ||
) | ||
|
||
|
||
def alert_context(event): | ||
return azure_rule_context(event) |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,294 @@ | ||||||
AnalysisType: rule | ||||||
Filename: azure_invite_external_users.py | ||||||
RuleID: "Azure.Audit.InviteExternalUsers" | ||||||
DisplayName: "Azure Invite External Users" | ||||||
Enabled: true | ||||||
LogTypes: | ||||||
- Azure.Audit | ||||||
Severity: Low | ||||||
Description: > | ||||||
This detection looks for a Azure users inviting external users | ||||||
Reports: | ||||||
MITRE ATT&CK: | ||||||
- TA0001:T1078 | ||||||
Runbook: > | ||||||
Verify the user permissions and investigate the external user details. If unauthorized, revoke access and block further invites. Update security policies. | ||||||
|
||||||
Reference: https://learn.microsoft.com/en-us/entra/identity/authentication/overview-authentication | ||||||
SummaryAttributes: | ||||||
- properties:ServicePrincipalName | ||||||
- properties:UserPrincipalName | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. You don't need this, since we already have the |
||||||
- properties:ipAddress | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
Tests: | ||||||
- Name: Successful Invite external user | ||||||
ExpectedResult: true | ||||||
Log: | ||||||
{ | ||||||
"callerIpAddress": "1.1.1.1", | ||||||
"category": "AuditLogs", | ||||||
"correlationId": "123456789", | ||||||
"durationMs": 0, | ||||||
"Level": 4, | ||||||
"operationName": "Invite external user", | ||||||
"operationVersion": "1.0", | ||||||
"properties": { | ||||||
"activityDateTime": "2024-09-23 14:33:09.049661100", | ||||||
"activityDisplayName": "Invite external user", | ||||||
"additionalDetails": [ | ||||||
{ | ||||||
"key": "oid", | ||||||
"value": "123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "tid", | ||||||
"value": "0123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "ipaddr", | ||||||
"value": "1.2.3.4" | ||||||
}, | ||||||
{ | ||||||
"key": "wids", | ||||||
"value": "123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "InvitationId", | ||||||
"value": "123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "invitedUserEmailAddress", | ||||||
"value": "[email protected]" | ||||||
} | ||||||
], | ||||||
"category": "UserManagement", | ||||||
"correlationId": "123456789", | ||||||
"id": "Invited Users_123456789", | ||||||
"initiatedBy": { | ||||||
"user": { | ||||||
"id": "123456789", | ||||||
"ipAddress": "1.2.3.4.5", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"roles": [], | ||||||
"userPrincipalName": "[email protected]" | ||||||
} | ||||||
}, | ||||||
"loggedByService": "Invited Users", | ||||||
"operationType": "Add", | ||||||
"result": "success", | ||||||
"targetResources": [ | ||||||
{ | ||||||
"administrativeUnits": [], | ||||||
"displayName": "Zeus.Theboss", | ||||||
"id": "123456789", | ||||||
"type": "User" | ||||||
} | ||||||
] | ||||||
}, | ||||||
"resourceId": "/tenants/123456789/providers/Microsoft.aadiam", | ||||||
"resultSignature": "None", | ||||||
"tenantId": "123456789", | ||||||
"time": "2024-12-10 14:33:09.049661100" | ||||||
} | ||||||
- Name: Same org successful invite | ||||||
ExpectedResult: false | ||||||
Log: | ||||||
{ | ||||||
"callerIpAddress": "1.1.1.1", | ||||||
"category": "AuditLogs", | ||||||
"correlationId": "123456789", | ||||||
"durationMs": 0, | ||||||
"Level": 4, | ||||||
"operationName": "Invite external user", | ||||||
"operationVersion": "1.0", | ||||||
"properties": { | ||||||
"activityDateTime": "2024-09-23 14:33:09.049661100", | ||||||
"activityDisplayName": "Invite external user", | ||||||
"additionalDetails": [ | ||||||
{ | ||||||
"key": "oid", | ||||||
"value": "123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "tid", | ||||||
"value": "0123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "ipaddr", | ||||||
"value": "1.2.3.4" | ||||||
}, | ||||||
{ | ||||||
"key": "wids", | ||||||
"value": "123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "InvitationId", | ||||||
"value": "123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "invitedUserEmailAddress", | ||||||
"value": "[email protected]" | ||||||
} | ||||||
], | ||||||
"category": "UserManagement", | ||||||
"correlationId": "123456789", | ||||||
"id": "Invited Users_123456789", | ||||||
"initiatedBy": { | ||||||
"user": { | ||||||
"id": "123456789", | ||||||
"ipAddress": "1.2.3.4.5", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"roles": [], | ||||||
"userPrincipalName": "[email protected]" | ||||||
} | ||||||
}, | ||||||
"loggedByService": "Invited Users", | ||||||
"operationType": "Add", | ||||||
"result": "success", | ||||||
"targetResources": [ | ||||||
{ | ||||||
"administrativeUnits": [], | ||||||
"displayName": "Zeus.Theboss", | ||||||
"id": "123456789", | ||||||
"type": "User" | ||||||
} | ||||||
] | ||||||
}, | ||||||
"resourceId": "/tenants/123456789/providers/Microsoft.aadiam", | ||||||
"resultSignature": "None", | ||||||
"tenantId": "123456789", | ||||||
"time": "2024-12-10 14:33:09.049661100" | ||||||
} | ||||||
- Name: Unsuccessful invite | ||||||
ExpectedResult: false | ||||||
Log: | ||||||
{ | ||||||
"callerIpAddress": "1.1.1.1", | ||||||
"category": "AuditLogs", | ||||||
"correlationId": "123456789", | ||||||
"durationMs": 0, | ||||||
"Level": 4, | ||||||
"operationName": "Invite external user", | ||||||
"operationVersion": "1.0", | ||||||
"properties": { | ||||||
"activityDateTime": "2024-09-23 14:33:09.049661100", | ||||||
"activityDisplayName": "Invite external user", | ||||||
"additionalDetails": [ | ||||||
{ | ||||||
"key": "oid", | ||||||
"value": "123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "tid", | ||||||
"value": "0123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "ipaddr", | ||||||
"value": "1.2.3.4" | ||||||
}, | ||||||
{ | ||||||
"key": "wids", | ||||||
"value": "123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "InvitationId", | ||||||
"value": "123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "invitedUserEmailAddress", | ||||||
"value": "[email protected]" | ||||||
} | ||||||
], | ||||||
"category": "UserManagement", | ||||||
"correlationId": "123456789", | ||||||
"id": "Invited Users_123456789", | ||||||
"initiatedBy": { | ||||||
"user": { | ||||||
"id": "123456789", | ||||||
"ipAddress": "1.2.3.4.5", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"roles": [], | ||||||
"userPrincipalName": "[email protected]" | ||||||
} | ||||||
}, | ||||||
"loggedByService": "Invited Users", | ||||||
"operationType": "Add", | ||||||
"result": "failed", | ||||||
"targetResources": [ | ||||||
{ | ||||||
"administrativeUnits": [], | ||||||
"displayName": "Zeus.Theboss", | ||||||
"id": "123456789", | ||||||
"type": "User" | ||||||
} | ||||||
] | ||||||
}, | ||||||
"resourceId": "/tenants/123456789/providers/Microsoft.aadiam", | ||||||
"resultSignature": "None", | ||||||
"tenantId": "123456789", | ||||||
"time": "2024-12-10 14:33:09.049661100" | ||||||
} | ||||||
- Name: Not external invite | ||||||
ExpectedResult: false | ||||||
Log: | ||||||
{ | ||||||
"callerIpAddress": "1.1.1.1", | ||||||
"category": "AuditLogs", | ||||||
"correlationId": "123456789", | ||||||
"durationMs": 0, | ||||||
"Level": 4, | ||||||
"operationName": "Invite Internal User", | ||||||
"operationVersion": "1.0", | ||||||
"properties": { | ||||||
"activityDateTime": "2024-09-23 14:33:09.049661100", | ||||||
"activityDisplayName": "Invite external user", | ||||||
"additionalDetails": [ | ||||||
{ | ||||||
"key": "oid", | ||||||
"value": "123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "tid", | ||||||
"value": "0123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "ipaddr", | ||||||
"value": "1.2.3.4" | ||||||
}, | ||||||
{ | ||||||
"key": "wids", | ||||||
"value": "123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "InvitationId", | ||||||
"value": "123456789" | ||||||
}, | ||||||
{ | ||||||
"key": "invitedUserEmailAddress", | ||||||
"value": "[email protected]" | ||||||
} | ||||||
], | ||||||
"category": "UserManagement", | ||||||
"correlationId": "123456789", | ||||||
"id": "Invited Users_123456789", | ||||||
"initiatedBy": { | ||||||
"user": { | ||||||
"id": "123456789", | ||||||
"ipAddress": "1.2.3.4.5", | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
|
||||||
"roles": [], | ||||||
"userPrincipalName": "[email protected]" | ||||||
} | ||||||
}, | ||||||
"loggedByService": "Invited Users", | ||||||
"operationType": "Add", | ||||||
"result": "success", | ||||||
"targetResources": [ | ||||||
{ | ||||||
"administrativeUnits": [], | ||||||
"displayName": "Zeus.Theboss", | ||||||
"id": "123456789", | ||||||
"type": "User" | ||||||
} | ||||||
] | ||||||
}, | ||||||
"resourceId": "/tenants/123456789/providers/Microsoft.aadiam", | ||||||
"resultSignature": "None", | ||||||
"tenantId": "123456789", | ||||||
"time": "2024-12-10 14:33:09.049661100" | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove this entirely; the field isn't present in any of your sample logs, so it will always be
null
and not useful