@cclabsnz/sf-audit 1.3.0 → 1.4.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 +101 -5
- 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 +1 -0
- package/lib/api/RestClientImpl.d.ts +1 -0
- package/lib/api/RestClientImpl.js +6 -0
- package/lib/chains/CapabilityRegistry.js +19 -0
- package/lib/chains/namedChains.js +22 -0
- package/lib/checks/eventLogAccess.d.ts +14 -0
- package/lib/checks/eventLogAccess.js +33 -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/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/registry.js +33 -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 +4 -0
- package/lib/commands/audit/security.js +40 -16
- package/lib/compliance/mapping.js +27 -7
- package/lib/context/AuditCache.d.ts +3 -0
- package/lib/context/AuditContext.d.ts +2 -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 +16 -0
- package/lib/lib/wire.d.ts +2 -0
- package/lib/lib/wire.js +3 -0
- package/package.json +13 -2
|
@@ -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
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
const MAX_OBJECTS = 25; // cap describe calls
|
|
2
|
+
/**
|
|
3
|
+
* Cross-references data classification against ACTUAL field encryption. `data-
|
|
4
|
+
* classification` confirms Shield is licensed and that fields are classified;
|
|
5
|
+
* this check answers the next question: are the fields marked sensitive (PII/PHI
|
|
6
|
+
* via ComplianceGroup) actually encrypted at rest? Classified-but-plaintext
|
|
7
|
+
* fields are the gap that matters for a health/PII org — the data is labelled
|
|
8
|
+
* sensitive yet stored in the clear.
|
|
9
|
+
*/
|
|
10
|
+
export class EncryptionCoverageCheck {
|
|
11
|
+
id = 'encryption-coverage';
|
|
12
|
+
name = 'Encryption Coverage for Sensitive Fields';
|
|
13
|
+
category = 'Data Security';
|
|
14
|
+
description = 'Flags fields classified as sensitive (PII/PHI via ComplianceGroup) that are not encrypted at rest with Shield Platform Encryption';
|
|
15
|
+
async run(ctx) {
|
|
16
|
+
const findings = [];
|
|
17
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
18
|
+
// 1. Sensitive fields = those with a ComplianceGroup (PII/PCI/HIPAA/GDPR/...).
|
|
19
|
+
let classified;
|
|
20
|
+
try {
|
|
21
|
+
classified = await ctx.tooling.query(`SELECT EntityDefinition.QualifiedApiName obj, QualifiedApiName field
|
|
22
|
+
FROM FieldDefinition WHERE ComplianceGroup != null`);
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
findings.push(this.inconclusive('Classified fields could not be queried (Tooling API access needed)'));
|
|
26
|
+
return { findings };
|
|
27
|
+
}
|
|
28
|
+
const fieldsByObj = new Map();
|
|
29
|
+
for (const c of classified) {
|
|
30
|
+
if (!c.obj || !c.field)
|
|
31
|
+
continue;
|
|
32
|
+
const set = fieldsByObj.get(c.obj) ?? new Set();
|
|
33
|
+
set.add(c.field);
|
|
34
|
+
fieldsByObj.set(c.obj, set);
|
|
35
|
+
}
|
|
36
|
+
if (fieldsByObj.size === 0) {
|
|
37
|
+
findings.push({
|
|
38
|
+
id: 'encryption-coverage-no-classification',
|
|
39
|
+
category: this.category,
|
|
40
|
+
riskLevel: 'LOW',
|
|
41
|
+
passed: true,
|
|
42
|
+
title: 'No fields are classified as sensitive',
|
|
43
|
+
detail: 'No fields carry a ComplianceGroup (data classification), so encryption coverage cannot be assessed against a sensitivity baseline. Classification is the prerequisite — see the data-classification check.',
|
|
44
|
+
remediation: 'Classify PII/PHI fields (Setup → Data Classification) first, then encrypt the sensitive ones with Shield Platform Encryption.',
|
|
45
|
+
});
|
|
46
|
+
return { findings };
|
|
47
|
+
}
|
|
48
|
+
// 2. For each classified object, describe it and read per-field encryption.
|
|
49
|
+
const unencrypted = [];
|
|
50
|
+
let describedAny = false;
|
|
51
|
+
for (const [obj, fields] of [...fieldsByObj.entries()].slice(0, MAX_OBJECTS)) {
|
|
52
|
+
let desc;
|
|
53
|
+
try {
|
|
54
|
+
desc = await ctx.rest.get(`/sobjects/${obj}/describe`);
|
|
55
|
+
}
|
|
56
|
+
catch {
|
|
57
|
+
continue;
|
|
58
|
+
}
|
|
59
|
+
if (!desc.fields)
|
|
60
|
+
continue;
|
|
61
|
+
describedAny = true;
|
|
62
|
+
const encryptedNames = new Set(desc.fields.filter((f) => f.encrypted).map((f) => f.name));
|
|
63
|
+
for (const field of fields) {
|
|
64
|
+
if (!encryptedNames.has(field))
|
|
65
|
+
unencrypted.push(`${obj}.${field}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
if (!describedAny) {
|
|
69
|
+
findings.push(this.inconclusive('Object describes were not accessible, so field encryption could not be confirmed'));
|
|
70
|
+
return { findings };
|
|
71
|
+
}
|
|
72
|
+
if (unencrypted.length > 0) {
|
|
73
|
+
findings.push({
|
|
74
|
+
id: 'encryption-coverage-unencrypted-sensitive',
|
|
75
|
+
category: this.category,
|
|
76
|
+
riskLevel: 'HIGH',
|
|
77
|
+
title: `${unencrypted.length} field(s) classified sensitive but NOT encrypted at rest`,
|
|
78
|
+
detail: 'These fields are labelled sensitive (PII/PHI/PCI via a ComplianceGroup) yet are stored in plaintext — Shield Platform Encryption is not applied. For a health/PII org this is the gap that matters: the data is known-sensitive but unprotected at rest, exposed to anyone who can read the field, and to at-rest/export exposure.',
|
|
79
|
+
remediation: 'Enable Shield Platform Encryption on these fields (Setup → Platform Encryption → Encryption Policy). Prefer probabilistic encryption unless a field must be filtered/sorted; if deterministic is required, treat it as weaker and document the tradeoff. Re-encrypt existing data after enabling.',
|
|
80
|
+
affectedItems: unencrypted.slice(0, 50).map((f) => ({ label: f, url: `${baseUrl}/lightning/setup/PlatformEncryptionPolicy/home` })),
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
findings.push({
|
|
85
|
+
id: 'encryption-coverage-ok',
|
|
86
|
+
category: this.category,
|
|
87
|
+
riskLevel: 'LOW',
|
|
88
|
+
passed: true,
|
|
89
|
+
title: 'All classified sensitive fields checked are encrypted at rest',
|
|
90
|
+
detail: `Every classified field found across ${Math.min(fieldsByObj.size, MAX_OBJECTS)} object(s) is encrypted with Shield Platform Encryption.`,
|
|
91
|
+
remediation: 'Keep encryption policy in sync as new sensitive fields are added and classified.',
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
return { findings };
|
|
95
|
+
}
|
|
96
|
+
inconclusive(what) {
|
|
97
|
+
return {
|
|
98
|
+
id: 'encryption-coverage-inconclusive',
|
|
99
|
+
category: this.category,
|
|
100
|
+
riskLevel: 'INFO',
|
|
101
|
+
inconclusive: true,
|
|
102
|
+
title: `${what}`,
|
|
103
|
+
detail: 'The audit user could not gather the classification/describe data needed to assess encryption coverage.',
|
|
104
|
+
remediation: 'Grant the audit user Tooling API access and object describe (View Setup and Configuration), then re-run.',
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
//# sourceMappingURL=EncryptionCoverageCheck.js.map
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { classifyEventLogAccessError } from '../eventLogAccess.js';
|
|
1
2
|
export class EventMonitoringCheck {
|
|
2
3
|
id = 'event-monitoring';
|
|
3
4
|
name = 'Event Monitoring Storage';
|
|
@@ -26,8 +27,8 @@ export class EventMonitoringCheck {
|
|
|
26
27
|
return r.earliestDate;
|
|
27
28
|
return r.earliestDate < earliest ? r.earliestDate : earliest;
|
|
28
29
|
}, null);
|
|
29
|
-
// Populate cache for SiemIntegrationCheck at zero extra API cost
|
|
30
|
-
ctx.cache.eventLogSummary = { earliestDate, totalFiles, eventTypes };
|
|
30
|
+
// Populate cache for SiemIntegrationCheck + GuestTrafficAnomalyCheck at zero extra API cost
|
|
31
|
+
ctx.cache.eventLogSummary = { earliestDate, totalFiles, eventTypes, accessible: true };
|
|
31
32
|
if (totalFiles === 0) {
|
|
32
33
|
findings.push({
|
|
33
34
|
id: 'event-monitoring-disabled',
|
|
@@ -65,9 +66,11 @@ export class EventMonitoringCheck {
|
|
|
65
66
|
}
|
|
66
67
|
}
|
|
67
68
|
}
|
|
68
|
-
catch {
|
|
69
|
-
// EventLogFile may not be accessible without Event Monitoring license
|
|
70
|
-
|
|
69
|
+
catch (e) {
|
|
70
|
+
// EventLogFile may not be accessible without Event Monitoring license, or the
|
|
71
|
+
// audit user may lack "View Event Log Files". Record which, so downstream
|
|
72
|
+
// checks can phrase their blind spot precisely instead of re-querying.
|
|
73
|
+
ctx.cache.eventLogSummary = { earliestDate: null, totalFiles: 0, eventTypes: [], accessible: false, accessError: classifyEventLogAccessError(e) };
|
|
71
74
|
findings.push({
|
|
72
75
|
id: 'event-monitoring-inaccessible',
|
|
73
76
|
category: this.category,
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { AuditContext } from '../../context/AuditContext.js';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
/**
|
|
4
|
+
* Advisory review of Experience Cloud CSP / Lightning Web Security posture.
|
|
5
|
+
* The per-site CSP level ("Strict" vs "Relaxed") and the Lightning Web Security
|
|
6
|
+
* toggle are not reliably exposed to SOQL/Tooling, so for each live site this
|
|
7
|
+
* emits a targeted manual-verification item rather than a false pass. Relaxed CSP
|
|
8
|
+
* or disabled LWS on a public site widens the XSS / script-injection surface that
|
|
9
|
+
* unauthenticated visitors can reach.
|
|
10
|
+
*/
|
|
11
|
+
export declare class ExperienceCspCheck implements SecurityCheck {
|
|
12
|
+
readonly id = "experience-csp";
|
|
13
|
+
readonly name = "Experience Cloud CSP & Lightning Web Security";
|
|
14
|
+
readonly category = "Access Control";
|
|
15
|
+
readonly description = "Advises verifying Strict CSP and Lightning Web Security on live Experience Cloud sites (not reliably API-readable), to limit XSS/script-injection exposure";
|
|
16
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=ExperienceCspCheck.d.ts.map
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Advisory review of Experience Cloud CSP / Lightning Web Security posture.
|
|
3
|
+
* The per-site CSP level ("Strict" vs "Relaxed") and the Lightning Web Security
|
|
4
|
+
* toggle are not reliably exposed to SOQL/Tooling, so for each live site this
|
|
5
|
+
* emits a targeted manual-verification item rather than a false pass. Relaxed CSP
|
|
6
|
+
* or disabled LWS on a public site widens the XSS / script-injection surface that
|
|
7
|
+
* unauthenticated visitors can reach.
|
|
8
|
+
*/
|
|
9
|
+
export class ExperienceCspCheck {
|
|
10
|
+
id = 'experience-csp';
|
|
11
|
+
name = 'Experience Cloud CSP & Lightning Web Security';
|
|
12
|
+
category = 'Access Control';
|
|
13
|
+
description = 'Advises verifying Strict CSP and Lightning Web Security on live Experience Cloud sites (not reliably API-readable), to limit XSS/script-injection exposure';
|
|
14
|
+
async run(ctx) {
|
|
15
|
+
const findings = [];
|
|
16
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
17
|
+
let networks;
|
|
18
|
+
try {
|
|
19
|
+
networks = await ctx.soql.queryAll("SELECT Id, Name, Status FROM Network WHERE Status = 'Live'");
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
findings.push({
|
|
23
|
+
id: 'experience-csp-inconclusive',
|
|
24
|
+
category: this.category,
|
|
25
|
+
riskLevel: 'INFO',
|
|
26
|
+
inconclusive: true,
|
|
27
|
+
title: 'Experience Cloud sites could not be queried (insufficient access)',
|
|
28
|
+
detail: 'The Network object was not accessible, so CSP/LWS posture could not be assessed. This may mean no Experience Cloud licence.',
|
|
29
|
+
remediation: 'Grant the audit user View Setup and Configuration and re-run. If Experience Cloud is unused, this check is not applicable.',
|
|
30
|
+
});
|
|
31
|
+
return { findings };
|
|
32
|
+
}
|
|
33
|
+
if (networks.length === 0) {
|
|
34
|
+
findings.push({
|
|
35
|
+
id: 'experience-csp-none',
|
|
36
|
+
category: this.category,
|
|
37
|
+
riskLevel: 'LOW',
|
|
38
|
+
passed: true,
|
|
39
|
+
title: 'No live Experience Cloud sites',
|
|
40
|
+
detail: 'No live Experience Cloud sites exist, so there is no CSP/LWS surface to review.',
|
|
41
|
+
remediation: 'When a site goes live, set Security to "Strict CSP" and enable Lightning Web Security.',
|
|
42
|
+
});
|
|
43
|
+
return { findings };
|
|
44
|
+
}
|
|
45
|
+
findings.push({
|
|
46
|
+
id: 'experience-csp-verify',
|
|
47
|
+
category: this.category,
|
|
48
|
+
riskLevel: 'INFO',
|
|
49
|
+
title: `Verify Strict CSP + Lightning Web Security on ${networks.length} live Experience Cloud site(s)`,
|
|
50
|
+
detail: 'The per-site Content Security Policy level and Lightning Web Security toggle are not reliably exposed to the API, so they must be confirmed manually. A "Relaxed CSP" level or disabled Lightning Web Security lets inline/third-party scripts run on pages an unauthenticated guest can reach, widening the XSS and script-injection surface.',
|
|
51
|
+
remediation: 'For each site: Setup → Digital Experiences → (site) → Administration → Security & Privacy — set the CSP level to "Strict CSP" and enable Lightning Web Security. Review any Trusted Sites/URLs added to relax CSP.',
|
|
52
|
+
affectedItems: networks.slice(0, 30).map((n) => ({ label: n.Name, url: `${baseUrl}/lightning/setup/SetupNetworks/home` })),
|
|
53
|
+
});
|
|
54
|
+
return { findings };
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=ExperienceCspCheck.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 Credentials (the modern auth half of Named Credentials) for
|
|
5
|
+
* weak authentication. Complements `named-credentials` (which inventories the
|
|
6
|
+
* endpoints) by grading HOW the org authenticates to them: a credential with no
|
|
7
|
+
* authentication, or a hand-rolled custom scheme, is a soft target for spoofing
|
|
8
|
+
* the remote system or leaking a static secret.
|
|
9
|
+
*/
|
|
10
|
+
export declare class ExternalCredentialsCheck implements SecurityCheck {
|
|
11
|
+
readonly id = "external-credentials";
|
|
12
|
+
readonly name = "External Credential Authentication";
|
|
13
|
+
readonly category = "External Connectivity";
|
|
14
|
+
readonly description = "Grades External Credential authentication protocols, flagging callouts that use no authentication or a custom (non-standard) scheme";
|
|
15
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=ExternalCredentialsCheck.d.ts.map
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
// Authentication protocols that mean the callout carries no server-verified
|
|
2
|
+
// credential — either fully anonymous, or a static/custom secret that is easy to
|
|
3
|
+
// leak or replay.
|
|
4
|
+
const WEAK_PROTOCOLS = new Set(['NoAuthentication', 'Custom']);
|
|
5
|
+
/**
|
|
6
|
+
* Reviews External Credentials (the modern auth half of Named Credentials) for
|
|
7
|
+
* weak authentication. Complements `named-credentials` (which inventories the
|
|
8
|
+
* endpoints) by grading HOW the org authenticates to them: a credential with no
|
|
9
|
+
* authentication, or a hand-rolled custom scheme, is a soft target for spoofing
|
|
10
|
+
* the remote system or leaking a static secret.
|
|
11
|
+
*/
|
|
12
|
+
export class ExternalCredentialsCheck {
|
|
13
|
+
id = 'external-credentials';
|
|
14
|
+
name = 'External Credential Authentication';
|
|
15
|
+
category = 'External Connectivity';
|
|
16
|
+
description = 'Grades External Credential authentication protocols, flagging callouts that use no authentication or a custom (non-standard) scheme';
|
|
17
|
+
async run(ctx) {
|
|
18
|
+
const findings = [];
|
|
19
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
20
|
+
let creds;
|
|
21
|
+
try {
|
|
22
|
+
creds = await ctx.soql.queryAll('SELECT Id, DeveloperName, AuthenticationProtocol FROM ExternalCredential');
|
|
23
|
+
}
|
|
24
|
+
catch {
|
|
25
|
+
findings.push({
|
|
26
|
+
id: 'external-credentials-inconclusive',
|
|
27
|
+
category: this.category,
|
|
28
|
+
riskLevel: 'INFO',
|
|
29
|
+
inconclusive: true,
|
|
30
|
+
title: 'External Credentials could not be queried (insufficient access or unsupported)',
|
|
31
|
+
detail: 'The ExternalCredential object was not accessible. This can mean the org has not migrated to External Credentials, or the audit user lacks access.',
|
|
32
|
+
remediation: 'Grant the audit user View Setup and Configuration and re-run. Also review Setup → Named Credentials → External Credentials manually.',
|
|
33
|
+
});
|
|
34
|
+
return { findings };
|
|
35
|
+
}
|
|
36
|
+
if (creds.length === 0) {
|
|
37
|
+
findings.push({
|
|
38
|
+
id: 'external-credentials-none',
|
|
39
|
+
category: this.category,
|
|
40
|
+
riskLevel: 'LOW',
|
|
41
|
+
passed: true,
|
|
42
|
+
title: 'No External Credentials configured',
|
|
43
|
+
detail: 'No ExternalCredential records exist, so there is no external-credential authentication surface to grade.',
|
|
44
|
+
remediation: 'When adding External Credentials, prefer OAuth/JWT or AWS SigV4 over custom or no-authentication schemes.',
|
|
45
|
+
});
|
|
46
|
+
return { findings };
|
|
47
|
+
}
|
|
48
|
+
const weak = creds.filter((c) => WEAK_PROTOCOLS.has(c.AuthenticationProtocol ?? ''));
|
|
49
|
+
if (weak.length > 0) {
|
|
50
|
+
findings.push({
|
|
51
|
+
id: 'external-credentials-weak-auth',
|
|
52
|
+
category: this.category,
|
|
53
|
+
riskLevel: 'MEDIUM',
|
|
54
|
+
title: `${weak.length} External Credential(s) use no or custom authentication`,
|
|
55
|
+
detail: 'These External Credentials authenticate with "No Authentication" or a "Custom" scheme. No-auth callouts can be spoofed or redirected without detection, and custom schemes typically embed a static secret that is easy to leak or replay. Standard protocols (OAuth, JWT, AWS SigV4) provide server-verified, rotatable credentials.',
|
|
56
|
+
remediation: 'Move these callouts to a standard authentication protocol (OAuth 2.0, JWT bearer, or AWS SigV4) with a rotatable secret, and confirm the paired Named Credential targets an HTTPS endpoint.',
|
|
57
|
+
affectedItems: weak.map((c) => ({ label: `${c.DeveloperName} (${c.AuthenticationProtocol})`, url: `${baseUrl}/lightning/setup/NamedCredential/home` })),
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
else {
|
|
61
|
+
findings.push({
|
|
62
|
+
id: 'external-credentials-ok',
|
|
63
|
+
category: this.category,
|
|
64
|
+
riskLevel: 'LOW',
|
|
65
|
+
passed: true,
|
|
66
|
+
title: `${creds.length} External Credential(s); all use standard authentication`,
|
|
67
|
+
detail: 'No External Credential uses "No Authentication" or a custom scheme.',
|
|
68
|
+
remediation: 'Continue to prefer OAuth/JWT/SigV4 and rotate secrets on a schedule.',
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return { findings };
|
|
72
|
+
}
|
|
73
|
+
}
|
|
74
|
+
//# sourceMappingURL=ExternalCredentialsCheck.js.map
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { AuditContext } from '../../context/AuditContext.js';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
/**
|
|
4
|
+
* Flags guest (unauthenticated) users whose profile/permission-sets grant API or
|
|
5
|
+
* Bulk API access. The other guest checks cover the UI-API/GraphQL vector; this
|
|
6
|
+
* covers the *programmatic* one: a guest with "API Enabled" can drive the REST/SOAP/
|
|
7
|
+
* Bulk API directly, turning any readable object into a scriptable bulk pull, and
|
|
8
|
+
* "Bulk API Hard Delete" additionally lets an anonymous caller permanently destroy
|
|
9
|
+
* records (bypassing the recycle bin).
|
|
10
|
+
*/
|
|
11
|
+
export declare class GuestApiAccessCheck implements SecurityCheck {
|
|
12
|
+
readonly id = "guest-api-access";
|
|
13
|
+
readonly name = "Guest API & Bulk Access";
|
|
14
|
+
readonly category = "Access Control";
|
|
15
|
+
readonly description = "Flags guest users granted API Enabled or Bulk API Hard Delete \u2014 programmatic bulk read/delete access for unauthenticated visitors";
|
|
16
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
17
|
+
private inconclusive;
|
|
18
|
+
}
|
|
19
|
+
//# sourceMappingURL=GuestApiAccessCheck.d.ts.map
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Flags guest (unauthenticated) users whose profile/permission-sets grant API or
|
|
3
|
+
* Bulk API access. The other guest checks cover the UI-API/GraphQL vector; this
|
|
4
|
+
* covers the *programmatic* one: a guest with "API Enabled" can drive the REST/SOAP/
|
|
5
|
+
* Bulk API directly, turning any readable object into a scriptable bulk pull, and
|
|
6
|
+
* "Bulk API Hard Delete" additionally lets an anonymous caller permanently destroy
|
|
7
|
+
* records (bypassing the recycle bin).
|
|
8
|
+
*/
|
|
9
|
+
export class GuestApiAccessCheck {
|
|
10
|
+
id = 'guest-api-access';
|
|
11
|
+
name = 'Guest API & Bulk Access';
|
|
12
|
+
category = 'Access Control';
|
|
13
|
+
description = 'Flags guest users granted API Enabled or Bulk API Hard Delete — programmatic bulk read/delete access for unauthenticated visitors';
|
|
14
|
+
async run(ctx) {
|
|
15
|
+
const findings = [];
|
|
16
|
+
const baseUrl = ctx.orgInfo.instanceUrl;
|
|
17
|
+
let guests;
|
|
18
|
+
try {
|
|
19
|
+
guests = await ctx.soql.queryAll("SELECT Id, Username FROM User WHERE UserType = 'Guest' AND IsActive = true");
|
|
20
|
+
}
|
|
21
|
+
catch {
|
|
22
|
+
findings.push(this.inconclusive('Guest users could not be queried'));
|
|
23
|
+
return { findings };
|
|
24
|
+
}
|
|
25
|
+
if (guests.length === 0) {
|
|
26
|
+
findings.push({
|
|
27
|
+
id: 'guest-api-access-none',
|
|
28
|
+
category: this.category,
|
|
29
|
+
riskLevel: 'LOW',
|
|
30
|
+
passed: true,
|
|
31
|
+
title: 'No active guest users',
|
|
32
|
+
detail: 'There are no active guest users, so there is no guest API surface.',
|
|
33
|
+
remediation: 'If a public site is added later, keep API Enabled and Bulk API permissions off the guest profile.',
|
|
34
|
+
});
|
|
35
|
+
return { findings };
|
|
36
|
+
}
|
|
37
|
+
const inIds = guests.map((g) => `'${g.Id}'`).join(', ');
|
|
38
|
+
let psa;
|
|
39
|
+
try {
|
|
40
|
+
psa = await ctx.soql.queryAll(`SELECT AssigneeId, PermissionSet.Label, PermissionSet.PermissionsApiEnabled, PermissionSet.PermissionsBulkApiHardDelete
|
|
41
|
+
FROM PermissionSetAssignment WHERE AssigneeId IN (${inIds})`);
|
|
42
|
+
}
|
|
43
|
+
catch {
|
|
44
|
+
findings.push(this.inconclusive('Guest permission sets could not be queried'));
|
|
45
|
+
return { findings };
|
|
46
|
+
}
|
|
47
|
+
const guestById = new Map(guests.map((g) => [g.Id, g]));
|
|
48
|
+
const apiGuests = new Map(); // guestId -> permset labels granting API
|
|
49
|
+
const hardDeleteGuests = new Map();
|
|
50
|
+
for (const a of psa) {
|
|
51
|
+
if (!a.PermissionSet)
|
|
52
|
+
continue;
|
|
53
|
+
if (a.PermissionSet.PermissionsApiEnabled) {
|
|
54
|
+
(apiGuests.get(a.AssigneeId) ?? apiGuests.set(a.AssigneeId, new Set()).get(a.AssigneeId)).add(a.PermissionSet.Label);
|
|
55
|
+
}
|
|
56
|
+
if (a.PermissionSet.PermissionsBulkApiHardDelete) {
|
|
57
|
+
(hardDeleteGuests.get(a.AssigneeId) ?? hardDeleteGuests.set(a.AssigneeId, new Set()).get(a.AssigneeId)).add(a.PermissionSet.Label);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
if (apiGuests.size > 0) {
|
|
61
|
+
findings.push({
|
|
62
|
+
id: 'guest-api-access-enabled',
|
|
63
|
+
category: this.category,
|
|
64
|
+
riskLevel: 'HIGH',
|
|
65
|
+
title: `${apiGuests.size} guest user(s) have API access enabled`,
|
|
66
|
+
detail: '"API Enabled" on a guest user lets an unauthenticated caller drive the REST/SOAP/Bulk API directly, not just the site UI. Every object the guest can read becomes a scriptable bulk-extraction target, and this bypasses UI-only assumptions about what guests can reach.',
|
|
67
|
+
remediation: 'Remove "API Enabled" from the guest profile and any permission set assigned to the guest user. Guests should interact only through the site\'s Apex/LWC, never the raw API.',
|
|
68
|
+
affectedItems: [...apiGuests.entries()].slice(0, 30).map(([id, sets]) => ({
|
|
69
|
+
label: `${guestById.get(id)?.Username ?? id} — via ${[...sets].join(', ')}`,
|
|
70
|
+
url: `${baseUrl}/lightning/setup/PermSets/home`,
|
|
71
|
+
})),
|
|
72
|
+
});
|
|
73
|
+
}
|
|
74
|
+
if (hardDeleteGuests.size > 0) {
|
|
75
|
+
findings.push({
|
|
76
|
+
id: 'guest-api-hard-delete',
|
|
77
|
+
category: this.category,
|
|
78
|
+
riskLevel: 'CRITICAL',
|
|
79
|
+
title: `${hardDeleteGuests.size} guest user(s) have Bulk API Hard Delete`,
|
|
80
|
+
detail: '"Bulk API Hard Delete" lets the holder permanently delete records, skipping the recycle bin. On a guest user this hands an unauthenticated visitor an irreversible destructive capability.',
|
|
81
|
+
remediation: 'Immediately remove "Bulk API Hard Delete" from all guest profiles/permission sets.',
|
|
82
|
+
affectedItems: [...hardDeleteGuests.entries()].slice(0, 30).map(([id, sets]) => ({
|
|
83
|
+
label: `${guestById.get(id)?.Username ?? id} — via ${[...sets].join(', ')}`,
|
|
84
|
+
url: `${baseUrl}/lightning/setup/PermSets/home`,
|
|
85
|
+
})),
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
if (findings.length === 0) {
|
|
89
|
+
findings.push({
|
|
90
|
+
id: 'guest-api-access-ok',
|
|
91
|
+
category: this.category,
|
|
92
|
+
riskLevel: 'LOW',
|
|
93
|
+
passed: true,
|
|
94
|
+
title: `${guests.length} guest user(s); no API or Bulk API access`,
|
|
95
|
+
detail: 'No active guest user has "API Enabled" or "Bulk API Hard Delete", so guests cannot drive the raw API.',
|
|
96
|
+
remediation: 'Keep API and Bulk permissions off guest profiles as sites change.',
|
|
97
|
+
});
|
|
98
|
+
}
|
|
99
|
+
return { findings };
|
|
100
|
+
}
|
|
101
|
+
inconclusive(what) {
|
|
102
|
+
return {
|
|
103
|
+
id: 'guest-api-access-inconclusive',
|
|
104
|
+
category: this.category,
|
|
105
|
+
riskLevel: 'INFO',
|
|
106
|
+
inconclusive: true,
|
|
107
|
+
title: `${what} (insufficient access)`,
|
|
108
|
+
detail: 'The audit user could not gather the data needed to evaluate guest API access.',
|
|
109
|
+
remediation: 'Grant the audit user View Setup and Configuration and re-run.',
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
//# sourceMappingURL=GuestApiAccessCheck.js.map
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import type { AuditContext } from '../../context/AuditContext.js';
|
|
2
|
+
import type { SecurityCheck, CheckResult } from '../SecurityCheck.js';
|
|
3
|
+
/**
|
|
4
|
+
* Detects every object an unauthenticated guest can READ IN BULK. Unlike
|
|
5
|
+
* GuestUserAccessCheck (a fixed list of standard objects + sharing rules), this
|
|
6
|
+
* auto-discovers ALL objects the guest profile/permission-sets can read, then
|
|
7
|
+
* decides whether records are actually reachable:
|
|
8
|
+
* - public external OWD (Read/ReadWrite) => every record is readable, OR
|
|
9
|
+
* - Private OWD but the guest OWNS records (public-form submissions) => those
|
|
10
|
+
* records are still readable, because an owner can always read its own records.
|
|
11
|
+
*
|
|
12
|
+
* Sharing-model readability is necessary but not sufficient: the Experience Cloud
|
|
13
|
+
* UI API (GraphQL) can only return objects it MODELS. Objects like Calendar,
|
|
14
|
+
* AuthSession, or OauthToken can be readable in the sharing model yet fail the UI
|
|
15
|
+
* API `object-info` endpoint, so they are NOT reachable through the guest GraphQL
|
|
16
|
+
* vector. This check therefore probes `object-info` per exposed object and grades:
|
|
17
|
+
* - Tier 1 (CRITICAL): sharing-readable AND UI-API-modeled => actually pullable.
|
|
18
|
+
* - Tier 2 (MEDIUM): sharing-readable but NOT UI-API-modeled => defense-in-depth
|
|
19
|
+
* only (remove the grant, but it is not the bulk-exfiltration vector).
|
|
20
|
+
* Where a live record exists, UserRecordAccess is queried as ground-truth read
|
|
21
|
+
* confirmation and surfaced in the finding evidence.
|
|
22
|
+
*/
|
|
23
|
+
export declare class GuestObjectExposureCheck implements SecurityCheck {
|
|
24
|
+
readonly id = "guest-object-exposure";
|
|
25
|
+
readonly name = "Guest Object Exposure (Bulk Read via UI API)";
|
|
26
|
+
readonly category = "Access Control";
|
|
27
|
+
readonly description = "Auto-discovers every object an unauthenticated guest can read in bulk via the UI API (GraphQL), including records exposed by guest ownership despite a Private org-wide default";
|
|
28
|
+
run(ctx: AuditContext): Promise<CheckResult>;
|
|
29
|
+
/**
|
|
30
|
+
* Probes the UI API `object-info` endpoint. Returns true if the object is
|
|
31
|
+
* modelled (reachable via executeGraphQL), false if the endpoint reports it is
|
|
32
|
+
* not modelled, or null if the probe could not be performed at all.
|
|
33
|
+
*/
|
|
34
|
+
private isUiApiModeled;
|
|
35
|
+
/**
|
|
36
|
+
* Ground-truth read confirmation via UserRecordAccess for a single sample
|
|
37
|
+
* record. Returns null when there is no record to test or the probe fails.
|
|
38
|
+
*/
|
|
39
|
+
private confirmGuestRead;
|
|
40
|
+
private evidenceNote;
|
|
41
|
+
private ok;
|
|
42
|
+
private inconclusive;
|
|
43
|
+
}
|
|
44
|
+
//# sourceMappingURL=GuestObjectExposureCheck.d.ts.map
|