-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(entra): add new check `entra_thirdparty_integrated_apps_not_allo…
…wed` (#6357) Co-authored-by: MrCloudSec <hello@mistercloudsec.com>
- Loading branch information
1 parent
914012d
commit bce958b
Showing
8 changed files
with
227 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
...r_settings_password_never_expire/admincenter_settings_password_never_expire.metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
30 changes: 30 additions & 0 deletions
30
...ty_integrated_apps_not_allowed/entra_thirdparty_integrated_apps_not_allowed.metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"Provider": "microsoft365", | ||
"CheckID": "entra_thirdparty_integrated_apps_not_allowed", | ||
"CheckTitle": "Ensure third party integrated applications are not allowed", | ||
"CheckType": [], | ||
"ServiceName": "entra", | ||
"SubServiceName": "", | ||
"ResourceIdTemplate": "", | ||
"Severity": "high", | ||
"ResourceType": "", | ||
"Description": "Require administrators or appropriately delegated users to register third-party applications.", | ||
"Risk": "It is recommended to only allow an administrator to register custom-developed applications. This ensures that the application undergoes a formal security review and approval process prior to exposing Azure Active Directory data. Certain users like developers or other high-request users may also be delegated permissions to prevent them from waiting on an administrative user. Your organization should review your policies and decide your needs.", | ||
"RelatedUrl": "https://learn.microsoft.com/en-us/entra/identity-platform/how-applications-are-added#who-has-permission-to-add-applications-to-my-microsoft-entra-instance", | ||
"Remediation": { | ||
"Code": { | ||
"CLI": "", | ||
"NativeIaC": "", | ||
"Other": "", | ||
"Terraform": "" | ||
}, | ||
"Recommendation": { | ||
"Text": "1. From Entra select the Portal Menu 2. Select Azure Active Directory 3. Select Users 4. Select User settings 5. Ensure that Users can register applications is set to No", | ||
"Url": "https://learn.microsoft.com/en-us/entra/identity/role-based-access-control/delegate-app-roles#restrict-who-can-create-applications" | ||
} | ||
}, | ||
"Categories": [], | ||
"DependsOn": [], | ||
"RelatedTo": [], | ||
"Notes": "Enforcing this setting will create additional requests for approval that will need to be addressed by an administrator. If permissions are delegated, a user may approve a malevolent third party application, potentially giving it access to your data." | ||
} |
26 changes: 26 additions & 0 deletions
26
...ra_thirdparty_integrated_apps_not_allowed/entra_thirdparty_integrated_apps_not_allowed.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
from prowler.lib.check.models import Check, Check_Report_Microsoft365 | ||
from prowler.providers.microsoft365.services.entra.entra_client import entra_client | ||
|
||
|
||
class entra_thirdparty_integrated_apps_not_allowed(Check): | ||
def execute(self) -> Check_Report_Microsoft365: | ||
findings = [] | ||
|
||
auth_policy = entra_client.authorization_policy | ||
report = Check_Report_Microsoft365(self.metadata(), auth_policy) | ||
report.resource_name = getattr(auth_policy, "name", "Authorization Policy") | ||
report.resource_id = getattr(auth_policy, "id", "authorizationPolicy") | ||
report.status = "FAIL" | ||
report.status_extended = "App creation is not disabled for non-admin users." | ||
|
||
if getattr(auth_policy, "default_user_role_permissions", None) and not getattr( | ||
auth_policy.default_user_role_permissions, | ||
"allowed_to_create_apps", | ||
True, | ||
): | ||
report.status = "PASS" | ||
report.status_extended = "App creation is disabled for non-admin users." | ||
|
||
findings.append(report) | ||
|
||
return findings |
127 changes: 127 additions & 0 deletions
127
...irdparty_integrated_apps_not_allowed/entra_thirdparty_integrated_apps_not_allowed_test.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,127 @@ | ||
from unittest import mock | ||
from uuid import uuid4 | ||
|
||
from prowler.providers.microsoft365.services.entra.entra_service import ( | ||
DefaultUserRolePermissions, | ||
) | ||
from tests.providers.microsoft365.microsoft365_fixtures import ( | ||
DOMAIN, | ||
set_mocked_microsoft365_provider, | ||
) | ||
|
||
|
||
class Test_entra_thirdparty_integrated_apps_not_allowed: | ||
def test_entra_no_authorization_policy(self): | ||
entra_client = mock.MagicMock | ||
entra_client.audited_tenant = "audited_tenant" | ||
entra_client.audited_domain = DOMAIN | ||
with ( | ||
mock.patch( | ||
"prowler.providers.common.provider.Provider.get_global_provider", | ||
return_value=set_mocked_microsoft365_provider(), | ||
), | ||
mock.patch( | ||
"prowler.providers.microsoft365.services.entra.entra_thirdparty_integrated_apps_not_allowed.entra_thirdparty_integrated_apps_not_allowed.entra_client", | ||
new=entra_client, | ||
), | ||
): | ||
from prowler.providers.microsoft365.services.entra.entra_thirdparty_integrated_apps_not_allowed.entra_thirdparty_integrated_apps_not_allowed import ( | ||
entra_thirdparty_integrated_apps_not_allowed, | ||
) | ||
|
||
entra_client.authorization_policy = None | ||
|
||
check = entra_thirdparty_integrated_apps_not_allowed() | ||
result = check.execute() | ||
assert len(result) == 1 | ||
assert result[0].status == "FAIL" | ||
assert result[0].resource_name == "Authorization Policy" | ||
assert result[0].resource_id == "authorizationPolicy" | ||
assert ( | ||
result[0].status_extended | ||
== "App creation is not disabled for non-admin users." | ||
) | ||
|
||
def test_entra_default_user_role_permissions_not_allowed_to_create_apps(self): | ||
id = str(uuid4()) | ||
entra_client = mock.MagicMock | ||
entra_client.audited_tenant = "audited_tenant" | ||
entra_client.audited_domain = DOMAIN | ||
|
||
with ( | ||
mock.patch( | ||
"prowler.providers.common.provider.Provider.get_global_provider", | ||
return_value=set_mocked_microsoft365_provider(), | ||
), | ||
mock.patch( | ||
"prowler.providers.microsoft365.services.entra.entra_thirdparty_integrated_apps_not_allowed.entra_thirdparty_integrated_apps_not_allowed.entra_client", | ||
new=entra_client, | ||
), | ||
): | ||
from prowler.providers.microsoft365.services.entra.entra_service import ( | ||
AuthorizationPolicy, | ||
) | ||
from prowler.providers.microsoft365.services.entra.entra_thirdparty_integrated_apps_not_allowed.entra_thirdparty_integrated_apps_not_allowed import ( | ||
entra_thirdparty_integrated_apps_not_allowed, | ||
) | ||
|
||
role_permissions = DefaultUserRolePermissions(allowed_to_create_apps=False) | ||
entra_client.authorization_policy = AuthorizationPolicy( | ||
id=id, | ||
name="Test", | ||
description="Test", | ||
default_user_role_permissions=role_permissions, | ||
) | ||
|
||
check = entra_thirdparty_integrated_apps_not_allowed() | ||
result = check.execute() | ||
assert len(result) == 1 | ||
assert result[0].status == "PASS" | ||
assert ( | ||
result[0].status_extended | ||
== "App creation is disabled for non-admin users." | ||
) | ||
assert result[0].resource_name == "Test" | ||
assert result[0].resource_id == id | ||
|
||
def test_entra_default_user_role_permissions_allowed_to_create_apps(self): | ||
id = str(uuid4()) | ||
entra_client = mock.MagicMock | ||
entra_client.audited_tenant = "audited_tenant" | ||
entra_client.audited_domain = DOMAIN | ||
|
||
with ( | ||
mock.patch( | ||
"prowler.providers.common.provider.Provider.get_global_provider", | ||
return_value=set_mocked_microsoft365_provider(), | ||
), | ||
mock.patch( | ||
"prowler.providers.microsoft365.services.entra.entra_thirdparty_integrated_apps_not_allowed.entra_thirdparty_integrated_apps_not_allowed.entra_client", | ||
new=entra_client, | ||
), | ||
): | ||
from prowler.providers.microsoft365.services.entra.entra_service import ( | ||
AuthorizationPolicy, | ||
) | ||
from prowler.providers.microsoft365.services.entra.entra_thirdparty_integrated_apps_not_allowed.entra_thirdparty_integrated_apps_not_allowed import ( | ||
entra_thirdparty_integrated_apps_not_allowed, | ||
) | ||
|
||
role_permissions = DefaultUserRolePermissions(allowed_to_create_apps=True) | ||
entra_client.authorization_policy = AuthorizationPolicy( | ||
id=id, | ||
name="Test", | ||
description="Test", | ||
default_user_role_permissions=role_permissions, | ||
) | ||
|
||
check = entra_thirdparty_integrated_apps_not_allowed() | ||
result = check.execute() | ||
assert len(result) == 1 | ||
assert result[0].status == "FAIL" | ||
assert ( | ||
result[0].status_extended | ||
== "App creation is not disabled for non-admin users." | ||
) | ||
assert result[0].resource_name == "Test" | ||
assert result[0].resource_id == id |