@cclabsnz/sf-audit 1.3.0 → 1.6.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/README.md +193 -12
- package/lib/api/MetadataClient.d.ts +4 -0
- package/lib/api/MetadataClient.js +2 -0
- package/lib/api/MetadataClientImpl.d.ts +8 -0
- package/lib/api/MetadataClientImpl.js +22 -0
- package/lib/api/RestClient.d.ts +2 -0
- package/lib/api/RestClientImpl.d.ts +2 -0
- package/lib/api/RestClientImpl.js +33 -0
- package/lib/apps/analyzeApps.d.ts +8 -0
- package/lib/apps/analyzeApps.js +19 -0
- package/lib/apps/appResolver.d.ts +4 -0
- package/lib/apps/appResolver.js +50 -0
- package/lib/apps/grantedAccess.d.ts +4 -0
- package/lib/apps/grantedAccess.js +36 -0
- package/lib/apps/leastPrivilege.d.ts +6 -0
- package/lib/apps/leastPrivilege.js +47 -0
- package/lib/apps/renderApps.d.ts +5 -0
- package/lib/apps/renderApps.js +23 -0
- package/lib/apps/standardAppCatalog.d.ts +11 -0
- package/lib/apps/standardAppCatalog.js +14 -0
- package/lib/apps/types.d.ts +64 -0
- package/lib/apps/types.js +2 -0
- package/lib/apps/usageCollector.d.ts +9 -0
- package/lib/apps/usageCollector.js +104 -0
- package/lib/chains/CapabilityRegistry.js +19 -0
- package/lib/chains/namedChains.js +67 -0
- package/lib/checks/eventLogAccess.d.ts +14 -0
- package/lib/checks/eventLogAccess.js +33 -0
- package/lib/checks/impl/AgentActionSurfaceCheck.d.ts +13 -0
- package/lib/checks/impl/AgentActionSurfaceCheck.js +125 -0
- package/lib/checks/impl/AgentChannelExposureCheck.d.ts +15 -0
- package/lib/checks/impl/AgentChannelExposureCheck.js +223 -0
- package/lib/checks/impl/AgentInventoryCheck.d.ts +15 -0
- package/lib/checks/impl/AgentInventoryCheck.js +228 -0
- package/lib/checks/impl/AgentMonitoringCoverageCheck.d.ts +12 -0
- package/lib/checks/impl/AgentMonitoringCoverageCheck.js +97 -0
- package/lib/checks/impl/AgentUserPrivilegeCheck.d.ts +13 -0
- package/lib/checks/impl/AgentUserPrivilegeCheck.js +204 -0
- package/lib/checks/impl/AuthProvidersCheck.d.ts +17 -0
- package/lib/checks/impl/AuthProvidersCheck.js +88 -0
- package/lib/checks/impl/ClassicSitesCheck.d.ts +17 -0
- package/lib/checks/impl/ClassicSitesCheck.js +65 -0
- package/lib/checks/impl/CspTrustedSitesCheck.d.ts +1 -0
- package/lib/checks/impl/CspTrustedSitesCheck.js +10 -1
- package/lib/checks/impl/DataExportAccessCheck.d.ts +19 -0
- package/lib/checks/impl/DataExportAccessCheck.js +79 -0
- package/lib/checks/impl/EncryptionCoverageCheck.d.ts +19 -0
- package/lib/checks/impl/EncryptionCoverageCheck.js +108 -0
- package/lib/checks/impl/EventMonitoringCheck.js +8 -5
- package/lib/checks/impl/ExperienceCspCheck.d.ts +18 -0
- package/lib/checks/impl/ExperienceCspCheck.js +57 -0
- package/lib/checks/impl/ExternalCredentialsCheck.d.ts +17 -0
- package/lib/checks/impl/ExternalCredentialsCheck.js +74 -0
- package/lib/checks/impl/GuestApiAccessCheck.d.ts +19 -0
- package/lib/checks/impl/GuestApiAccessCheck.js +113 -0
- package/lib/checks/impl/GuestObjectExposureCheck.d.ts +44 -0
- package/lib/checks/impl/GuestObjectExposureCheck.js +241 -0
- package/lib/checks/impl/GuestRecordAccessPolicyCheck.d.ts +34 -0
- package/lib/checks/impl/GuestRecordAccessPolicyCheck.js +120 -0
- package/lib/checks/impl/GuestSiteOptionsCheck.d.ts +18 -0
- package/lib/checks/impl/GuestSiteOptionsCheck.js +92 -0
- package/lib/checks/impl/GuestTrafficAnomalyCheck.d.ts +23 -0
- package/lib/checks/impl/GuestTrafficAnomalyCheck.js +343 -0
- package/lib/checks/impl/LoginAccessPolicyCheck.d.ts +26 -0
- package/lib/checks/impl/LoginAccessPolicyCheck.js +117 -0
- package/lib/checks/impl/LoginAnomalyCheck.d.ts +17 -0
- package/lib/checks/impl/LoginAnomalyCheck.js +98 -0
- package/lib/checks/impl/SandboxDataMaskingCheck.d.ts +17 -0
- package/lib/checks/impl/SandboxDataMaskingCheck.js +85 -0
- package/lib/checks/impl/SessionHardeningCheck.d.ts +21 -0
- package/lib/checks/impl/SessionHardeningCheck.js +134 -0
- package/lib/checks/impl/ThreatDetectionCheck.d.ts +17 -0
- package/lib/checks/impl/ThreatDetectionCheck.js +91 -0
- package/lib/checks/impl/TrustedUrlHygieneCheck.d.ts +16 -0
- package/lib/checks/impl/TrustedUrlHygieneCheck.js +198 -0
- package/lib/checks/registry.js +52 -0
- package/lib/commands/audit/apps.d.ts +16 -0
- package/lib/commands/audit/apps.js +64 -0
- package/lib/commands/audit/diff.js +9 -5
- package/lib/commands/audit/events/pull.d.ts +17 -0
- package/lib/commands/audit/events/pull.js +88 -0
- package/lib/commands/audit/security.d.ts +5 -0
- package/lib/commands/audit/security.js +47 -17
- package/lib/compliance/catalogs/index.js +2 -0
- package/lib/compliance/catalogs/owaspLlm.d.ts +3 -0
- package/lib/compliance/catalogs/owaspLlm.js +34 -0
- package/lib/compliance/mapping.js +46 -7
- package/lib/compliance/resolve.js +4 -3
- package/lib/compliance/types.d.ts +1 -1
- package/lib/context/AuditCache.d.ts +31 -0
- package/lib/context/AuditContext.d.ts +6 -0
- package/lib/events/EventBaselineStore.d.ts +16 -0
- package/lib/events/EventBaselineStore.js +55 -0
- package/lib/events/eventLogQuery.d.ts +21 -0
- package/lib/events/eventLogQuery.js +34 -0
- package/lib/events/pullEventLogs.d.ts +51 -0
- package/lib/events/pullEventLogs.js +79 -0
- package/lib/findings/CheckMeta.js +22 -0
- package/lib/lib/wire.d.ts +4 -2
- package/lib/lib/wire.js +5 -1
- package/lib/renderers/ClientReportRenderer.js +1 -1
- package/package.json +16 -2
|
@@ -0,0 +1,204 @@
|
|
|
1
|
+
// An agent user's write access is "broad" when it can create/update/delete on more than
|
|
2
|
+
// this many objects. Chosen to match DataClassificationCheck's small-key-object set size
|
|
3
|
+
// (7 key objects) with headroom: a legitimate task-scoped agent user should touch only a
|
|
4
|
+
// handful of objects, so >10 is a signal of over-provisioning.
|
|
5
|
+
const BROAD_WRITE_OBJECT_THRESHOLD = 10;
|
|
6
|
+
export class AgentUserPrivilegeCheck {
|
|
7
|
+
id = 'agent-user-privilege';
|
|
8
|
+
name = 'Agent User Privilege';
|
|
9
|
+
category = 'AI & Agents';
|
|
10
|
+
description = 'Flags Agentforce run-as / agent users whose effective access is over-broad: Modify/View All Data, write access to many objects, or read access to data classified as sensitive. An injected prompt can exfiltrate or mutate exactly what the agent user can reach.';
|
|
11
|
+
dependsOnCache = ['agentUsers', 'agentAccess'];
|
|
12
|
+
async run(ctx) {
|
|
13
|
+
const findings = [];
|
|
14
|
+
// Gate: only run when AgentInventoryCheck confirmed the agent queries succeeded.
|
|
15
|
+
if (ctx.cache.agentAccess !== 'ok')
|
|
16
|
+
return { findings };
|
|
17
|
+
const agentUsers = ctx.cache.agentUsers ?? [];
|
|
18
|
+
if (agentUsers.length === 0)
|
|
19
|
+
return { findings };
|
|
20
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
21
|
+
const setupUrl = `${baseUrl}/lightning/setup/PermSets/home`;
|
|
22
|
+
// Collect every permission set assigned to any agent user, then query the two
|
|
23
|
+
// permission surfaces once for the whole set (not per user).
|
|
24
|
+
const allPsIds = [...new Set(agentUsers.flatMap((u) => u.permissionSetIds))];
|
|
25
|
+
if (allPsIds.length === 0)
|
|
26
|
+
return { findings };
|
|
27
|
+
const psIn = allPsIds.map((id) => `'${id}'`).join(', ');
|
|
28
|
+
// System permissions (ModifyAllData / ViewAllData) per permission set.
|
|
29
|
+
let systemPerms;
|
|
30
|
+
try {
|
|
31
|
+
systemPerms = await ctx.soql.queryAll(`SELECT Id, Label, PermissionsModifyAllData, PermissionsViewAllData
|
|
32
|
+
FROM PermissionSet
|
|
33
|
+
WHERE Id IN (${psIn})`);
|
|
34
|
+
}
|
|
35
|
+
catch (err) {
|
|
36
|
+
findings.push({
|
|
37
|
+
id: 'agent-user-privilege-inconclusive',
|
|
38
|
+
category: this.category,
|
|
39
|
+
riskLevel: 'INFO',
|
|
40
|
+
inconclusive: true,
|
|
41
|
+
title: 'Agent user permissions could not be resolved',
|
|
42
|
+
detail: `The PermissionSet query for agent users was not accessible: ${err instanceof Error ? err.message : String(err)}`,
|
|
43
|
+
remediation: 'Grant the audit user "View Setup and Configuration", then re-run the audit.',
|
|
44
|
+
});
|
|
45
|
+
return { findings };
|
|
46
|
+
}
|
|
47
|
+
// Object-level CRUD per permission set. A failure here is non-fatal — we still report
|
|
48
|
+
// the system-permission findings.
|
|
49
|
+
let objectPerms = [];
|
|
50
|
+
let objectPermsFailed = false;
|
|
51
|
+
try {
|
|
52
|
+
objectPerms = await ctx.soql.queryAll(`SELECT ParentId, SobjectType, PermissionsRead, PermissionsCreate, PermissionsEdit, PermissionsDelete
|
|
53
|
+
FROM ObjectPermissions
|
|
54
|
+
WHERE ParentId IN (${psIn})`);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
objectPermsFailed = true;
|
|
58
|
+
}
|
|
59
|
+
// Sensitive objects = objects with at least one classified field (ComplianceGroup set).
|
|
60
|
+
// Query once for every readable object across the agent users; skip the sub-signal
|
|
61
|
+
// silently if the org has no classification data or the Tooling query is unavailable.
|
|
62
|
+
const readableObjects = [
|
|
63
|
+
...new Set(objectPerms.filter((p) => p.PermissionsRead).map((p) => p.SobjectType)),
|
|
64
|
+
];
|
|
65
|
+
const sensitiveObjects = await this.querySensitiveObjects(ctx, readableObjects);
|
|
66
|
+
// Index permission-set metadata by id for per-user attribution.
|
|
67
|
+
const psById = new Map(systemPerms.map((p) => [p.Id, p]));
|
|
68
|
+
const objPermsByPs = new Map();
|
|
69
|
+
for (const op of objectPerms) {
|
|
70
|
+
const list = objPermsByPs.get(op.ParentId) ?? [];
|
|
71
|
+
list.push(op);
|
|
72
|
+
objPermsByPs.set(op.ParentId, list);
|
|
73
|
+
}
|
|
74
|
+
for (const u of agentUsers) {
|
|
75
|
+
this.evaluateUser(u, psById, objPermsByPs, sensitiveObjects, {
|
|
76
|
+
findings,
|
|
77
|
+
setupUrl,
|
|
78
|
+
objectPermsFailed,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
return { findings };
|
|
82
|
+
}
|
|
83
|
+
evaluateUser(u, psById, objPermsByPs, sensitiveObjects, out) {
|
|
84
|
+
const { findings, setupUrl } = out;
|
|
85
|
+
// Which of the user's permission sets grant ModifyAllData / ViewAllData.
|
|
86
|
+
const adminPsLabels = [];
|
|
87
|
+
let hasModifyAll = false;
|
|
88
|
+
let hasViewAll = false;
|
|
89
|
+
for (const psId of u.permissionSetIds) {
|
|
90
|
+
const ps = psById.get(psId);
|
|
91
|
+
if (!ps)
|
|
92
|
+
continue;
|
|
93
|
+
if (ps.PermissionsModifyAllData) {
|
|
94
|
+
hasModifyAll = true;
|
|
95
|
+
adminPsLabels.push(`${ps.Label} (Modify All Data)`);
|
|
96
|
+
}
|
|
97
|
+
else if (ps.PermissionsViewAllData) {
|
|
98
|
+
hasViewAll = true;
|
|
99
|
+
adminPsLabels.push(`${ps.Label} (View All Data)`);
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
if (hasModifyAll || hasViewAll) {
|
|
103
|
+
const which = hasModifyAll ? 'Modify All Data' : 'View All Data';
|
|
104
|
+
findings.push({
|
|
105
|
+
id: `agent-user-privilege-admin-${u.userId}`,
|
|
106
|
+
category: this.category,
|
|
107
|
+
riskLevel: 'CRITICAL',
|
|
108
|
+
title: `Agent user ${u.username} holds ${which}`,
|
|
109
|
+
detail: `The agent user "${u.username}" (profile ${u.profileName || 'unknown'}) effectively holds ` +
|
|
110
|
+
`${which}, which bypasses sharing across the entire org. Because an Agentforce agent runs as ` +
|
|
111
|
+
`this user, a successful prompt injection inherits ${which.toLowerCase()}: it can ` +
|
|
112
|
+
`${hasModifyAll ? 'read, edit, and delete' : 'read'} every record in the org. This is the ` +
|
|
113
|
+
`worst-case blast radius for an exposed agent.`,
|
|
114
|
+
remediation: `Remove ${which} from the offending permission set(s) unless the agent genuinely requires ` +
|
|
115
|
+
`org-wide access. Scope the agent user to only the objects and records its topics need.`,
|
|
116
|
+
affectedItems: [
|
|
117
|
+
{
|
|
118
|
+
label: u.username,
|
|
119
|
+
url: setupUrl,
|
|
120
|
+
note: `Permission set(s): ${adminPsLabels.join(', ')}`,
|
|
121
|
+
},
|
|
122
|
+
],
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
// Broad object write access: union of objects this user can create/update/delete across
|
|
126
|
+
// all of their permission sets.
|
|
127
|
+
const writableObjects = new Set();
|
|
128
|
+
const readableObjects = new Set();
|
|
129
|
+
for (const psId of u.permissionSetIds) {
|
|
130
|
+
for (const op of objPermsByPs.get(psId) ?? []) {
|
|
131
|
+
if (op.PermissionsCreate || op.PermissionsEdit || op.PermissionsDelete) {
|
|
132
|
+
writableObjects.add(op.SobjectType);
|
|
133
|
+
}
|
|
134
|
+
if (op.PermissionsRead)
|
|
135
|
+
readableObjects.add(op.SobjectType);
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
if (writableObjects.size > BROAD_WRITE_OBJECT_THRESHOLD) {
|
|
139
|
+
const objList = [...writableObjects].sort();
|
|
140
|
+
findings.push({
|
|
141
|
+
id: `agent-user-privilege-broad-write-${u.userId}`,
|
|
142
|
+
category: this.category,
|
|
143
|
+
riskLevel: 'HIGH',
|
|
144
|
+
title: `Agent user ${u.username} has write access to ${writableObjects.size} objects`,
|
|
145
|
+
detail: `The agent user "${u.username}" can create, update, or delete records on ${writableObjects.size} ` +
|
|
146
|
+
`objects (threshold ${BROAD_WRITE_OBJECT_THRESHOLD}). An injected prompt runs with this write ` +
|
|
147
|
+
`surface, so it could mutate or destroy data across all of them. Objects: ` +
|
|
148
|
+
`${objList.slice(0, 20).join(', ')}${objList.length > 20 ? `, and ${objList.length - 20} more` : ''}.`,
|
|
149
|
+
remediation: 'Narrow the agent user\'s object CRUD to only the objects its topics act on. Prefer read-only access ' +
|
|
150
|
+
'where the agent only needs to answer questions, and move write actions behind explicit, reviewed Apex/Flow.',
|
|
151
|
+
affectedItems: [
|
|
152
|
+
{
|
|
153
|
+
label: u.username,
|
|
154
|
+
url: setupUrl,
|
|
155
|
+
note: `${writableObjects.size} writable object(s) via permission set(s): ${u.permissionSetIds.join(', ')}`,
|
|
156
|
+
},
|
|
157
|
+
],
|
|
158
|
+
});
|
|
159
|
+
}
|
|
160
|
+
// Read access to sensitive/classified objects. Silent when the org has no classification
|
|
161
|
+
// data (sensitiveObjects is empty).
|
|
162
|
+
const sensitiveReadable = [...readableObjects].filter((o) => sensitiveObjects.has(o)).sort();
|
|
163
|
+
if (sensitiveReadable.length > 0) {
|
|
164
|
+
findings.push({
|
|
165
|
+
id: `agent-user-privilege-sensitive-read-${u.userId}`,
|
|
166
|
+
category: this.category,
|
|
167
|
+
riskLevel: 'HIGH',
|
|
168
|
+
title: `Agent user ${u.username} can read ${sensitiveReadable.length} object(s) classified as sensitive`,
|
|
169
|
+
detail: `The agent user "${u.username}" has read access to ${sensitiveReadable.length} object(s) that carry ` +
|
|
170
|
+
`Data Classification / Compliance Group markings (PII, PCI, HIPAA, GDPR, etc.): ` +
|
|
171
|
+
`${sensitiveReadable.join(', ')}. An injected prompt can exfiltrate exactly this classified data ` +
|
|
172
|
+
`through whatever channel the agent is exposed on.`,
|
|
173
|
+
remediation: 'Confirm the agent legitimately needs to read these sensitive objects. If not, remove read access. ' +
|
|
174
|
+
'Where it is required, ensure the agent\'s output channels are internal-only and monitored.',
|
|
175
|
+
affectedItems: sensitiveReadable.map((o) => ({
|
|
176
|
+
label: o,
|
|
177
|
+
note: 'read access, object has classified (sensitive) fields',
|
|
178
|
+
})),
|
|
179
|
+
});
|
|
180
|
+
}
|
|
181
|
+
}
|
|
182
|
+
// Objects that have at least one classified field. Reuses DataClassificationCheck's
|
|
183
|
+
// FieldDefinition/ComplianceGroup query, scoped to the objects the agent users can read.
|
|
184
|
+
// Returns an empty set (sub-signal silently skipped) if there is no classification data
|
|
185
|
+
// or the Tooling query is unavailable.
|
|
186
|
+
async querySensitiveObjects(ctx, readableObjects) {
|
|
187
|
+
if (readableObjects.length === 0)
|
|
188
|
+
return new Set();
|
|
189
|
+
const objList = readableObjects.map((o) => `'${o}'`).join(', ');
|
|
190
|
+
try {
|
|
191
|
+
const rows = await ctx.tooling.query(`SELECT EntityDefinition.QualifiedApiName objectName, COUNT(Id) classifiedCount
|
|
192
|
+
FROM FieldDefinition
|
|
193
|
+
WHERE EntityDefinition.QualifiedApiName IN (${objList})
|
|
194
|
+
AND ComplianceGroup != null
|
|
195
|
+
GROUP BY EntityDefinition.QualifiedApiName`);
|
|
196
|
+
return new Set(rows.filter((r) => (r.classifiedCount ?? 0) > 0).map((r) => r.objectName));
|
|
197
|
+
}
|
|
198
|
+
catch {
|
|
199
|
+
// No classification feature / no Tooling access: skip the sub-signal silently.
|
|
200
|
+
return new Set();
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
//# sourceMappingURL=AgentUserPrivilegeCheck.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AuditContext } from '../../context/AuditContext.js';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
/**
|
|
4
|
+
* Reviews external identity federation — Auth Providers and SAML SSO configs.
|
|
5
|
+
* Every configured provider is a way into the org that does not use a Salesforce
|
|
6
|
+
* password, so an unvetted or misconfigured provider (especially social login with
|
|
7
|
+
* just-in-time user creation) can let attackers federate in or auto-provision
|
|
8
|
+
* over-privileged users.
|
|
9
|
+
*/
|
|
10
|
+
export declare class AuthProvidersCheck implements SecurityCheck {
|
|
11
|
+
readonly id = "auth-providers";
|
|
12
|
+
readonly name = "Auth Providers & External IdPs";
|
|
13
|
+
readonly category = "Authentication";
|
|
14
|
+
readonly description = "Reviews configured Auth Providers and SAML SSO configurations \u2014 external login paths that bypass Salesforce credentials and can auto-provision users";
|
|
15
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=AuthProvidersCheck.d.ts.map
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
// Consumer/social identity providers — higher risk when they can create users
|
|
2
|
+
// via just-in-time provisioning, because an attacker-controlled account at the
|
|
3
|
+
// provider becomes an org login.
|
|
4
|
+
const SOCIAL_TYPES = new Set(['Facebook', 'Google', 'Twitter', 'LinkedIn', 'GitHub', 'OpenIdConnect']);
|
|
5
|
+
/**
|
|
6
|
+
* Reviews external identity federation — Auth Providers and SAML SSO configs.
|
|
7
|
+
* Every configured provider is a way into the org that does not use a Salesforce
|
|
8
|
+
* password, so an unvetted or misconfigured provider (especially social login with
|
|
9
|
+
* just-in-time user creation) can let attackers federate in or auto-provision
|
|
10
|
+
* over-privileged users.
|
|
11
|
+
*/
|
|
12
|
+
export class AuthProvidersCheck {
|
|
13
|
+
id = 'auth-providers';
|
|
14
|
+
name = 'Auth Providers & External IdPs';
|
|
15
|
+
category = 'Authentication';
|
|
16
|
+
description = 'Reviews configured Auth Providers and SAML SSO configurations — external login paths that bypass Salesforce credentials and can auto-provision users';
|
|
17
|
+
async run(ctx) {
|
|
18
|
+
const findings = [];
|
|
19
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
20
|
+
let providers = [];
|
|
21
|
+
let providersFailed = false;
|
|
22
|
+
try {
|
|
23
|
+
providers = await ctx.soql.queryAll('SELECT Id, DeveloperName, ProviderType, FriendlyName FROM AuthProvider');
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
providersFailed = true;
|
|
27
|
+
}
|
|
28
|
+
let saml = [];
|
|
29
|
+
try {
|
|
30
|
+
saml = await ctx.soql.queryAll('SELECT Id, DeveloperName, Issuer FROM SamlSsoConfig');
|
|
31
|
+
}
|
|
32
|
+
catch {
|
|
33
|
+
// SAML config not accessible / not configured — handled together with providers below.
|
|
34
|
+
}
|
|
35
|
+
if (providersFailed) {
|
|
36
|
+
findings.push({
|
|
37
|
+
id: 'auth-providers-inconclusive',
|
|
38
|
+
category: this.category,
|
|
39
|
+
riskLevel: 'INFO',
|
|
40
|
+
inconclusive: true,
|
|
41
|
+
title: 'Auth Providers could not be queried (insufficient access)',
|
|
42
|
+
detail: 'The AuthProvider object was not accessible, so external identity federation could not be evaluated.',
|
|
43
|
+
remediation: 'Grant the audit user View Setup and Configuration and re-run. Also review Setup → Auth. Providers and Single Sign-On Settings manually.',
|
|
44
|
+
});
|
|
45
|
+
return { findings };
|
|
46
|
+
}
|
|
47
|
+
const social = providers.filter((p) => SOCIAL_TYPES.has(p.ProviderType));
|
|
48
|
+
if (social.length > 0) {
|
|
49
|
+
findings.push({
|
|
50
|
+
id: 'auth-providers-social',
|
|
51
|
+
category: this.category,
|
|
52
|
+
riskLevel: 'MEDIUM',
|
|
53
|
+
title: `${social.length} social/consumer Auth Provider(s) configured`,
|
|
54
|
+
detail: 'Social and OpenID Connect auth providers let users authenticate with external consumer identities. If the registration handler provisions users just-in-time, an attacker who controls (or creates) an account at the provider may obtain an org login — potentially with a default profile that is more privileged than intended.',
|
|
55
|
+
remediation: 'Confirm each social provider is intentional, review its Apex registration handler for least-privilege user creation (and that it does not auto-activate high-privilege profiles), and disable providers that are not required.',
|
|
56
|
+
affectedItems: social.map((p) => ({ label: `${p.FriendlyName ?? p.DeveloperName} (${p.ProviderType})`, url: `${baseUrl}/lightning/setup/AuthProviders/home` })),
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
const nonSocial = providers.filter((p) => !SOCIAL_TYPES.has(p.ProviderType));
|
|
60
|
+
if (nonSocial.length > 0 || saml.length > 0) {
|
|
61
|
+
findings.push({
|
|
62
|
+
id: 'auth-providers-inventory',
|
|
63
|
+
category: this.category,
|
|
64
|
+
riskLevel: 'INFO',
|
|
65
|
+
title: `${nonSocial.length} other Auth Provider(s) and ${saml.length} SAML SSO config(s) configured`,
|
|
66
|
+
detail: 'These external identity paths let users sign in without a Salesforce password. Each SAML config and enterprise auth provider should be a known, trusted IdP with certificate validation and no stale/duplicate entries.',
|
|
67
|
+
remediation: 'Review each SAML SSO config (Issuer, signing certificate, and that "Just-in-time provisioning" creates least-privilege users) and each auth provider. Remove any that are unused or unrecognised.',
|
|
68
|
+
affectedItems: [
|
|
69
|
+
...nonSocial.map((p) => ({ label: `Auth Provider: ${p.FriendlyName ?? p.DeveloperName} (${p.ProviderType})`, url: `${baseUrl}/lightning/setup/AuthProviders/home` })),
|
|
70
|
+
...saml.map((s) => ({ label: `SAML: ${s.DeveloperName}${s.Issuer ? ` (${s.Issuer})` : ''}`, url: `${baseUrl}/lightning/setup/SingleSignOn/home` })),
|
|
71
|
+
].slice(0, 40),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (providers.length === 0 && saml.length === 0) {
|
|
75
|
+
findings.push({
|
|
76
|
+
id: 'auth-providers-none',
|
|
77
|
+
category: this.category,
|
|
78
|
+
riskLevel: 'LOW',
|
|
79
|
+
passed: true,
|
|
80
|
+
title: 'No external Auth Providers or SAML SSO configured',
|
|
81
|
+
detail: 'No AuthProvider or SamlSsoConfig records exist, so there is no external federation surface to review.',
|
|
82
|
+
remediation: 'If external identity is added later, restrict just-in-time provisioning to least-privilege profiles and validate the IdP certificate.',
|
|
83
|
+
});
|
|
84
|
+
}
|
|
85
|
+
return { findings };
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
//# sourceMappingURL=AuthProvidersCheck.js.map
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AuditContext } from '../../context/AuditContext.js';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
/**
|
|
4
|
+
* Audits classic Force.com Sites (Visualforce sites), a public unauthenticated
|
|
5
|
+
* surface that runs in PARALLEL to Experience Cloud and is missed by the
|
|
6
|
+
* Network-based guest checks. Each active classic site has its own guest user
|
|
7
|
+
* whose profile can expose Apex, Visualforce pages, and objects to anonymous
|
|
8
|
+
* visitors (the vector behind classic `/apex/…` public pages).
|
|
9
|
+
*/
|
|
10
|
+
export declare class ClassicSitesCheck implements SecurityCheck {
|
|
11
|
+
readonly id = "classic-sites";
|
|
12
|
+
readonly name = "Classic Force.com Sites";
|
|
13
|
+
readonly category = "Access Control";
|
|
14
|
+
readonly description = "Flags active classic (Visualforce) Force.com Sites and their guest users \u2014 an unauthenticated public surface separate from Experience Cloud";
|
|
15
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ClassicSitesCheck.d.ts.map
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// Classic (non-Experience-Builder) public site types. Siteforce = Experience
|
|
2
|
+
// Builder sites, which the Network-based guest checks already cover.
|
|
3
|
+
const CLASSIC_TYPES = new Set(['Visualforce', 'ChatterNetworkPicasso']);
|
|
4
|
+
/**
|
|
5
|
+
* Audits classic Force.com Sites (Visualforce sites), a public unauthenticated
|
|
6
|
+
* surface that runs in PARALLEL to Experience Cloud and is missed by the
|
|
7
|
+
* Network-based guest checks. Each active classic site has its own guest user
|
|
8
|
+
* whose profile can expose Apex, Visualforce pages, and objects to anonymous
|
|
9
|
+
* visitors (the vector behind classic `/apex/…` public pages).
|
|
10
|
+
*/
|
|
11
|
+
export class ClassicSitesCheck {
|
|
12
|
+
id = 'classic-sites';
|
|
13
|
+
name = 'Classic Force.com Sites';
|
|
14
|
+
category = 'Access Control';
|
|
15
|
+
description = 'Flags active classic (Visualforce) Force.com Sites and their guest users — an unauthenticated public surface separate from Experience Cloud';
|
|
16
|
+
async run(ctx) {
|
|
17
|
+
const findings = [];
|
|
18
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
19
|
+
let sites;
|
|
20
|
+
try {
|
|
21
|
+
sites = await ctx.soql.queryAll('SELECT Id, Name, Status, SiteType, GuestUserId, MasterLabel FROM Site');
|
|
22
|
+
}
|
|
23
|
+
catch {
|
|
24
|
+
findings.push({
|
|
25
|
+
id: 'classic-sites-inconclusive',
|
|
26
|
+
category: this.category,
|
|
27
|
+
riskLevel: 'INFO',
|
|
28
|
+
inconclusive: true,
|
|
29
|
+
title: 'Force.com Sites could not be queried (insufficient access)',
|
|
30
|
+
detail: 'The Site object was not accessible, so classic public sites could not be evaluated. This may mean Sites is not enabled.',
|
|
31
|
+
remediation: 'Grant the audit user View Setup and Configuration and re-run. If Sites is not used, this check is not applicable.',
|
|
32
|
+
});
|
|
33
|
+
return { findings };
|
|
34
|
+
}
|
|
35
|
+
const classicActive = sites.filter((s) => CLASSIC_TYPES.has(s.SiteType) && s.Status === 'Active');
|
|
36
|
+
if (classicActive.length > 0) {
|
|
37
|
+
const withGuest = classicActive.filter((s) => s.GuestUserId);
|
|
38
|
+
findings.push({
|
|
39
|
+
id: 'classic-sites-active',
|
|
40
|
+
category: this.category,
|
|
41
|
+
riskLevel: 'HIGH',
|
|
42
|
+
title: `${classicActive.length} active classic (Visualforce) Force.com site(s)`,
|
|
43
|
+
detail: `Classic Force.com Sites serve pages to unauthenticated visitors through a dedicated guest user, separate from Experience Cloud. ${withGuest.length} of these have a guest user whose profile governs anonymous access to Apex, Visualforce pages, and objects. This surface is easy to forget because the guest/Experience-Cloud checks only inspect Experience (Network) sites.`,
|
|
44
|
+
remediation: 'For each active classic site, review the guest user profile (object/field permissions, guest-executable Apex, exposed VF pages) exactly as for Experience Cloud guests. Deactivate sites that are no longer needed. Re-run guest-object-exposure/guest-executable-apex to grade the exposure of these guest users.',
|
|
45
|
+
affectedItems: classicActive.slice(0, 30).map((s) => ({
|
|
46
|
+
label: `${s.MasterLabel ?? s.Name} (${s.SiteType}${s.GuestUserId ? ', guest user present' : ', no guest user'})`,
|
|
47
|
+
url: `${baseUrl}/lightning/setup/CustomDomains/home`,
|
|
48
|
+
})),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
else {
|
|
52
|
+
findings.push({
|
|
53
|
+
id: 'classic-sites-ok',
|
|
54
|
+
category: this.category,
|
|
55
|
+
riskLevel: 'LOW',
|
|
56
|
+
passed: true,
|
|
57
|
+
title: 'No active classic Force.com sites',
|
|
58
|
+
detail: 'No active Visualforce Force.com Sites were found, so there is no classic unauthenticated site surface.',
|
|
59
|
+
remediation: 'If a classic site is activated later, review its guest user profile before it goes live.',
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
return { findings };
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
//# sourceMappingURL=ClassicSitesCheck.js.map
|
|
@@ -5,6 +5,7 @@ export declare class CspTrustedSitesCheck implements SecurityCheck {
|
|
|
5
5
|
readonly name = "CSP Trusted Sites";
|
|
6
6
|
readonly category = "Network Security";
|
|
7
7
|
readonly description = "Checks Content Security Policy trusted sites for insecure HTTP endpoints that allow mixed-content loading.";
|
|
8
|
+
readonly populatesCache: readonly ["cspTrustedSites"];
|
|
8
9
|
run(ctx: AuditContext): Promise<CheckResult>;
|
|
9
10
|
}
|
|
10
11
|
//# sourceMappingURL=CspTrustedSitesCheck.d.ts.map
|
|
@@ -3,8 +3,17 @@ export class CspTrustedSitesCheck {
|
|
|
3
3
|
name = 'CSP Trusted Sites';
|
|
4
4
|
category = 'Network Security';
|
|
5
5
|
description = 'Checks Content Security Policy trusted sites for insecure HTTP endpoints that allow mixed-content loading.';
|
|
6
|
+
// Shares the fetched trusted-sites allowlist with TrustedUrlHygieneCheck (AI & Agents)
|
|
7
|
+
// so it does not re-query CspTrustedSite. Findings/behavior are unchanged by this.
|
|
8
|
+
populatesCache = ['cspTrustedSites'];
|
|
6
9
|
async run(ctx) {
|
|
7
|
-
const sites = await ctx.soql.queryAll(`SELECT Id, EndpointUrl, Context, IsActive FROM CspTrustedSite WHERE IsActive = true`);
|
|
10
|
+
const sites = await ctx.soql.queryAll(`SELECT Id, DeveloperName, EndpointUrl, Context, IsActive FROM CspTrustedSite WHERE IsActive = true`);
|
|
11
|
+
ctx.cache.cspTrustedSites = sites.map((s) => ({
|
|
12
|
+
developerName: s.DeveloperName ?? '',
|
|
13
|
+
endpointUrl: s.EndpointUrl,
|
|
14
|
+
isActive: s.IsActive,
|
|
15
|
+
context: s.Context,
|
|
16
|
+
}));
|
|
8
17
|
if (sites.length === 0) {
|
|
9
18
|
return {
|
|
10
19
|
findings: [{
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AuditContext } from '../../context/AuditContext.js';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
/**
|
|
4
|
+
* Finds the profiles / permission sets that grant a bulk data-extraction
|
|
5
|
+
* capability — the mechanisms an attacker (or a departing insider) uses to
|
|
6
|
+
* exfiltrate en masse, which the report/sharing checks do not cover:
|
|
7
|
+
* - "Weekly Data Export" (PermissionsDataExport): full-org CSV export.
|
|
8
|
+
* - "API Enabled" combined with View/Modify All Data: unrestricted Bulk/REST pull
|
|
9
|
+
* of every record.
|
|
10
|
+
* The toxic combination (export or API + ViewAll) is graded highest.
|
|
11
|
+
*/
|
|
12
|
+
export declare class DataExportAccessCheck implements SecurityCheck {
|
|
13
|
+
readonly id = "data-export-access";
|
|
14
|
+
readonly name = "Mass Data Export Access";
|
|
15
|
+
readonly category = "Data Access Control";
|
|
16
|
+
readonly description = "Flags profiles/permission sets granting Weekly Data Export or API access combined with View/Modify All Data \u2014 the bulk data-exfiltration capability";
|
|
17
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=DataExportAccessCheck.d.ts.map
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Finds the profiles / permission sets that grant a bulk data-extraction
|
|
3
|
+
* capability — the mechanisms an attacker (or a departing insider) uses to
|
|
4
|
+
* exfiltrate en masse, which the report/sharing checks do not cover:
|
|
5
|
+
* - "Weekly Data Export" (PermissionsDataExport): full-org CSV export.
|
|
6
|
+
* - "API Enabled" combined with View/Modify All Data: unrestricted Bulk/REST pull
|
|
7
|
+
* of every record.
|
|
8
|
+
* The toxic combination (export or API + ViewAll) is graded highest.
|
|
9
|
+
*/
|
|
10
|
+
export class DataExportAccessCheck {
|
|
11
|
+
id = 'data-export-access';
|
|
12
|
+
name = 'Mass Data Export Access';
|
|
13
|
+
category = 'Data Access Control';
|
|
14
|
+
description = 'Flags profiles/permission sets granting Weekly Data Export or API access combined with View/Modify All Data — the bulk data-exfiltration capability';
|
|
15
|
+
async run(ctx) {
|
|
16
|
+
const findings = [];
|
|
17
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
18
|
+
let rows;
|
|
19
|
+
try {
|
|
20
|
+
rows = await ctx.soql.queryAll(`SELECT Id, Label, Type, Profile.Name, PermissionsDataExport, PermissionsApiEnabled,
|
|
21
|
+
PermissionsViewAllData, PermissionsModifyAllData
|
|
22
|
+
FROM PermissionSet
|
|
23
|
+
WHERE PermissionsDataExport = true OR (PermissionsApiEnabled = true AND (PermissionsViewAllData = true OR PermissionsModifyAllData = true))`);
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
findings.push({
|
|
27
|
+
id: 'data-export-access-inconclusive',
|
|
28
|
+
category: this.category,
|
|
29
|
+
riskLevel: 'INFO',
|
|
30
|
+
inconclusive: true,
|
|
31
|
+
title: 'Data-export permissions could not be queried (insufficient access)',
|
|
32
|
+
detail: 'PermissionSet was not accessible, so mass-export capability could not be evaluated.',
|
|
33
|
+
remediation: 'Grant the audit user access to PermissionSet (View Setup and Configuration) and re-run.',
|
|
34
|
+
});
|
|
35
|
+
return { findings };
|
|
36
|
+
}
|
|
37
|
+
const label = (r) => (r.Type === 'Profile' && r.Profile ? `Profile: ${r.Profile.Name}` : `Permission Set: ${r.Label}`);
|
|
38
|
+
const exportGrants = rows.filter((r) => r.PermissionsDataExport);
|
|
39
|
+
const bulkApiGrants = rows.filter((r) => r.PermissionsApiEnabled && (r.PermissionsViewAllData || r.PermissionsModifyAllData));
|
|
40
|
+
if (exportGrants.length > 0) {
|
|
41
|
+
findings.push({
|
|
42
|
+
id: 'data-export-weekly-export',
|
|
43
|
+
category: this.category,
|
|
44
|
+
riskLevel: 'HIGH',
|
|
45
|
+
title: `${exportGrants.length} profile(s)/permission set(s) grant "Weekly Data Export"`,
|
|
46
|
+
detail: 'The "Weekly Data Export" permission lets the holder export the entire org to CSV on demand. Granted beyond a small set of trusted administrators, it is a one-click mass-exfiltration capability with no per-object gating.',
|
|
47
|
+
remediation: 'Remove "Weekly Data Export" from all but a minimal set of named administrators. Prefer a monitored, purpose-built integration for scheduled extracts, and alert on Data Export events via Event Monitoring.',
|
|
48
|
+
affectedItems: exportGrants.slice(0, 40).map((r) => ({ label: label(r), url: `${baseUrl}/lightning/setup/PermSets/home` })),
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
if (bulkApiGrants.length > 0) {
|
|
52
|
+
findings.push({
|
|
53
|
+
id: 'data-export-bulk-api-viewall',
|
|
54
|
+
category: this.category,
|
|
55
|
+
riskLevel: 'HIGH',
|
|
56
|
+
title: `${bulkApiGrants.length} profile(s)/permission set(s) combine API access with View/Modify All Data`,
|
|
57
|
+
detail: 'API Enabled together with View All Data or Modify All Data lets the holder pull (or alter) every record in the org through the Bulk/REST API from any client — a programmatic bulk-exfiltration path that bypasses UI and sharing.',
|
|
58
|
+
remediation: 'Split these grants: integration/service accounts should hold API access scoped by object permissions, not View/Modify All. Remove View/Modify All from any account that only needs targeted API access, and restrict API clients via "API Access Control".',
|
|
59
|
+
affectedItems: bulkApiGrants.slice(0, 40).map((r) => ({
|
|
60
|
+
label: `${label(r)}${r.PermissionsModifyAllData ? ' (Modify All)' : ' (View All)'}`,
|
|
61
|
+
url: `${baseUrl}/lightning/setup/PermSets/home`,
|
|
62
|
+
})),
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
if (findings.length === 0) {
|
|
66
|
+
findings.push({
|
|
67
|
+
id: 'data-export-access-ok',
|
|
68
|
+
category: this.category,
|
|
69
|
+
riskLevel: 'LOW',
|
|
70
|
+
passed: true,
|
|
71
|
+
title: 'No broad mass-export capability found',
|
|
72
|
+
detail: 'No profiles/permission sets grant Weekly Data Export, nor API access combined with View/Modify All Data.',
|
|
73
|
+
remediation: 'Keep Weekly Data Export and View/Modify-All limited to trusted admins, and prefer scoped integration users for extracts.',
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
return { findings };
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
//# sourceMappingURL=DataExportAccessCheck.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AuditContext } from '../../context/AuditContext.js';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
/**
|
|
4
|
+
* Cross-references data classification against ACTUAL field encryption. `data-
|
|
5
|
+
* classification` confirms Shield is licensed and that fields are classified;
|
|
6
|
+
* this check answers the next question: are the fields marked sensitive (PII/PHI
|
|
7
|
+
* via ComplianceGroup) actually encrypted at rest? Classified-but-plaintext
|
|
8
|
+
* fields are the gap that matters for a health/PII org — the data is labelled
|
|
9
|
+
* sensitive yet stored in the clear.
|
|
10
|
+
*/
|
|
11
|
+
export declare class EncryptionCoverageCheck implements SecurityCheck {
|
|
12
|
+
readonly id = "encryption-coverage";
|
|
13
|
+
readonly name = "Encryption Coverage for Sensitive Fields";
|
|
14
|
+
readonly category = "Data Security";
|
|
15
|
+
readonly description = "Flags fields classified as sensitive (PII/PHI via ComplianceGroup) that are not encrypted at rest with Shield Platform Encryption";
|
|
16
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
17
|
+
private inconclusive;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=EncryptionCoverageCheck.d.ts.map
|