@cclabsnz/sf-audit 1.15.1 → 1.17.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +143 -1
- package/README.md +100 -24
- package/config/scoring.sample.json +104 -5
- package/lib/apps/analyzeApps.d.ts +8 -2
- package/lib/apps/analyzeApps.js +7 -2
- package/lib/apps/apiLogSource.d.ts +39 -0
- package/lib/apps/apiLogSource.js +75 -0
- package/lib/apps/appResolver.js +30 -4
- package/lib/apps/grantedAccess.js +16 -3
- package/lib/apps/leastPrivilege.d.ts +3 -1
- package/lib/apps/leastPrivilege.js +7 -3
- package/lib/apps/permissionSetGenerator.d.ts +22 -0
- package/lib/apps/permissionSetGenerator.js +100 -0
- package/lib/apps/types.d.ts +6 -0
- package/lib/apps/usageCollector.d.ts +7 -1
- package/lib/apps/usageCollector.js +57 -26
- package/lib/chains/CapabilityRegistry.js +26 -0
- package/lib/chains/namedChains.js +110 -3
- package/lib/checks/CheckEngine.d.ts +3 -1
- package/lib/checks/CheckEngine.js +11 -3
- package/lib/checks/impl/AgentInventoryCheck.js +8 -3
- package/lib/checks/impl/AgentOutboundActionsCheck.d.ts +13 -0
- package/lib/checks/impl/AgentOutboundActionsCheck.js +155 -0
- package/lib/checks/impl/AgentQueryReachCheck.d.ts +11 -0
- package/lib/checks/impl/AgentQueryReachCheck.js +88 -0
- package/lib/checks/impl/ApexCrudFLSCheck.js +45 -10
- package/lib/checks/impl/ApexSharingCheck.js +16 -25
- package/lib/checks/impl/AuthProviderRegistrationHandlerCheck.d.ts +10 -0
- package/lib/checks/impl/AuthProviderRegistrationHandlerCheck.js +131 -0
- package/lib/checks/impl/ConnectedAppsCheck.js +47 -1
- package/lib/checks/impl/DataCloudDataSpaceIsolationCheck.d.ts +10 -0
- package/lib/checks/impl/DataCloudDataSpaceIsolationCheck.js +116 -0
- package/lib/checks/impl/DelegatedAdministrationGroupsCheck.d.ts +10 -0
- package/lib/checks/impl/DelegatedAdministrationGroupsCheck.js +75 -0
- package/lib/checks/impl/DelegatedAuthenticationExposureCheck.d.ts +10 -0
- package/lib/checks/impl/DelegatedAuthenticationExposureCheck.js +98 -0
- package/lib/checks/impl/ExternalAccountHierarchyExposureCheck.d.ts +10 -0
- package/lib/checks/impl/ExternalAccountHierarchyExposureCheck.js +73 -0
- package/lib/checks/impl/FlowHttpCalloutCredentialBypassCheck.d.ts +10 -0
- package/lib/checks/impl/FlowHttpCalloutCredentialBypassCheck.js +115 -0
- package/lib/checks/impl/GenAiPromptTemplateGroundingCheck.d.ts +10 -0
- package/lib/checks/impl/GenAiPromptTemplateGroundingCheck.js +227 -0
- package/lib/checks/impl/GuestExecutableApexCheck.d.ts +1 -1
- package/lib/checks/impl/GuestExecutableApexCheck.js +105 -14
- package/lib/checks/impl/HardcodedCredentialsCheck.js +7 -2
- package/lib/checks/impl/InboundEmailHandlerExposureCheck.d.ts +10 -0
- package/lib/checks/impl/InboundEmailHandlerExposureCheck.js +136 -0
- package/lib/checks/impl/OauthDeviceAndAssetTokenFlowsCheck.d.ts +10 -0
- package/lib/checks/impl/OauthDeviceAndAssetTokenFlowsCheck.js +84 -0
- package/lib/checks/impl/OrgWideEmailSpoofingCheck.d.ts +10 -0
- package/lib/checks/impl/OrgWideEmailSpoofingCheck.js +106 -0
- package/lib/checks/impl/PackagePostInstallSupplyChainCheck.d.ts +10 -0
- package/lib/checks/impl/PackagePostInstallSupplyChainCheck.js +89 -0
- package/lib/checks/impl/PlatformEventSubscriberContextCheck.d.ts +10 -0
- package/lib/checks/impl/PlatformEventSubscriberContextCheck.js +84 -0
- package/lib/checks/impl/RestrictionRulesIntegrityCheck.d.ts +10 -0
- package/lib/checks/impl/RestrictionRulesIntegrityCheck.js +105 -0
- package/lib/checks/impl/ShieldTenantSecretLifecycleCheck.d.ts +10 -0
- package/lib/checks/impl/ShieldTenantSecretLifecycleCheck.js +90 -0
- package/lib/checks/registry.js +34 -0
- package/lib/checks/support/agentGraph.d.ts +49 -0
- package/lib/checks/support/agentGraph.js +87 -0
- package/lib/checks/support/apexAccess.d.ts +56 -0
- package/lib/checks/support/apexAccess.js +127 -0
- package/lib/checks/support/missingObject.d.ts +13 -0
- package/lib/checks/support/missingObject.js +35 -0
- package/lib/commands/audit/apps.d.ts +1 -0
- package/lib/commands/audit/apps.js +83 -29
- package/lib/commands/audit/diff.js +2 -2
- package/lib/commands/audit/history.js +2 -2
- package/lib/commands/audit/incident/report.js +2 -2
- package/lib/commands/audit/security.d.ts +3 -0
- package/lib/commands/audit/security.js +58 -9
- package/lib/commands/audit/timeline.js +2 -2
- package/lib/compliance/mapping.js +35 -7
- package/lib/findings/AuditResult.d.ts +8 -0
- package/lib/findings/CheckMeta.js +17 -0
- package/lib/findings/Finding.d.ts +4 -0
- package/lib/findings/ScoringConfig.d.ts +10 -8
- package/lib/findings/ScoringConfig.js +12 -5
- package/lib/findings/coverage.d.ts +28 -0
- package/lib/findings/coverage.js +30 -0
- package/lib/findings/exitCode.js +1 -1
- package/lib/findings/loadScoringConfig.js +51 -8
- package/lib/findings/scoring.js +14 -5
- package/lib/history/HistoryStore.js +9 -3
- package/lib/history/archivePolicy.d.ts +19 -0
- package/lib/history/archivePolicy.js +34 -0
- package/lib/incident/bundleIo.js +4 -3
- package/lib/incident/collect/collectBundle.d.ts +1 -1
- package/lib/incident/collect/collectBundle.js +4 -3
- package/lib/incident/collect/streamGuestLogs.d.ts +1 -1
- package/lib/incident/collect/streamGuestLogs.js +3 -2
- package/lib/incident/csv.js +4 -4
- package/lib/incident/render/evidence.js +3 -3
- package/lib/incident/render/html.js +2 -3
- package/lib/index.d.ts +2 -0
- package/lib/index.js +2 -0
- package/lib/lib/packageInfo.d.ts +6 -0
- package/lib/lib/packageInfo.js +19 -0
- package/lib/renderers/AttackChainDagRenderer.d.ts +7 -0
- package/lib/renderers/AttackChainDagRenderer.js +139 -0
- package/lib/renderers/ClientReportRenderer.d.ts +2 -0
- package/lib/renderers/ClientReportRenderer.js +34 -6
- package/lib/renderers/DiffHtmlRenderer.js +2 -7
- package/lib/renderers/HistoryRenderer.js +19 -11
- package/lib/renderers/HtmlRenderer.js +19 -6
- package/lib/renderers/MarkdownRenderer.js +7 -0
- package/lib/renderers/SarifRenderer.d.ts +43 -0
- package/lib/renderers/SarifRenderer.js +250 -0
- package/lib/report/ExecutivePriorities.js +1 -1
- package/lib/report/RemediationRoadmap.js +1 -1
- package/lib/waivers/WaiverLoader.d.ts +28 -0
- package/lib/waivers/WaiverLoader.js +103 -0
- package/lib/waivers/WaiverModel.d.ts +32 -0
- package/lib/waivers/WaiverModel.js +28 -0
- package/lib/waivers/applyWaivers.d.ts +22 -0
- package/lib/waivers/applyWaivers.js +85 -0
- package/package.json +3 -3
|
@@ -1,23 +1,9 @@
|
|
|
1
|
-
import { ApexRepository } from '@cclabsnz/sf-core';
|
|
2
|
-
|
|
3
|
-
const WITHOUT_SHARING = /\bwithout\s+sharing\b/i;
|
|
4
|
-
const WITH_SHARING = /\bwith\s+sharing\b/i;
|
|
5
|
-
const CLASS_PATTERN = /\bclass\s+\w+/i;
|
|
1
|
+
import { ApexRepository, testApexPattern } from '@cclabsnz/sf-core';
|
|
2
|
+
import { apexCode, effectiveSharing } from '../support/apexAccess.js';
|
|
6
3
|
const IS_TEST_CLASS = /@IsTest\b/i;
|
|
7
|
-
// SBS-CPORTAL-001: @AuraEnabled
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (!CLASS_PATTERN.test(body)) {
|
|
11
|
-
return null; // Not a class — skip interfaces, enums, etc.
|
|
12
|
-
}
|
|
13
|
-
if (WITH_SHARING.test(body))
|
|
14
|
-
return 'with';
|
|
15
|
-
if (WITHOUT_SHARING.test(body))
|
|
16
|
-
return 'without';
|
|
17
|
-
if (INHERITED_SHARING.test(body))
|
|
18
|
-
return 'inherited';
|
|
19
|
-
return 'none';
|
|
20
|
-
}
|
|
4
|
+
// SBS-CPORTAL-001: @AuraEnabled and @RemoteAction expose a class to portal and community users;
|
|
5
|
+
// @RestResource exposes it to any API caller (spec RULE-005).
|
|
6
|
+
const IS_EXTERNALLY_EXPOSED = /@AuraEnabled\b|@RemoteAction\b|@RestResource\b/i;
|
|
21
7
|
export class ApexSharingCheck {
|
|
22
8
|
id = 'apex-sharing';
|
|
23
9
|
name = 'Apex Sharing Declarations';
|
|
@@ -41,15 +27,20 @@ export class ApexSharingCheck {
|
|
|
41
27
|
// SBS-CPORTAL-001: portal-exposed Apex without enforcement = IDOR risk
|
|
42
28
|
const portalExposedWithoutSharing = [];
|
|
43
29
|
const portalExposedNoDeclaration = [];
|
|
30
|
+
const bodyByName = new Map(apexBodies.map((b) => [b.name.toLowerCase(), b.body ?? '']));
|
|
44
31
|
for (const apexClass of apexBodies) {
|
|
45
32
|
const body = apexClass.body ?? '';
|
|
33
|
+
const code = apexCode(body);
|
|
46
34
|
// Test classes run as sysadmin — sharing declarations are not applicable
|
|
47
|
-
if (IS_TEST_CLASS
|
|
35
|
+
if (testApexPattern(code, IS_TEST_CLASS))
|
|
48
36
|
continue;
|
|
49
|
-
|
|
37
|
+
// Read from the class's own declaration, not any mention in the body (spec MN-002).
|
|
38
|
+
// SYSTEM_MODE does not enter into it: it bypasses CRUD/FLS, not sharing (spec RULE-001).
|
|
39
|
+
// A class with no keyword takes the sharing of the class it extends (spec MN-001).
|
|
40
|
+
const declaration = effectiveSharing(apexClass.name, body, (n) => bodyByName.get(n.toLowerCase()));
|
|
50
41
|
if (declaration === null)
|
|
51
42
|
continue; // Not a class definition
|
|
52
|
-
const isPortalExposed =
|
|
43
|
+
const isPortalExposed = testApexPattern(code, IS_EXTERNALLY_EXPOSED);
|
|
53
44
|
switch (declaration) {
|
|
54
45
|
case 'with':
|
|
55
46
|
withSharingClasses.push(apexClass.name);
|
|
@@ -80,9 +71,9 @@ export class ApexSharingCheck {
|
|
|
80
71
|
id: 'portal-exposed-apex-without-sharing',
|
|
81
72
|
category: this.category,
|
|
82
73
|
riskLevel: 'CRITICAL',
|
|
83
|
-
title: `${allPortalRisk.length}
|
|
84
|
-
detail: 'Classes with @AuraEnabled or @
|
|
85
|
-
remediation: 'Add "with sharing" to all @AuraEnabled and @
|
|
74
|
+
title: `${allPortalRisk.length} externally exposed Apex class(es) (@AuraEnabled/@RemoteAction/@RestResource) lack "with sharing": IDOR risk`,
|
|
75
|
+
detail: 'Classes with @AuraEnabled, @RemoteAction or @RestResource methods that use "without sharing" or have no sharing declaration execute without record-level access control. Attackers can supply arbitrary record IDs to read or manipulate data they should not access (IDOR). SBS-CPORTAL-001 requires server-side authorization for every record accessed via portal Apex.',
|
|
76
|
+
remediation: 'Add "with sharing" to all @AuraEnabled, @RemoteAction and @RestResource classes. Validate user ownership or sharing on every record accessed inside these methods.',
|
|
86
77
|
affectedItems: allPortalRisk.map((name) => ({
|
|
87
78
|
label: name,
|
|
88
79
|
url: apexClassesUrl,
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuditContext } from '@cclabsnz/sf-core';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
export declare class AuthProviderRegistrationHandlerCheck implements SecurityCheck {
|
|
4
|
+
readonly id = "auth-provider-registration-handler";
|
|
5
|
+
readonly name = "Auth.Provider Registration Handler Security";
|
|
6
|
+
readonly category = "Identity & Access";
|
|
7
|
+
readonly description = "Detects Auth.Provider RegistrationHandler running as Admin with email-based account linking vulnerable to pre-auth takeover.";
|
|
8
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=AuthProviderRegistrationHandlerCheck.d.ts.map
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
export class AuthProviderRegistrationHandlerCheck {
|
|
2
|
+
id = 'auth-provider-registration-handler';
|
|
3
|
+
name = 'Auth.Provider Registration Handler Security';
|
|
4
|
+
category = 'Identity & Access';
|
|
5
|
+
description = 'Detects Auth.Provider RegistrationHandler running as Admin with email-based account linking vulnerable to pre-auth takeover.';
|
|
6
|
+
async run(ctx) {
|
|
7
|
+
const findings = [];
|
|
8
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
9
|
+
const authProviderUrl = `${baseUrl}/lightning/setup/AuthProviders/home`;
|
|
10
|
+
let providers = [];
|
|
11
|
+
try {
|
|
12
|
+
providers = await ctx.soql.queryAll('SELECT Id, DeveloperName, FriendlyName, ProviderType, ExecutionUserId, RegistrationHandlerId FROM AuthProvider WHERE RegistrationHandlerId != null');
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
// This object exists in every org, so a failure is lack of access, never an absent feature.
|
|
16
|
+
findings.push({
|
|
17
|
+
id: 'auth-provider-registration-handler-inaccessible',
|
|
18
|
+
category: this.category,
|
|
19
|
+
riskLevel: 'INFO',
|
|
20
|
+
inconclusive: true,
|
|
21
|
+
title: 'Auth Providers could not be queried',
|
|
22
|
+
detail: `Failed to query AuthProvider: ${err instanceof Error ? err.message : String(err)}`,
|
|
23
|
+
remediation: 'Grant the audit user "View Setup and Configuration".',
|
|
24
|
+
});
|
|
25
|
+
return { findings };
|
|
26
|
+
}
|
|
27
|
+
if (providers.length === 0) {
|
|
28
|
+
findings.push({
|
|
29
|
+
id: 'auth-provider-registration-handler-ok',
|
|
30
|
+
category: this.category,
|
|
31
|
+
riskLevel: 'LOW',
|
|
32
|
+
passed: true,
|
|
33
|
+
title: 'No Auth Providers configured with Registration Handlers',
|
|
34
|
+
detail: 'Zero AuthProvider records in this org configure an automated Registration Handler.',
|
|
35
|
+
remediation: 'When configuring Registration Handlers, avoid execution as System Administrator and verify email authenticity.',
|
|
36
|
+
});
|
|
37
|
+
return { findings };
|
|
38
|
+
}
|
|
39
|
+
// Query Execution Users
|
|
40
|
+
const executionUserIds = [
|
|
41
|
+
...new Set(providers.map((p) => p.ExecutionUserId).filter((id) => Boolean(id))),
|
|
42
|
+
];
|
|
43
|
+
let adminUsers = new Set();
|
|
44
|
+
let userDetails = new Map();
|
|
45
|
+
if (executionUserIds.length > 0) {
|
|
46
|
+
const users = await ctx.soql.queryAll(`SELECT Id, Username, IsActive, Profile.Name FROM User WHERE Id IN ('${executionUserIds.join("','")}')`);
|
|
47
|
+
for (const u of users) {
|
|
48
|
+
const profName = u.Profile?.Name ?? '';
|
|
49
|
+
userDetails.set(u.Id, `${u.Username} (${profName})`);
|
|
50
|
+
if (profName === 'System Administrator' || profName.toLowerCase().includes('admin')) {
|
|
51
|
+
adminUsers.add(u.Id);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
// Query Registration Handler Apex classes
|
|
56
|
+
const handlerIds = [
|
|
57
|
+
...new Set(providers.map((p) => p.RegistrationHandlerId).filter((id) => Boolean(id))),
|
|
58
|
+
];
|
|
59
|
+
let classBodies = new Map();
|
|
60
|
+
let classNames = new Map();
|
|
61
|
+
if (handlerIds.length > 0) {
|
|
62
|
+
const classes = await ctx.soql.queryAll(`SELECT Id, Name, Body FROM ApexClass WHERE Id IN ('${handlerIds.join("','")}')`);
|
|
63
|
+
for (const c of classes) {
|
|
64
|
+
classNames.set(c.Id, c.Name);
|
|
65
|
+
classBodies.set(c.Id, c.Body ?? '');
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
const adminExecProviders = [];
|
|
69
|
+
const unverifiedEmailLinkingProviders = [];
|
|
70
|
+
for (const p of providers) {
|
|
71
|
+
const isExecAdmin = p.ExecutionUserId && adminUsers.has(p.ExecutionUserId);
|
|
72
|
+
if (isExecAdmin) {
|
|
73
|
+
adminExecProviders.push(p);
|
|
74
|
+
}
|
|
75
|
+
const body = p.RegistrationHandlerId ? classBodies.get(p.RegistrationHandlerId) ?? '' : '';
|
|
76
|
+
if (body) {
|
|
77
|
+
// Check if class queries user by email
|
|
78
|
+
const matchesEmailQuery = /SELECT\s+[^;]+FROM\s+User\s+WHERE\s+[^;]*Email\s*=/i.test(body);
|
|
79
|
+
// Check if verification or portal scoping is present
|
|
80
|
+
const checksVerified = /email_verified|isEmailVerified|emailVerified/i.test(body);
|
|
81
|
+
const checksPortalScope = /UserType|IsPortalEnabled|UserLicense/i.test(body);
|
|
82
|
+
if (matchesEmailQuery && (!checksVerified || !checksPortalScope)) {
|
|
83
|
+
unverifiedEmailLinkingProviders.push(p);
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
if (adminExecProviders.length > 0) {
|
|
88
|
+
findings.push({
|
|
89
|
+
id: 'auth-provider-registration-handler-admin-exec',
|
|
90
|
+
category: this.category,
|
|
91
|
+
riskLevel: 'CRITICAL',
|
|
92
|
+
title: `${adminExecProviders.length} Auth Provider(s) execute Registration Handler as System Administrator`,
|
|
93
|
+
detail: 'When an Auth.Provider (SSO, OIDC, Google, etc.) Registration Handler runs under a System Administrator execution context, any user creation, role assignment, or record linking executed by the handler occurs with maximum system privileges, enabling automated privilege escalation.',
|
|
94
|
+
remediation: 'Configure the "Execute Registration As" user to a dedicated least-privileged integration user rather than a full System Administrator.',
|
|
95
|
+
affectedItems: adminExecProviders.map((p) => ({
|
|
96
|
+
label: p.FriendlyName || p.DeveloperName,
|
|
97
|
+
url: authProviderUrl,
|
|
98
|
+
note: `Execution user: ${p.ExecutionUserId ? userDetails.get(p.ExecutionUserId) ?? p.ExecutionUserId : 'Unknown'}`,
|
|
99
|
+
})),
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
if (unverifiedEmailLinkingProviders.length > 0) {
|
|
103
|
+
findings.push({
|
|
104
|
+
id: 'auth-provider-registration-handler-unverified-email-linking',
|
|
105
|
+
category: this.category,
|
|
106
|
+
riskLevel: 'CRITICAL',
|
|
107
|
+
title: `${unverifiedEmailLinkingProviders.length} Auth Provider(s) link user accounts by email without verification or portal scoping`,
|
|
108
|
+
detail: 'The RegistrationHandler Apex class matches existing User records purely by email address (SELECT Id FROM User WHERE Email = :data.email) without validating email verification tokens (email_verified == true) or scoping to portal user types. An attacker registering an account with a target admin\'s email address on a public or social identity provider can hijack the internal admin user account upon login.',
|
|
109
|
+
remediation: 'Update the RegistrationHandler to verify email_verified == true from the identity provider and ensure social/external registrations can never match internal standard or administrator User records.',
|
|
110
|
+
affectedItems: unverifiedEmailLinkingProviders.map((p) => ({
|
|
111
|
+
label: `${p.FriendlyName || p.DeveloperName} (Handler: ${p.RegistrationHandlerId ? classNames.get(p.RegistrationHandlerId) ?? p.RegistrationHandlerId : 'Unknown'})`,
|
|
112
|
+
url: authProviderUrl,
|
|
113
|
+
note: 'Unverified email matching against User table',
|
|
114
|
+
})),
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
if (adminExecProviders.length === 0 && unverifiedEmailLinkingProviders.length === 0) {
|
|
118
|
+
findings.push({
|
|
119
|
+
id: 'auth-provider-registration-handler-ok',
|
|
120
|
+
category: this.category,
|
|
121
|
+
riskLevel: 'LOW',
|
|
122
|
+
passed: true,
|
|
123
|
+
title: 'Auth Provider Registration Handlers are securely configured',
|
|
124
|
+
detail: `${providers.length} Auth Provider(s) inspected; handlers do not run as System Administrator and do not perform unverified email account linking.`,
|
|
125
|
+
remediation: 'Continue enforcing least-privilege execution users and strict identity verification in Registration Handlers.',
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
return { findings };
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
//# sourceMappingURL=AuthProviderRegistrationHandlerCheck.js.map
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* External Client Apps are absent from orgs that predate them, where the query answers with
|
|
3
|
+
* INVALID_TYPE. That, and only that, means "none"; any other failure is reported as inconclusive.
|
|
4
|
+
*/
|
|
5
|
+
function isExternalClientAppUnsupported(err) {
|
|
6
|
+
const code = err?.errorCode ?? '';
|
|
7
|
+
const msg = err instanceof Error ? err.message : String(err);
|
|
8
|
+
return code === 'INVALID_TYPE' || /sObject type 'ExternalClientApplication' is not supported/i.test(msg);
|
|
9
|
+
}
|
|
1
10
|
export class ConnectedAppsCheck {
|
|
2
11
|
id = 'connected-apps';
|
|
3
12
|
name = 'Connected Apps';
|
|
@@ -11,7 +20,30 @@ export class ConnectedAppsCheck {
|
|
|
11
20
|
const connectedApps = await ctx.soql.queryAll(`SELECT Id, Name, OptionsAllowAdminApprovedUsersOnly, SessionTimeout
|
|
12
21
|
FROM ConnectedApplication`);
|
|
13
22
|
const count = connectedApps.length;
|
|
14
|
-
//
|
|
23
|
+
// External Client Apps are the successor to connected apps. Their policies (permitted users,
|
|
24
|
+
// session timeout) are not exposed on the objects this check can read reliably, so they are
|
|
25
|
+
// inventoried and listed for manual review rather than judged on guessed fields.
|
|
26
|
+
let externalApps = [];
|
|
27
|
+
try {
|
|
28
|
+
externalApps = await ctx.soql.queryAll('SELECT Id, DeveloperName, MasterLabel FROM ExternalClientApplication');
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
if (!isExternalClientAppUnsupported(err)) {
|
|
32
|
+
findings.push({
|
|
33
|
+
id: 'external-client-apps-inconclusive',
|
|
34
|
+
category: this.category,
|
|
35
|
+
riskLevel: 'INFO',
|
|
36
|
+
inconclusive: true,
|
|
37
|
+
title: 'External Client Apps could not be listed',
|
|
38
|
+
detail: `The connected-app results below stand, but External Client Apps were not checked: ${err instanceof Error ? err.message : String(err)}`,
|
|
39
|
+
remediation: 'Grant the audit user View Setup and Configuration, then re-run. Meanwhile review Setup → External Client App Manager manually.',
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
// Cache app names for DeploymentIdentityCheck and SiemIntegrationCheck — no extra query.
|
|
44
|
+
// Connected apps only: ConnectedAppInactivityCheck matches these names against LoginHistory,
|
|
45
|
+
// and how External Client App logins are labelled there is unverified, so adding them could
|
|
46
|
+
// report every External Client App as inactive.
|
|
15
47
|
ctx.cache.connectedAppNames = connectedApps.map((a) => a.Name);
|
|
16
48
|
// Check for apps with unrestricted user access
|
|
17
49
|
const unrestrictedApps = connectedApps.filter((app) => !app.OptionsAllowAdminApprovedUsersOnly);
|
|
@@ -73,6 +105,20 @@ export class ConnectedAppsCheck {
|
|
|
73
105
|
remediation: 'Continue monitoring as new connected apps are added.',
|
|
74
106
|
});
|
|
75
107
|
}
|
|
108
|
+
if (externalApps.length > 0) {
|
|
109
|
+
findings.push({
|
|
110
|
+
id: 'external-client-apps-review',
|
|
111
|
+
category: this.category,
|
|
112
|
+
riskLevel: 'INFO',
|
|
113
|
+
title: `${externalApps.length} External Client App(s) need their OAuth policies reviewed manually`,
|
|
114
|
+
detail: 'External Client Apps carry the same risks as connected apps: who may authorise them, and how long their sessions and refresh tokens last. This audit lists them but does not evaluate their policies, so the connected-app results above do not cover them.',
|
|
115
|
+
remediation: 'In Setup → External Client App Manager, open each app\'s OAuth policies: set Permitted Users to admin-approved users, an access-token timeout of 15 minutes or less for CLI and CI/CD apps, and a bounded refresh-token validity.',
|
|
116
|
+
affectedItems: externalApps.map((app) => ({
|
|
117
|
+
label: app.MasterLabel || app.DeveloperName,
|
|
118
|
+
url: `${baseUrl}/${app.Id}`,
|
|
119
|
+
})),
|
|
120
|
+
});
|
|
121
|
+
}
|
|
76
122
|
return {
|
|
77
123
|
findings,
|
|
78
124
|
metrics: {
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuditContext } from '@cclabsnz/sf-core';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
export declare class DataCloudDataSpaceIsolationCheck implements SecurityCheck {
|
|
4
|
+
readonly id = "data-cloud-data-space-isolation";
|
|
5
|
+
readonly name = "Data Cloud Data Space Isolation";
|
|
6
|
+
readonly category = "Data Security";
|
|
7
|
+
readonly description = "Flags orgs where external integrations, partner users, or agent users are mapped to the default Data Space, or unconstrained Data Share Targets exist.";
|
|
8
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=DataCloudDataSpaceIsolationCheck.d.ts.map
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
import { isMissingObjectError, queryIfPresent } from '../support/missingObject.js';
|
|
2
|
+
const EXTERNAL_USER_TYPES = new Set(['PowerPartner', 'CustomerSuccess', 'PowerCustomerSuccess', 'CspLitePortal', 'Guest']);
|
|
3
|
+
function isDataCloudPermSet(ps) {
|
|
4
|
+
return /datacloud|dataspace|cdp/i.test(`${ps?.Name ?? ''} ${ps?.Label ?? ''}`);
|
|
5
|
+
}
|
|
6
|
+
export class DataCloudDataSpaceIsolationCheck {
|
|
7
|
+
id = 'data-cloud-data-space-isolation';
|
|
8
|
+
name = 'Data Cloud Data Space Isolation';
|
|
9
|
+
category = 'Data Security';
|
|
10
|
+
description = 'Flags orgs where external integrations, partner users, or agent users are mapped to the default Data Space, or unconstrained Data Share Targets exist.';
|
|
11
|
+
async run(ctx) {
|
|
12
|
+
const findings = [];
|
|
13
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
14
|
+
let dataSpaces;
|
|
15
|
+
try {
|
|
16
|
+
dataSpaces = await ctx.soql.queryAll('SELECT Id, Name, Description FROM DataSpace');
|
|
17
|
+
}
|
|
18
|
+
catch (err) {
|
|
19
|
+
if (isMissingObjectError(err)) {
|
|
20
|
+
findings.push({
|
|
21
|
+
id: 'data-cloud-data-space-not-enabled',
|
|
22
|
+
category: this.category,
|
|
23
|
+
riskLevel: 'LOW',
|
|
24
|
+
passed: true,
|
|
25
|
+
title: 'Data Cloud is not enabled or DataSpace is not configured in this org',
|
|
26
|
+
detail: 'DataSpace object is not available; Data Cloud is not enabled or licensed in this org.',
|
|
27
|
+
remediation: 'No action required if Data Cloud is not deployed.',
|
|
28
|
+
});
|
|
29
|
+
return { findings };
|
|
30
|
+
}
|
|
31
|
+
findings.push({
|
|
32
|
+
id: 'data-cloud-data-space-inaccessible',
|
|
33
|
+
category: this.category,
|
|
34
|
+
riskLevel: 'INFO',
|
|
35
|
+
inconclusive: true,
|
|
36
|
+
title: 'Data Cloud Data Spaces could not be read',
|
|
37
|
+
detail: `Query to DataSpace failed: ${err instanceof Error ? err.message : String(err)}`,
|
|
38
|
+
remediation: 'Ensure the audit user has permission to view Data Cloud Data Spaces and configuration.',
|
|
39
|
+
});
|
|
40
|
+
return { findings };
|
|
41
|
+
}
|
|
42
|
+
if (dataSpaces.length === 0) {
|
|
43
|
+
findings.push({
|
|
44
|
+
id: 'data-cloud-data-space-ok',
|
|
45
|
+
category: this.category,
|
|
46
|
+
riskLevel: 'LOW',
|
|
47
|
+
passed: true,
|
|
48
|
+
title: 'No Data Cloud Data Spaces found',
|
|
49
|
+
detail: 'Zero DataSpace records exist in this org.',
|
|
50
|
+
remediation: 'Define segmented Data Spaces if Data Cloud is activated in the future.',
|
|
51
|
+
});
|
|
52
|
+
return { findings };
|
|
53
|
+
}
|
|
54
|
+
// Data Cloud names its default data space "default". Only Name is selected, so only Name is read.
|
|
55
|
+
const defaultDataSpace = dataSpaces.find((ds) => (ds.Name ?? '').toLowerCase() === 'default');
|
|
56
|
+
// External, guest or agent users holding a Data Cloud permission set they were assigned
|
|
57
|
+
// directly. A profile's own permission set, or an unrelated one, grants no data space access.
|
|
58
|
+
const assignments = await ctx.soql.queryAll("SELECT Id, AssigneeId, Assignee.Username, Assignee.UserType, Assignee.Profile.Name, PermissionSet.Name, PermissionSet.Label FROM PermissionSetAssignment WHERE Assignee.IsActive = true AND PermissionSet.IsOwnedByProfile = false AND (PermissionSet.Name LIKE '%DataCloud%' OR PermissionSet.Name LIKE '%DataSpace%' OR PermissionSet.Name LIKE '%CDP%')");
|
|
59
|
+
const byUser = new Map();
|
|
60
|
+
for (const a of assignments) {
|
|
61
|
+
const uType = a.Assignee?.UserType ?? '';
|
|
62
|
+
const uname = (a.Assignee?.Username ?? '').toLowerCase();
|
|
63
|
+
const lowTrust = EXTERNAL_USER_TYPES.has(uType) || uname.includes('agent');
|
|
64
|
+
if (lowTrust && isDataCloudPermSet(a.PermissionSet) && !byUser.has(a.AssigneeId))
|
|
65
|
+
byUser.set(a.AssigneeId, a);
|
|
66
|
+
}
|
|
67
|
+
const oversharedUsers = [...byUser.values()];
|
|
68
|
+
if (defaultDataSpace && oversharedUsers.length > 0) {
|
|
69
|
+
findings.push({
|
|
70
|
+
id: 'data-cloud-data-space-default-overshared',
|
|
71
|
+
category: this.category,
|
|
72
|
+
riskLevel: 'HIGH',
|
|
73
|
+
title: `${oversharedUsers.length} external, partner, or agent user(s) hold Data Cloud access while the default Data Space is in use`,
|
|
74
|
+
detail: 'Data Cloud default Data Space flattens standard Salesforce OWD record-level sharing. Exposing the default Data Space to external partner, integration, or agent accounts grants bulk visibility across data lake objects (DLOs) and data model objects (DMOs).',
|
|
75
|
+
remediation: 'Segment data by creating dedicated Data Spaces with restricted permissions, and map partner and agent users only to their respective segmented spaces.',
|
|
76
|
+
affectedItems: oversharedUsers.map((u) => ({
|
|
77
|
+
label: u.Assignee?.Username ?? u.AssigneeId,
|
|
78
|
+
url: `${baseUrl}/lightning/setup/DataCloudDataSpace/home`,
|
|
79
|
+
note: `UserType: ${u.Assignee?.UserType ?? 'Unknown'}; permission set ${u.PermissionSet?.Label ?? u.PermissionSet?.Name ?? 'unknown'}`,
|
|
80
|
+
})),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
// Query DataShareTarget for unconstrained external data sharing
|
|
84
|
+
const shareTargets = await queryIfPresent(() => ctx.soql.queryAll('SELECT Id, Name, TargetType, Status FROM DataShareTarget'));
|
|
85
|
+
const unconstrainedTargets = shareTargets.filter((t) => (t.Status ?? '').toLowerCase() === 'active');
|
|
86
|
+
if (unconstrainedTargets.length > 0) {
|
|
87
|
+
findings.push({
|
|
88
|
+
id: 'data-cloud-data-share-target-unconstrained',
|
|
89
|
+
category: this.category,
|
|
90
|
+
riskLevel: 'HIGH',
|
|
91
|
+
title: `${unconstrainedTargets.length} active Data Cloud Data Share Target(s) without IP or authentication constraints`,
|
|
92
|
+
detail: 'External Data Share Targets allow zero-copy outbound sharing to external platforms (Snowflake, AWS S3, BigQuery). Active targets without strict constraints expose bulk customer data outside Salesforce boundaries.',
|
|
93
|
+
remediation: 'Audit all active Data Share Targets, apply IP restrictions, and verify authentication and encryption configurations.',
|
|
94
|
+
affectedItems: unconstrainedTargets.map((t) => ({
|
|
95
|
+
label: t.Name ?? t.Id,
|
|
96
|
+
url: `${baseUrl}/lightning/setup/DataShare/home`,
|
|
97
|
+
note: `TargetType: ${t.TargetType ?? 'Unknown'}, Status: ${t.Status ?? 'Unknown'}`,
|
|
98
|
+
})),
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
if ((!defaultDataSpace || oversharedUsers.length === 0) &&
|
|
102
|
+
unconstrainedTargets.length === 0) {
|
|
103
|
+
findings.push({
|
|
104
|
+
id: 'data-cloud-data-space-ok',
|
|
105
|
+
category: this.category,
|
|
106
|
+
riskLevel: 'LOW',
|
|
107
|
+
passed: true,
|
|
108
|
+
title: 'Data Cloud Data Spaces and Data Share Targets are properly segmented and isolated',
|
|
109
|
+
detail: `${dataSpaces.length} Data Space(s) inspected; no over-sharing to low-trust identities or unconstrained share targets detected.`,
|
|
110
|
+
remediation: 'Continue enforcing segmented Data Spaces for any new integration or external user.',
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
return { findings };
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
//# sourceMappingURL=DataCloudDataSpaceIsolationCheck.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuditContext } from '@cclabsnz/sf-core';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
export declare class DelegatedAdministrationGroupsCheck implements SecurityCheck {
|
|
4
|
+
readonly id = "delegated-administration-groups";
|
|
5
|
+
readonly name = "Delegated Administration Groups";
|
|
6
|
+
readonly category = "Privileged Access";
|
|
7
|
+
readonly description = "Identifies unmonitored Delegated Admin Groups that grant shadow-admin privileges outside profiles and permission sets.";
|
|
8
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=DelegatedAdministrationGroupsCheck.d.ts.map
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
export class DelegatedAdministrationGroupsCheck {
|
|
2
|
+
id = 'delegated-administration-groups';
|
|
3
|
+
name = 'Delegated Administration Groups';
|
|
4
|
+
category = 'Privileged Access';
|
|
5
|
+
description = 'Identifies unmonitored Delegated Admin Groups that grant shadow-admin privileges outside profiles and permission sets.';
|
|
6
|
+
async run(ctx) {
|
|
7
|
+
const findings = [];
|
|
8
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
9
|
+
const setupUrl = `${baseUrl}/lightning/setup/DelegateGroups/home`;
|
|
10
|
+
let groups = [];
|
|
11
|
+
try {
|
|
12
|
+
groups = await ctx.soql.queryAll('SELECT Id, DeveloperName FROM DelegateGroup');
|
|
13
|
+
}
|
|
14
|
+
catch (err) {
|
|
15
|
+
// This object exists in every org, so a failure is lack of access, never an absent feature.
|
|
16
|
+
findings.push({
|
|
17
|
+
id: 'delegated-administration-groups-inaccessible',
|
|
18
|
+
category: this.category,
|
|
19
|
+
riskLevel: 'INFO',
|
|
20
|
+
inconclusive: true,
|
|
21
|
+
title: 'Delegated Administration Groups could not be queried',
|
|
22
|
+
detail: `Failed to query DelegateGroup: ${err instanceof Error ? err.message : String(err)}`,
|
|
23
|
+
remediation: 'Grant the audit user "View Setup and Configuration" to inspect delegated admin groups.',
|
|
24
|
+
});
|
|
25
|
+
return { findings };
|
|
26
|
+
}
|
|
27
|
+
if (groups.length === 0) {
|
|
28
|
+
findings.push({
|
|
29
|
+
id: 'delegated-administration-groups-ok',
|
|
30
|
+
category: this.category,
|
|
31
|
+
riskLevel: 'LOW',
|
|
32
|
+
passed: true,
|
|
33
|
+
title: 'No Delegated Administration Groups found',
|
|
34
|
+
detail: 'Zero DelegateGroup records are configured in this org.',
|
|
35
|
+
remediation: 'Continue avoiding unmonitored delegated administration groups.',
|
|
36
|
+
});
|
|
37
|
+
return { findings };
|
|
38
|
+
}
|
|
39
|
+
// Query members of delegated admin groups
|
|
40
|
+
let members = [];
|
|
41
|
+
members = await ctx.soql.queryAll('SELECT Id, DelegateGroupId, UserOrGroupId FROM DelegateGroupMember');
|
|
42
|
+
// Collect user names if members exist
|
|
43
|
+
const userIds = members
|
|
44
|
+
.map((m) => m.UserOrGroupId)
|
|
45
|
+
.filter((id) => Boolean(id && id.startsWith('005')));
|
|
46
|
+
let userMap = new Map();
|
|
47
|
+
if (userIds.length > 0) {
|
|
48
|
+
const users = await ctx.soql.queryAll(`SELECT Id, Username, Profile.Name FROM User WHERE Id IN ('${userIds.join("','")}')`);
|
|
49
|
+
for (const u of users) {
|
|
50
|
+
userMap.set(u.Id, `${u.Username} (${u.Profile?.Name ?? 'Unknown Profile'})`);
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
findings.push({
|
|
54
|
+
id: 'delegated-administration-groups-active',
|
|
55
|
+
category: this.category,
|
|
56
|
+
riskLevel: 'HIGH',
|
|
57
|
+
title: `${groups.length} Delegated Administration Group(s) grant unmonitored shadow-admin privileges`,
|
|
58
|
+
detail: 'Delegated Administration groups operate completely outside Profiles, Permission Sets, and Permission Set Groups. A user with a standard read-only profile assigned to a DelegateGroup can create users, reset passwords, unlock accounts, assign permission sets, and log in as users in their subordinate role hierarchy—effectively serving as an invisible Shadow Admin that standard privilege audits miss.',
|
|
59
|
+
remediation: 'Review all members and assigned grants in Setup → Delegated Administration. Ensure all delegated administrators are known, assignable permission sets are tightly scoped, and remove obsolete groups.',
|
|
60
|
+
affectedItems: groups.map((g) => {
|
|
61
|
+
const groupMembers = members.filter((m) => m.DelegateGroupId === g.Id);
|
|
62
|
+
const memberDesc = groupMembers
|
|
63
|
+
.map((m) => userMap.get(m.UserOrGroupId) ?? m.UserOrGroupId)
|
|
64
|
+
.join(', ');
|
|
65
|
+
return {
|
|
66
|
+
label: g.DeveloperName || g.Name || g.Id,
|
|
67
|
+
url: setupUrl,
|
|
68
|
+
note: memberDesc ? `Members: ${memberDesc}` : 'Active delegated administration group',
|
|
69
|
+
};
|
|
70
|
+
}),
|
|
71
|
+
});
|
|
72
|
+
return { findings };
|
|
73
|
+
}
|
|
74
|
+
}
|
|
75
|
+
//# sourceMappingURL=DelegatedAdministrationGroupsCheck.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuditContext } from '@cclabsnz/sf-core';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
export declare class DelegatedAuthenticationExposureCheck implements SecurityCheck {
|
|
4
|
+
readonly id = "delegated-authentication-exposure";
|
|
5
|
+
readonly name = "Delegated Authentication Exposure";
|
|
6
|
+
readonly category = "Identity & Access";
|
|
7
|
+
readonly description = "Flags Delegated Authentication enabled over non-mTLS endpoints or assigned to System Administrator profiles.";
|
|
8
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=DelegatedAuthenticationExposureCheck.d.ts.map
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
export class DelegatedAuthenticationExposureCheck {
|
|
2
|
+
id = 'delegated-authentication-exposure';
|
|
3
|
+
name = 'Delegated Authentication Exposure';
|
|
4
|
+
category = 'Identity & Access';
|
|
5
|
+
description = 'Flags Delegated Authentication enabled over non-mTLS endpoints or assigned to System Administrator profiles.';
|
|
6
|
+
async run(ctx) {
|
|
7
|
+
const findings = [];
|
|
8
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
9
|
+
const ssoUrl = `${baseUrl}/lightning/setup/SingleSignOn/home`;
|
|
10
|
+
// Enabled, disabled, or unknown. Only a boolean actually returned by the settings read
|
|
11
|
+
// decides; a failed read or an absent Metadata client leaves it unknown, never "disabled".
|
|
12
|
+
let delegatedAuth;
|
|
13
|
+
let gatewayUrl = '';
|
|
14
|
+
if (ctx.metadata) {
|
|
15
|
+
try {
|
|
16
|
+
const sec = await ctx.metadata.read('SecuritySettings', 'Security');
|
|
17
|
+
const sso = sec?.singleSignOnSettings;
|
|
18
|
+
if (typeof sso?.isDelegatedAuthEnabled === 'boolean') {
|
|
19
|
+
delegatedAuth = sso.isDelegatedAuthEnabled;
|
|
20
|
+
gatewayUrl = sso.delegatedGatewayUrl ?? '';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
delegatedAuth = undefined;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const isDelegatedAuthEnabled = delegatedAuth === true;
|
|
28
|
+
const profiles = await ctx.soql.queryAll('SELECT Id, Name, PermissionsIsSingleSignOnEnabled FROM Profile WHERE PermissionsIsSingleSignOnEnabled = true');
|
|
29
|
+
const adminProfilesWithDelegatedAuth = profiles.filter((p) => p.Name.toLowerCase().includes('admin') || p.Name === 'System Administrator');
|
|
30
|
+
if (isDelegatedAuthEnabled) {
|
|
31
|
+
// Check 1: Insecure Gateway URL (non-https or cleartext)
|
|
32
|
+
const isInsecure = !gatewayUrl ||
|
|
33
|
+
gatewayUrl.startsWith('http://') ||
|
|
34
|
+
(!gatewayUrl.startsWith('https://') && gatewayUrl.length > 0);
|
|
35
|
+
if (isInsecure) {
|
|
36
|
+
findings.push({
|
|
37
|
+
id: 'delegated-authentication-insecure-gateway',
|
|
38
|
+
category: this.category,
|
|
39
|
+
riskLevel: 'CRITICAL',
|
|
40
|
+
title: 'Delegated Authentication gateway is unencrypted or missing mutual TLS',
|
|
41
|
+
detail: `Delegated Authentication is enabled with gateway URL "${gatewayUrl || 'empty'}". Unlike SAML or OIDC, Delegated Authentication relies on a simple SOAP boolean response without cryptographic assertion signatures. Transmitting credentials over unencrypted or unauthenticated endpoints allows credential harvesting and spoofed responses.`,
|
|
42
|
+
remediation: 'Configure a secure HTTPS endpoint with mutual TLS (mTLS) client certificate verification for the Delegated Authentication gateway, or migrate to SAML 2.0 / OpenID Connect.',
|
|
43
|
+
affectedItems: [
|
|
44
|
+
{
|
|
45
|
+
label: 'Delegated Gateway Endpoint',
|
|
46
|
+
url: ssoUrl,
|
|
47
|
+
note: `Gateway URL: ${gatewayUrl || 'None configured'}`,
|
|
48
|
+
},
|
|
49
|
+
],
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
// Check 2: Assigned to System Administrators
|
|
53
|
+
if (adminProfilesWithDelegatedAuth.length > 0) {
|
|
54
|
+
findings.push({
|
|
55
|
+
id: 'delegated-authentication-admin-assigned',
|
|
56
|
+
category: this.category,
|
|
57
|
+
riskLevel: 'CRITICAL',
|
|
58
|
+
title: `Delegated Authentication is assigned to ${adminProfilesWithDelegatedAuth.length} Administrator profile(s)`,
|
|
59
|
+
detail: 'The "Is Single Sign-On Enabled" permission routes user authentication through the external delegated gateway. When assigned to System Administrators, compromising or spoofing the delegated gateway grants instantaneous full org takeover as an admin.',
|
|
60
|
+
remediation: 'Remove "Is Single Sign-On Enabled" from System Administrator and privileged profiles. Reserve Delegated Authentication strictly for standard users, or enforce SAML/OIDC.',
|
|
61
|
+
affectedItems: adminProfilesWithDelegatedAuth.map((p) => ({
|
|
62
|
+
label: p.Name,
|
|
63
|
+
url: `${baseUrl}/lightning/setup/EnhancedProfiles/page?address=%2F${p.Id}`,
|
|
64
|
+
note: 'Admin profile routes authentication through delegated gateway',
|
|
65
|
+
})),
|
|
66
|
+
});
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
if (delegatedAuth === undefined) {
|
|
70
|
+
findings.push({
|
|
71
|
+
id: 'delegated-authentication-advisory',
|
|
72
|
+
category: this.category,
|
|
73
|
+
riskLevel: 'INFO',
|
|
74
|
+
title: 'Verify Delegated Authentication settings manually',
|
|
75
|
+
detail: `This run could not read SecuritySettings, so whether Delegated Authentication is enabled is unknown. ${adminProfilesWithDelegatedAuth.length} administrator profile(s) hold "Is Single Sign-On Enabled", which routes their sign-in through the delegated gateway if it is on.`,
|
|
76
|
+
remediation: 'In Setup → Single Sign-On Settings, check whether Delegated Authentication is enabled. If it is, the gateway must be HTTPS with mutual TLS, and administrator profiles should not hold "Is Single Sign-On Enabled".',
|
|
77
|
+
affectedItems: [{ label: 'Single Sign-On Settings', url: ssoUrl }],
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
else if (findings.length === 0) {
|
|
81
|
+
findings.push({
|
|
82
|
+
id: 'delegated-authentication-exposure-ok',
|
|
83
|
+
category: this.category,
|
|
84
|
+
riskLevel: 'LOW',
|
|
85
|
+
passed: true,
|
|
86
|
+
title: isDelegatedAuthEnabled
|
|
87
|
+
? 'Delegated Authentication uses an HTTPS gateway and is not assigned to administrators'
|
|
88
|
+
: 'Delegated Authentication is disabled',
|
|
89
|
+
detail: isDelegatedAuthEnabled
|
|
90
|
+
? 'SecuritySettings shows Delegated Authentication enabled with an HTTPS gateway, and no administrator profile holds "Is Single Sign-On Enabled".'
|
|
91
|
+
: 'SecuritySettings confirms Delegated Authentication is disabled, so no sign-in is routed through an external gateway.',
|
|
92
|
+
remediation: 'Continue using SAML 2.0 or OpenID Connect with signed assertions for SSO.',
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
return { findings };
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=DelegatedAuthenticationExposureCheck.js.map
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AuditContext } from '@cclabsnz/sf-core';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
export declare class ExternalAccountHierarchyExposureCheck implements SecurityCheck {
|
|
4
|
+
readonly id = "external-account-hierarchy-exposure";
|
|
5
|
+
readonly name = "External Account Hierarchy & Partner Super User Exposure";
|
|
6
|
+
readonly category = "External-Facing Access";
|
|
7
|
+
readonly description = "Flags Partner Super User access and External Account Hierarchies that bypass external OWD and widen portal visibility.";
|
|
8
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=ExternalAccountHierarchyExposureCheck.d.ts.map
|