@cclabsnz/sf-audit 1.18.1 → 1.20.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.
Files changed (41) hide show
  1. package/CHANGELOG.md +64 -0
  2. package/lib/apps/apiLogSource.js +3 -2
  3. package/lib/chains/AttackChain.d.ts +12 -0
  4. package/lib/chains/ChainEngine.js +12 -3
  5. package/lib/chains/namedChains.d.ts +72 -0
  6. package/lib/chains/namedChains.js +381 -207
  7. package/lib/checks/CheckEngine.js +5 -2
  8. package/lib/checks/impl/AgentActionSurfaceCheck.js +2 -13
  9. package/lib/checks/impl/AgentInventoryCheck.js +2 -15
  10. package/lib/checks/impl/ApexLoggingCheck.js +2 -0
  11. package/lib/checks/impl/GuestApiAccessCheck.js +2 -0
  12. package/lib/checks/impl/GuestUserAccessCheck.js +2 -0
  13. package/lib/checks/impl/UsersAndAdminsCheck.js +91 -26
  14. package/lib/checks/support/missingObject.js +2 -1
  15. package/lib/checks/support/schema.js +1 -1
  16. package/lib/commands/audit/incident/collect.js +2 -1
  17. package/lib/findings/Finding.d.ts +7 -0
  18. package/lib/findings/unknownMetrics.d.ts +5 -0
  19. package/lib/findings/unknownMetrics.js +29 -0
  20. package/lib/history/DiffEngine.js +6 -1
  21. package/lib/incident/collect/orgErrors.js +3 -1
  22. package/lib/incident/collect/streamGuestLogs.js +3 -2
  23. package/lib/lib/apiErrorText.d.ts +8 -0
  24. package/lib/lib/apiErrorText.js +15 -0
  25. package/lib/renderers/AttackChainDagRenderer.d.ts +5 -1
  26. package/lib/renderers/AttackChainDagRenderer.js +16 -31
  27. package/lib/renderers/ClientReportRenderer.js +4 -1
  28. package/lib/renderers/HtmlRenderer.js +23 -7
  29. package/lib/renderers/MarkdownRenderer.js +61 -2
  30. package/lib/renderers/SarifRenderer.js +10 -2
  31. package/lib/threats/linddun.d.ts +3 -0
  32. package/lib/threats/linddun.js +40 -0
  33. package/lib/threats/resolve.d.ts +8 -0
  34. package/lib/threats/resolve.js +18 -0
  35. package/lib/threats/stride.d.ts +3 -0
  36. package/lib/threats/stride.js +120 -0
  37. package/lib/threats/types.d.ts +16 -0
  38. package/lib/threats/types.js +22 -0
  39. package/lib/threats/view.d.ts +27 -0
  40. package/lib/threats/view.js +51 -0
  41. package/package.json +4 -4
@@ -1,4 +1,17 @@
1
1
  import { capabilitiesFor } from './CapabilityRegistry.js';
2
+ /** True when the finding belongs to the group (a capability group matches on granted capabilities). */
3
+ export function inGroup(f, g) {
4
+ if (g.ids?.includes(f.id))
5
+ return true;
6
+ if (g.prefixes?.some((p) => f.id === p || f.id.startsWith(p)))
7
+ return true;
8
+ if (g.capabilities) {
9
+ const grants = capabilitiesFor(f).grants;
10
+ if (g.capabilities.some((c) => grants.includes(c)))
11
+ return true;
12
+ }
13
+ return false;
14
+ }
2
15
  const has = (s, ...caps) => caps.every((c) => s.has(c));
3
16
  const hasAny = (s, ...caps) => caps.some((c) => s.has(c));
4
17
  const byIds = (active, ids) => active.filter((f) => ids.includes(f.id));
@@ -8,7 +21,7 @@ const byPrefixes = (active, prefixes) => active.filter((f) => prefixes.some((p)
8
21
  // Findings that show an unauthenticated visitor can actually read, write or run something. A guest
9
22
  // user existing (`guest-user-baseline`) or a site being live (`classic-sites-active`) is a surface,
10
23
  // not an exposure: every org with a site has one. RULE-071.
11
- const GUEST_EXPOSURE = [
24
+ export const GUEST_EXPOSURE = [
12
25
  'guest-user-read-access', 'guest-user-write-access', 'guest-user-sharing-exposure',
13
26
  'guest-executable-apex-unprotected', 'guest-executable-apex-exposed', 'guest-executable-apex-system-mode',
14
27
  'guest-object-exposure-public-owd', 'guest-object-exposure-guest-owned',
@@ -19,19 +32,203 @@ const GUEST_EXPOSURE = [
19
32
  ];
20
33
  // Ways in for a low-trust principal: external users with public sharing, social sign-on,
21
34
  // self-registration, or a confirmed guest exposure. RULE-072.
22
- const LOW_TRUST_ENTRY = [
35
+ export const LOW_TRUST_ENTRY = [
23
36
  'sharing-model-external-read', 'sharing-model-external-write',
24
37
  'auth-providers-social', 'experience-cloud-site-self-registration',
25
38
  ...GUEST_EXPOSURE,
26
39
  ];
27
40
  // Escalations a non-admin can use. Admins holding admin permissions (`users-super-admin-combo`,
28
41
  // `users-author-apex`) are not an escalation: they already have the access. RULE-072.
29
- const NON_ADMIN_ESCALATION = [
42
+ export const NON_ADMIN_ESCALATION = [
30
43
  'escalation-perms-found', 'privileged-access-shadow-admins',
31
44
  'separation-of-duties-self-escalation', 'separation-of-duties-identity-takeover', 'separation-of-duties-grant-self-data',
32
45
  'login-access-policy-delegated-admins',
33
46
  'integration-least-privilege-escalation-permissions',
34
47
  ];
48
+ // Each chain's finding groups, shared by match() and its abuse case so the two cannot drift.
49
+ export const UNAUTH_EXFIL_STEPS = [
50
+ 'guest-user-read-access', 'guest-user-write-access', 'guest-user-sharing-exposure', 'guest-user-baseline',
51
+ 'guest-executable-apex-unprotected', 'guest-executable-apex-exposed', 'guest-executable-apex-system-mode',
52
+ 'guest-object-exposure-public-owd', 'guest-object-exposure-guest-owned',
53
+ 'guest-api-access-enabled', 'guest-api-hard-delete', 'classic-sites-active',
54
+ 'guest-user-visibility-view-all-users', 'guest-user-visibility-owd', 'guest-user-visibility-object-read',
55
+ 'portal-exposed-apex-without-sharing', 'sharing-model-external-read', 'sharing-model-external-write',
56
+ 'field-level-security-high', 'field-level-security-medium',
57
+ // The guardrail whose absence lets guest-owned records defeat a Private OWD, and the Flow
58
+ // analogue of portal-exposed Apex running without sharing.
59
+ 'guest-record-access-policy-not-enforced',
60
+ 'flows-autolaunched-without-sharing', 'flows-screen-without-sharing',
61
+ // An open inbound email handler grants unauth-foothold, so it must appear whenever it
62
+ // is what opened the gate.
63
+ 'inbound-email-handler-unauthenticated-execution',
64
+ ];
65
+ // Internal-only weaknesses that widen what a foothold reaches. They join as evidence but
66
+ // never count toward the floor: without a guest-side step they describe no unauthenticated path.
67
+ export const UNAUTH_EXFIL_WIDENERS = ['data-cloud-data-space-default-overshared', 'restriction-rules-inactive'];
68
+ export const GUEST_TRAFFIC = ['guest-traffic-anomaly-recon', 'guest-traffic-anomaly-anonymizer'];
69
+ // A readable User roster counts as an exposed surface in its own right — recon against an org
70
+ // that leaks its staff list is the same incident. The object-level Read grant is excluded: on
71
+ // its own it is not a confirmed exposure, and this chain asserts one already in progress.
72
+ export const GUEST_BULK_SURFACE = [
73
+ 'guest-object-exposure-public-owd', 'guest-object-exposure-guest-owned',
74
+ 'guest-user-visibility-view-all-users', 'guest-user-visibility-owd',
75
+ ];
76
+ // Admin powers: they widen what a takeover reaches but are not themselves the escalation.
77
+ export const TAKEOVER_ADMIN_EVIDENCE = [
78
+ 'users-super-admin-combo', 'users-author-apex', 'guest-user-baseline', 'login-access-policy-login-as-enabled',
79
+ 'separation-of-duties-code-and-data',
80
+ 'delegated-administration-groups-active',
81
+ 'auth-provider-registration-handler-admin-exec', 'auth-provider-registration-handler-unverified-email-linking',
82
+ 'delegated-authentication-admin-assigned', 'platform-event-subscriber-escalation',
83
+ ];
84
+ // Exposed secrets: every finding here that grants credential-theft.
85
+ export const EXPOSED_SECRETS = [
86
+ 'hardcoded-credentials-found', 'custom-labels-credential-value-match', 'custom-labels-credential-name-match',
87
+ 'debug-log-active-traces', 'cors-wildcard-origin', 'cors-broad-origin',
88
+ 'flow-http-callout-hardcoded-secret', 'oauth-device-flow-enabled', 'oauth-password-flow-enabled',
89
+ 'custom-settings-credentials',
90
+ ];
91
+ export const EGRESS_PATHS = [
92
+ 'named-credentials-inventory', 'named-credentials-http-endpoint', 'remote-sites-inventory',
93
+ // A user who can stand up connected apps and bypass API access control has provisioned
94
+ // their own egress path.
95
+ 'separation-of-duties-external-exfil-channel',
96
+ ];
97
+ export const SOQL_INJECTION = ['soql-injection-risk'];
98
+ export const SOQL_READ_SINKS = [
99
+ 'sharing-model-external-read', 'sharing-model-external-write',
100
+ 'field-level-security-high', 'field-level-security-medium', 'users-view-all-data',
101
+ 'public-group-sharing-exposure', 'report-folder-access-public',
102
+ 'encryption-coverage-unencrypted-sensitive',
103
+ ];
104
+ export const AGENT_GUEST_CHANNEL = ['agent-channel-exposure-guest-'];
105
+ export const AGENT_PRIVILEGE = ['agent-user-privilege-admin-', 'agent-user-privilege-broad-write-'];
106
+ export const AGENT_WRITE_ACTIONS = ['agent-action-surface-write'];
107
+ export const ACTIVE_AGENTS = ['agent-inventory-summary'];
108
+ export const STALE_TRUSTED_URL = ['trusted-url-hygiene-unresolvable-', 'trusted-url-hygiene-parked-'];
109
+ export const AGENT_NO_CAPTURE = ['agent-monitoring-coverage-none'];
110
+ export const AGENT_QUERY_REACH = ['agent-query-reach-'];
111
+ // Egress: an outbound action that needs no confirmation, or a trusted domain anyone can claim.
112
+ export const AGENT_OUTBOUND = ['agent-outbound-actions-unconfirmed', 'agent-outbound-actions-unverified'];
113
+ // Where outsider text enters, when the org shows it. Evidence only: the chain fires without
114
+ // it, since Web-to-Lead, Web-to-Case and email exist in almost every org.
115
+ export const UNTRUSTED_INPUT = [
116
+ 'inbound-email-handler-unauthenticated-execution',
117
+ 'guest-user-write-access',
118
+ 'guest-object-exposure-guest-owned',
119
+ ];
120
+ export const SANDBOX_PII = ['sandbox-data-masking-pii-present'];
121
+ export const SANDBOX_WEAK_CONTROLS = [
122
+ 'internal-user-mfa-gaps', 'trusted-ip-broad-ranges', 'mfa-portal-users-without-enforcement',
123
+ 'public-group-sharing-exposure', 'report-folder-access-public', 'standard-profiles-in-use',
124
+ 'privileged-access-shadow-admins', 'sharing-model-external-read', 'sharing-model-external-write',
125
+ 'guest-user-read-access', 'guest-user-write-access', 'guest-user-sharing-exposure',
126
+ ];
127
+ export const INSIDER_BROAD_READ = [
128
+ 'public-group-sharing-exposure', 'report-folder-access-public',
129
+ 'users-view-all-data', 'users-modify-all-data',
130
+ // An unused Data Export or View All Users grant on an integration account is the same
131
+ // bulk-read reach as the other members of this set.
132
+ 'integration-least-privilege-data-permissions',
133
+ ];
134
+ export const INSIDER_BULK_EGRESS = [
135
+ 'data-export-weekly-export', 'data-export-bulk-api-viewall',
136
+ 'separation-of-duties-external-exfil-channel',
137
+ ];
138
+ export const INSIDER_BLIND_SPOT = [
139
+ 'event-monitoring-disabled', 'siem-integration-not-detected', 'event-monitoring-retention-short',
140
+ ];
141
+ export const DETECTION_BLIND_SPOTS = [
142
+ 'threat-detection-inactive', 'threat-detection-guest-anomaly-missing',
143
+ 'event-monitoring-disabled', 'event-monitoring-retention-short',
144
+ 'transaction-security-policy-none', 'siem-integration-not-detected', 'siem-retention-gap',
145
+ ];
146
+ export const EXPLOITABLE_ACCESS = ['unauth-foothold', 'priv-esc', 'org-takeover'];
147
+ export const MFA_WEAKNESS = ['trusted-ip-broad-ranges', 'internal-user-mfa-gaps', 'mfa-portal-users-without-enforcement'];
148
+ export const PRIVILEGED_ACCOUNTS = [
149
+ 'users-modify-all-data', 'users-view-all-data', 'users-super-admin-combo',
150
+ 'privileged-access-shadow-admins', 'separation-of-duties-self-escalation',
151
+ ];
152
+ // Standing reach: a token that can act broadly, and keeps being able to.
153
+ export const OAUTH_STANDING = [
154
+ 'connected-app-full-scope-infinite-token',
155
+ 'connected-app-full-scope',
156
+ 'connected-app-infinite-refresh-token',
157
+ ];
158
+ // What removes the containment or the observation. Any one of these turns standing access
159
+ // into access nobody is watching or limiting.
160
+ export const OAUTH_UNCONTAINED = [
161
+ // Nobody is reviewing it: tokens with no matching app, or long unused.
162
+ 'oauth-token-unmatched-app', 'oauth-token-stale', 'oauth-token-no-app-inventory',
163
+ // Nothing is limiting it: the network control that survives authorisation, removed.
164
+ 'connected-apps-bypass-ip', 'connected-apps-relax-ip', 'unrestricted-connected-apps',
165
+ 'connected-apps-long-session-timeout', 'admin-no-ip-restrictions',
166
+ // The authorising identity is worth more than it needs to be, so the token inherits more.
167
+ 'integration-least-privilege-escalation-permissions',
168
+ 'integration-least-privilege-data-permissions',
169
+ 'api-client-permission-assigned',
170
+ ];
171
+ export const SELF_REGISTRATION = ['experience-cloud-site-self-registration'];
172
+ // What an account is worth once obtained. Deliberately excludes report-folder-access-public:
173
+ // it is real for internal users, but a self-registered portal account is a Customer Community
174
+ // licence, which generally has no report access at all, so including it would overstate reach.
175
+ export const PORTAL_REACH = [
176
+ 'sharing-model-external-read', 'sharing-model-external-write',
177
+ 'portal-exposed-apex-without-sharing',
178
+ 'flows-autolaunched-without-sharing', 'flows-screen-without-sharing',
179
+ 'apex-rest-without-sharing',
180
+ 'external-account-hierarchy-super-users', 'external-account-hierarchy-active',
181
+ ];
182
+ // Social sign-on is a second way in rather than a requirement, so it joins as evidence when
183
+ // present but never gates the chain on its own.
184
+ export const SOCIAL_SIGN_ON = ['auth-providers-social'];
185
+ export const SESSION_ID_LEAK = ['outbound-messages-session-id'];
186
+ // Why a replayed session would not be stopped or seen. Any one is enough; the point of the
187
+ // chain is the credential leaving, and these say what happens next.
188
+ export const SESSION_UNCHECKED = [
189
+ // Disclosed in transit, so compromising the endpoint is not even required.
190
+ 'outbound-messages-cleartext',
191
+ // Nothing binds or shortens the session that was handed over.
192
+ 'session-hardening-risks', 'session-security-deviations',
193
+ 'admin-no-ip-restrictions', 'broad-ip-ranges',
194
+ // Nothing would record the replay.
195
+ 'event-monitoring-disabled', 'siem-integration-not-detected', 'threat-detection-inactive',
196
+ ];
197
+ export const ANONYMOUS_FILES = [
198
+ 'public-content-public-documents', 'public-content-public-static-resources',
199
+ 'content-links-no-expiry', 'content-links-no-password', 'content-links-stale',
200
+ 'guest-site-options-file-access',
201
+ ];
202
+ // No way to answer "what was in it" or "who took it". Classification and monitoring only:
203
+ // content-links-stale is a subset of content-links-no-expiry, so counting it on both sides
204
+ // would let one check satisfy the conjunction by itself.
205
+ export const FILES_UNACCOUNTED = [
206
+ 'data-classification-missing', 'data-encryption-not-detected',
207
+ 'event-monitoring-disabled', 'siem-integration-not-detected', 'threat-detection-inactive',
208
+ ];
209
+ export const VF_XSS = ['visualforce-xss-escape-false', 'visualforce-xss-js-merge-field', 'visualforce-xss-attr-merge-field'];
210
+ // The browser-side controls that would otherwise contain an injected script. Excludes
211
+ // 'experience-csp-verify', which asks the operator to confirm a setting rather than reporting
212
+ // a weakness — treating an advisory as a confirmed gap would inflate the chain.
213
+ export const BROWSER_WEAKENED = ['session-hardening-risks', 'csp-trusted-sites-insecure'];
214
+ // Somebody whose session is worth the trouble.
215
+ export const SESSION_TARGETS = [
216
+ 'users-super-admin-combo', 'privileged-access-shadow-admins',
217
+ 'users-modify-all-data', 'users-view-all-data',
218
+ 'separation-of-duties-self-escalation',
219
+ ];
220
+ export const OPEN_EMAIL_HANDLER = ['inbound-email-handler-unauthenticated-execution'];
221
+ export const EMAIL_FOLLOW_ON = [
222
+ 'apex-crud-fls-without-sharing', 'soql-injection-risk', 'portal-exposed-apex-without-sharing',
223
+ 'flows-autolaunched-without-sharing', 'users-modify-all-data', 'users-super-admin-combo',
224
+ 'privileged-access-shadow-admins',
225
+ ];
226
+ export const EVENT_SUBSCRIBER_ESCALATION = ['platform-event-subscriber-escalation'];
227
+ export const EVENT_PUBLISHER_FOOTHOLD = [
228
+ 'guest-user-read-access', 'guest-user-write-access', 'guest-user-sharing-exposure', 'guest-user-baseline',
229
+ 'sharing-model-external-read', 'sharing-model-external-write', 'experience-cloud-site-self-registration',
230
+ ];
231
+ export const EVENT_PRIVILEGED_TARGETS = ['users-super-admin-combo', 'users-modify-all-data', 'privileged-access-shadow-admins'];
35
232
  export const NAMED_CHAINS = [
36
233
  {
37
234
  id: 'unauth-bulk-exfil',
@@ -49,6 +246,13 @@ export const NAMED_CHAINS = [
49
246
  'and set external OWD to Private. Grant portal access only via sharing sets. Because the ' +
50
247
  'requests never reach a login page, tightening authentication does not mitigate this — the ' +
51
248
  'object permissions, sharing model and Apex sharing declarations are the controls that apply.',
249
+ abuseCase: {
250
+ actor: 'an unauthenticated site visitor',
251
+ goal: 'read or change business data in bulk without logging in',
252
+ preconditions: [{ ids: GUEST_EXPOSURE }, { ids: UNAUTH_EXFIL_STEPS }, { ids: UNAUTH_EXFIL_WIDENERS }, { capabilities: ['unauth-foothold'] }, { capabilities: ['code-exec', 'data-read-bulk', 'data-write'] }],
253
+ breakPoint: 0,
254
+ breakPointText: 'Close every confirmed guest exposure: guest object and record access, guest-callable Apex, guest API access, guest visibility of users, the guest record-access policy, and unauthenticated email handlers.',
255
+ },
52
256
  match(present, active) {
53
257
  if (!has(present, 'unauth-foothold'))
54
258
  return null;
@@ -58,27 +262,10 @@ export const NAMED_CHAINS = [
58
262
  // to reach something.
59
263
  if (byIds(active, GUEST_EXPOSURE).length === 0)
60
264
  return null;
61
- const steps = byIds(active, [
62
- 'guest-user-read-access', 'guest-user-write-access', 'guest-user-sharing-exposure', 'guest-user-baseline',
63
- 'guest-executable-apex-unprotected', 'guest-executable-apex-exposed', 'guest-executable-apex-system-mode',
64
- 'guest-object-exposure-public-owd', 'guest-object-exposure-guest-owned',
65
- 'guest-api-access-enabled', 'guest-api-hard-delete', 'classic-sites-active',
66
- 'guest-user-visibility-view-all-users', 'guest-user-visibility-owd', 'guest-user-visibility-object-read',
67
- 'portal-exposed-apex-without-sharing', 'sharing-model-external-read', 'sharing-model-external-write',
68
- 'field-level-security-high', 'field-level-security-medium',
69
- // The guardrail whose absence lets guest-owned records defeat a Private OWD, and the Flow
70
- // analogue of portal-exposed Apex running without sharing.
71
- 'guest-record-access-policy-not-enforced',
72
- 'flows-autolaunched-without-sharing', 'flows-screen-without-sharing',
73
- // An open inbound email handler grants unauth-foothold, so it must appear whenever it
74
- // is what opened the gate.
75
- 'inbound-email-handler-unauthenticated-execution',
76
- ]);
265
+ const steps = byIds(active, UNAUTH_EXFIL_STEPS);
77
266
  if (steps.length < 2)
78
267
  return null;
79
- // Internal-only weaknesses that widen what a foothold reaches. They join as evidence but
80
- // never count toward the floor: without a guest-side step they describe no unauthenticated path.
81
- return [...steps, ...byIds(active, ['data-cloud-data-space-default-overshared', 'restriction-rules-inactive'])];
268
+ return [...steps, ...byIds(active, UNAUTH_EXFIL_WIDENERS)];
82
269
  },
83
270
  },
84
271
  {
@@ -95,15 +282,16 @@ export const NAMED_CHAINS = [
95
282
  remediation: 'Treat as an active incident: block the source IPs at the WAF/CDN, close the guest bulk-read surface ' +
96
283
  '(set external OWD to Private, strip guest object read, enforce "Secure guest user record access"), ' +
97
284
  'and preserve/forward the event logs before the short EventLogFile retention window closes.',
285
+ abuseCase: {
286
+ actor: 'an unauthenticated visitor already probing the site',
287
+ goal: 'map the guest-readable data and pull it',
288
+ preconditions: [{ ids: GUEST_TRAFFIC }, { ids: GUEST_BULK_SURFACE }],
289
+ breakPoint: 1,
290
+ breakPointText: 'Close the guest bulk-read surface: guest object exposure and guest visibility of users.',
291
+ },
98
292
  match(_present, active) {
99
- const traffic = byIds(active, ['guest-traffic-anomaly-recon', 'guest-traffic-anomaly-anonymizer']);
100
- // A readable User roster counts as an exposed surface in its own right — recon against an org
101
- // that leaks its staff list is the same incident. The object-level Read grant is excluded: on
102
- // its own it is not a confirmed exposure, and this chain asserts one already in progress.
103
- const exposure = byIds(active, [
104
- 'guest-object-exposure-public-owd', 'guest-object-exposure-guest-owned',
105
- 'guest-user-visibility-view-all-users', 'guest-user-visibility-owd',
106
- ]);
293
+ const traffic = byIds(active, GUEST_TRAFFIC);
294
+ const exposure = byIds(active, GUEST_BULK_SURFACE);
107
295
  if (traffic.length === 0 || exposure.length === 0)
108
296
  return null;
109
297
  return [...traffic, ...exposure];
@@ -116,6 +304,13 @@ export const NAMED_CHAINS = [
116
304
  narrative: 'A low-trust authenticated user combines with a privilege-escalation permission ' +
117
305
  '(assign permission sets, manage users, author apex, modify metadata) to reach full org control.',
118
306
  remediation: 'Remove escalation permissions from non-admin profiles/permission sets and review who holds them.',
307
+ abuseCase: {
308
+ actor: 'a low-trust authenticated user (external, social sign-on, self-registered, or a guest with confirmed access)',
309
+ goal: 'take full control of the org',
310
+ preconditions: [{ ids: LOW_TRUST_ENTRY }, { ids: NON_ADMIN_ESCALATION }, { ids: TAKEOVER_ADMIN_EVIDENCE }],
311
+ breakPoint: 1,
312
+ breakPointText: 'Remove every escalation permission held by someone who is not an administrator.',
313
+ },
119
314
  match(_present, active) {
120
315
  // Both ends must be present: a way in for a low-trust principal, and an escalation that
121
316
  // principal could use. Admin-held power and a guest user merely existing join only as evidence.
@@ -123,18 +318,7 @@ export const NAMED_CHAINS = [
123
318
  const escalation = byIds(active, NON_ADMIN_ESCALATION);
124
319
  if (entry.length === 0 || escalation.length === 0)
125
320
  return null;
126
- return [
127
- ...entry,
128
- ...escalation,
129
- ...byIds(active, [
130
- // Admin powers: they widen what a takeover reaches but are not themselves the escalation.
131
- 'users-super-admin-combo', 'users-author-apex', 'guest-user-baseline', 'login-access-policy-login-as-enabled',
132
- 'separation-of-duties-code-and-data',
133
- 'delegated-administration-groups-active',
134
- 'auth-provider-registration-handler-admin-exec', 'auth-provider-registration-handler-unverified-email-linking',
135
- 'delegated-authentication-admin-assigned', 'platform-event-subscriber-escalation',
136
- ]),
137
- ];
321
+ return [...entry, ...escalation, ...byIds(active, TAKEOVER_ADMIN_EVIDENCE)];
138
322
  },
139
323
  },
140
324
  {
@@ -144,18 +328,21 @@ export const NAMED_CHAINS = [
144
328
  narrative: 'Exposed secrets (hardcoded credentials, credentials in custom labels, debug logs, or broad CORS) ' +
145
329
  'combine with an external egress path (named credential or remote site) to exfiltrate data to attacker infrastructure.',
146
330
  remediation: 'Rotate and remove exposed secrets, tighten CORS origins, and review external callout endpoints.',
331
+ abuseCase: {
332
+ actor: 'anyone who obtains an exposed secret',
333
+ goal: 'use it to move data to infrastructure they control',
334
+ preconditions: [{ ids: EXPOSED_SECRETS }, { ids: EGRESS_PATHS }, { capabilities: ['credential-theft'] }, { capabilities: ['external-egress'] }],
335
+ breakPoint: 0,
336
+ breakPointText: 'Rotate and remove every exposed secret: hardcoded credentials, credentials in custom settings or labels, active debug traces, broad CORS origins and enabled device or password OAuth flows.',
337
+ },
147
338
  match(present, active) {
148
339
  if (!has(present, 'credential-theft', 'external-egress'))
149
340
  return null;
150
- const steps = byIds(active, [
151
- 'hardcoded-credentials-found', 'custom-labels-credential-value-match', 'custom-labels-credential-name-match',
152
- 'debug-log-active-traces', 'cors-wildcard-origin', 'cors-broad-origin',
153
- 'named-credentials-inventory', 'named-credentials-http-endpoint', 'remote-sites-inventory',
154
- 'flow-http-callout-hardcoded-secret', 'oauth-device-flow-enabled', 'oauth-password-flow-enabled',
155
- // A user who can stand up connected apps and bypass API access control has provisioned
156
- // their own egress path.
157
- 'separation-of-duties-external-exfil-channel',
158
- ]);
341
+ // An exposed secret must be one of the steps: credential-theft granted elsewhere (a session id
342
+ // in an outbound message) is session-id-egress, and egress paths alone are no pivot. INT-012.
343
+ if (byIds(active, EXPOSED_SECRETS).length === 0)
344
+ return null;
345
+ const steps = byIds(active, [...EXPOSED_SECRETS, ...EGRESS_PATHS]);
159
346
  return steps.length >= 2 ? steps : null;
160
347
  },
161
348
  },
@@ -165,18 +352,20 @@ export const NAMED_CHAINS = [
165
352
  severity: 'HIGH',
166
353
  narrative: 'Injectable dynamic SOQL combines with bulk data readability to let an attacker extract large datasets.',
167
354
  remediation: 'Use bind variables in all dynamic SOQL and enforce CRUD/FLS; restrict bulk read access.',
355
+ abuseCase: {
356
+ actor: 'a user who can reach injectable Apex',
357
+ goal: 'read large datasets beyond their own access',
358
+ preconditions: [{ ids: SOQL_INJECTION }, { ids: SOQL_READ_SINKS }, { capabilities: ['code-exec'] }],
359
+ breakPoint: 0,
360
+ breakPointText: 'Use bind variables in the injectable dynamic SOQL.',
361
+ },
168
362
  match(present, active) {
169
363
  if (!has(present, 'code-exec'))
170
364
  return null;
171
- const inj = byIds(active, ['soql-injection-risk']);
365
+ const inj = byIds(active, SOQL_INJECTION);
172
366
  if (inj.length === 0)
173
367
  return null;
174
- const sink = byIds(active, [
175
- 'sharing-model-external-read', 'sharing-model-external-write',
176
- 'field-level-security-high', 'field-level-security-medium', 'users-view-all-data',
177
- 'public-group-sharing-exposure', 'report-folder-access-public',
178
- 'encryption-coverage-unencrypted-sensitive',
179
- ]);
368
+ const sink = byIds(active, SOQL_READ_SINKS);
180
369
  return sink.length > 0 ? [...inj, ...sink] : null;
181
370
  },
182
371
  },
@@ -196,12 +385,17 @@ export const NAMED_CHAINS = [
196
385
  'support chat; the risk here is not the channel existing, it is the channel reaching a privileged agent.',
197
386
  remediation: 'Break any one link: remove the guest/public binding, scope the agent run-as user to least privilege, ' +
198
387
  'or remove write-capable actions from the exposed agent (and add confirmation/guardrails where they must stay).',
388
+ abuseCase: {
389
+ actor: 'an unauthenticated chat visitor',
390
+ goal: 'steer a privileged agent into reading, changing or deleting data',
391
+ preconditions: [{ prefixes: AGENT_GUEST_CHANNEL }, { prefixes: AGENT_PRIVILEGE }, { ids: AGENT_WRITE_ACTIONS }],
392
+ breakPoint: 0,
393
+ breakPointText: 'Remove the guest or public channel binding from the privileged agent.',
394
+ },
199
395
  match(_present, active) {
200
- const channel = byPrefixes(active, ['agent-channel-exposure-guest-']);
201
- const privilege = byPrefixes(active, [
202
- 'agent-user-privilege-admin-', 'agent-user-privilege-broad-write-',
203
- ]);
204
- const actions = byIds(active, ['agent-action-surface-write']);
396
+ const channel = byPrefixes(active, AGENT_GUEST_CHANNEL);
397
+ const privilege = byPrefixes(active, AGENT_PRIVILEGE);
398
+ const actions = byIds(active, AGENT_WRITE_ACTIONS);
205
399
  if (channel.length === 0 || privilege.length === 0 || actions.length === 0)
206
400
  return null;
207
401
  return [...channel, ...privilege, ...actions];
@@ -217,12 +411,17 @@ export const NAMED_CHAINS = [
217
411
  'into sending data to it, and nothing records or responds to the exfiltration.',
218
412
  remediation: 'Remove or reclaim the stale trusted domain immediately, then enable Event Monitoring (and pull agent logs ' +
219
413
  'with `sf audit events pull`) plus a Transaction Security policy so agent-driven exfiltration is detected.',
414
+ abuseCase: {
415
+ actor: 'an outsider who registers a lapsed allowlisted domain',
416
+ goal: 'receive data an injected agent sends there, with nothing recorded',
417
+ preconditions: [{ ids: ACTIVE_AGENTS }, { prefixes: STALE_TRUSTED_URL }, { ids: AGENT_NO_CAPTURE }],
418
+ breakPoint: 1,
419
+ breakPointText: 'Remove or reclaim every stale trusted domain.',
420
+ },
220
421
  match(_present, active) {
221
- const agents = byIds(active, ['agent-inventory-summary']);
222
- const staleUrl = byPrefixes(active, [
223
- 'trusted-url-hygiene-unresolvable-', 'trusted-url-hygiene-parked-',
224
- ]);
225
- const noCapture = byIds(active, ['agent-monitoring-coverage-none']);
422
+ const agents = byIds(active, ACTIVE_AGENTS);
423
+ const staleUrl = byPrefixes(active, STALE_TRUSTED_URL);
424
+ const noCapture = byIds(active, AGENT_NO_CAPTURE);
226
425
  if (agents.length === 0 || staleUrl.length === 0 || noCapture.length === 0)
227
426
  return null;
228
427
  return [...agents, ...staleUrl, ...noCapture];
@@ -242,22 +441,19 @@ export const NAMED_CHAINS = [
242
441
  remediation: 'Break any one link: remove open-ended querying from agents that read untrusted records, require user ' +
243
442
  'confirmation on every outbound action, remove CSP Trusted URLs whose domains you no longer control, or ' +
244
443
  'keep the agent that queries separate from the agent that sends.',
444
+ abuseCase: {
445
+ actor: 'an outsider who can put text in a record an agent reads',
446
+ goal: 'have the agent query records and send them out',
447
+ preconditions: [{ prefixes: AGENT_QUERY_REACH }, { ids: AGENT_OUTBOUND, prefixes: STALE_TRUSTED_URL }, { ids: UNTRUSTED_INPUT }],
448
+ breakPoint: 1,
449
+ breakPointText: 'Require confirmation on every outbound agent action and remove trusted domains you no longer control.',
450
+ },
245
451
  match(_present, active) {
246
- const reach = byPrefixes(active, ['agent-query-reach-']);
247
- // Egress: an outbound action that needs no confirmation, or a trusted domain anyone can claim.
248
- const outbound = [
249
- ...byIds(active, ['agent-outbound-actions-unconfirmed', 'agent-outbound-actions-unverified']),
250
- ...byPrefixes(active, ['trusted-url-hygiene-parked-', 'trusted-url-hygiene-unresolvable-']),
251
- ];
452
+ const reach = byPrefixes(active, AGENT_QUERY_REACH);
453
+ const outbound = [...byIds(active, AGENT_OUTBOUND), ...byPrefixes(active, STALE_TRUSTED_URL)];
252
454
  if (reach.length === 0 || outbound.length === 0)
253
455
  return null;
254
- // Where outsider text enters, when the org shows it. Evidence only: the chain fires without
255
- // it, since Web-to-Lead, Web-to-Case and email exist in almost every org.
256
- const untrusted = byIds(active, [
257
- 'inbound-email-handler-unauthenticated-execution',
258
- 'guest-user-write-access',
259
- 'guest-object-exposure-guest-owned',
260
- ]);
456
+ const untrusted = byIds(active, UNTRUSTED_INPUT);
261
457
  return [...untrusted, ...reach, ...outbound];
262
458
  },
263
459
  },
@@ -273,16 +469,18 @@ export const NAMED_CHAINS = [
273
469
  remediation: 'Run Salesforce Data Mask on the sandbox (or refresh without production data), and bring its ' +
274
470
  'authentication and sharing configuration up to production standard for as long as real data ' +
275
471
  'remains in it.',
472
+ abuseCase: {
473
+ actor: 'anyone with access to the sandbox',
474
+ goal: 'read real production personal data under weaker controls',
475
+ preconditions: [{ ids: SANDBOX_PII }, { ids: SANDBOX_WEAK_CONTROLS }],
476
+ breakPoint: 0,
477
+ breakPointText: 'Mask the production personal data in the sandbox, or refresh it without production data.',
478
+ },
276
479
  match(_present, active) {
277
- const pii = byIds(active, ['sandbox-data-masking-pii-present']);
480
+ const pii = byIds(active, SANDBOX_PII);
278
481
  if (pii.length === 0)
279
482
  return null;
280
- const weakControls = byIds(active, [
281
- 'internal-user-mfa-gaps', 'trusted-ip-broad-ranges', 'mfa-portal-users-without-enforcement',
282
- 'public-group-sharing-exposure', 'report-folder-access-public', 'standard-profiles-in-use',
283
- 'privileged-access-shadow-admins', 'sharing-model-external-read', 'sharing-model-external-write',
284
- 'guest-user-read-access', 'guest-user-write-access', 'guest-user-sharing-exposure',
285
- ]);
483
+ const weakControls = byIds(active, SANDBOX_WEAK_CONTROLS);
286
484
  return weakControls.length > 0 ? [...pii, ...weakControls] : null;
287
485
  },
288
486
  },
@@ -298,21 +496,17 @@ export const NAMED_CHAINS = [
298
496
  remediation: 'Narrow the broad internal sharing, restrict Weekly Data Export and Bulk API access to a named ' +
299
497
  'few, and enable Event Monitoring (plus forwarding to a SIEM) so bulk reads are recorded and ' +
300
498
  'alertable.',
499
+ abuseCase: {
500
+ actor: 'an internal user or whoever holds their stolen credentials',
501
+ goal: 'export business data in bulk without a record of it',
502
+ preconditions: [{ ids: INSIDER_BROAD_READ }, { ids: INSIDER_BULK_EGRESS }, { ids: INSIDER_BLIND_SPOT }],
503
+ breakPoint: 1,
504
+ breakPointText: 'Restrict Weekly Data Export and bulk API export to a named few, and remove self-provisioned connected-app or API export channels.',
505
+ },
301
506
  match(_present, active) {
302
- const broadRead = byIds(active, [
303
- 'public-group-sharing-exposure', 'report-folder-access-public',
304
- 'users-view-all-data', 'users-modify-all-data',
305
- // An unused Data Export or View All Users grant on an integration account is the same
306
- // bulk-read reach as the other members of this set.
307
- 'integration-least-privilege-data-permissions',
308
- ]);
309
- const bulkEgress = byIds(active, [
310
- 'data-export-weekly-export', 'data-export-bulk-api-viewall',
311
- 'separation-of-duties-external-exfil-channel',
312
- ]);
313
- const blindSpot = byIds(active, [
314
- 'event-monitoring-disabled', 'siem-integration-not-detected', 'event-monitoring-retention-short',
315
- ]);
507
+ const broadRead = byIds(active, INSIDER_BROAD_READ);
508
+ const bulkEgress = byIds(active, INSIDER_BULK_EGRESS);
509
+ const blindSpot = byIds(active, INSIDER_BLIND_SPOT);
316
510
  if (broadRead.length === 0 || bulkEgress.length === 0 || blindSpot.length === 0)
317
511
  return null;
318
512
  return [...broadRead, ...bulkEgress, ...blindSpot];
@@ -330,22 +524,22 @@ export const NAMED_CHAINS = [
330
524
  remediation: 'Close the detection gap first: enable Event Monitoring with adequate retention, turn on threat ' +
331
525
  'detection event storage, add a Transaction Security policy, and forward events to a SIEM. Then ' +
332
526
  'remediate the underlying access findings.',
527
+ abuseCase: {
528
+ actor: 'an attacker using an access path the org already exposes',
529
+ goal: 'act without being detected or reconstructed afterwards',
530
+ preconditions: [{ ids: DETECTION_BLIND_SPOTS }, { capabilities: EXPLOITABLE_ACCESS }],
531
+ breakPoint: 0,
532
+ breakPointText: 'Restore detection: Event Monitoring with adequate retention, threat detection, a Transaction Security policy and SIEM forwarding.',
533
+ },
333
534
  match(present, active) {
334
- if (!hasAny(present, 'unauth-foothold', 'priv-esc', 'org-takeover'))
535
+ if (!hasAny(present, ...EXPLOITABLE_ACCESS))
335
536
  return null;
336
- const blindSpots = byIds(active, [
337
- 'threat-detection-inactive', 'threat-detection-guest-anomaly-missing',
338
- 'event-monitoring-disabled', 'event-monitoring-retention-short',
339
- 'transaction-security-policy-none', 'siem-integration-not-detected', 'siem-retention-gap',
340
- ]);
537
+ const blindSpots = byIds(active, DETECTION_BLIND_SPOTS);
341
538
  // One missing control is a finding on its own; two or more is a systemic blind spot. Requiring
342
539
  // two keeps this from firing on every org that has not bought Shield.
343
540
  if (blindSpots.length < 2)
344
541
  return null;
345
- const exposure = active.filter((f) => {
346
- const g = capabilitiesFor(f).grants;
347
- return g.includes('unauth-foothold') || g.includes('priv-esc') || g.includes('org-takeover');
348
- });
542
+ const exposure = active.filter((f) => inGroup(f, { capabilities: EXPLOITABLE_ACCESS }));
349
543
  return exposure.length > 0 ? [...exposure.slice(0, 3), ...blindSpots] : null;
350
544
  },
351
545
  },
@@ -356,14 +550,16 @@ export const NAMED_CHAINS = [
356
550
  narrative: 'Weak MFA enforcement or trusted-IP MFA bypass combines with the presence of highly-privileged ' +
357
551
  'accounts, so a credential-stuffing or phishing attacker can take over an admin without a second factor.',
358
552
  remediation: 'Enforce MFA for all internal users, remove trusted-IP MFA bypass ranges, and minimise privileged accounts.',
553
+ abuseCase: {
554
+ actor: 'a credential-stuffing or phishing attacker',
555
+ goal: 'take over a privileged account without a second factor',
556
+ preconditions: [{ ids: MFA_WEAKNESS }, { ids: PRIVILEGED_ACCOUNTS }],
557
+ breakPoint: 0,
558
+ breakPointText: 'Enforce MFA for every user and remove trusted-IP ranges that bypass it.',
559
+ },
359
560
  match(_present, active) {
360
- const weakness = byIds(active, [
361
- 'trusted-ip-broad-ranges', 'internal-user-mfa-gaps', 'mfa-portal-users-without-enforcement',
362
- ]);
363
- const targets = byIds(active, [
364
- 'users-modify-all-data', 'users-view-all-data', 'users-super-admin-combo',
365
- 'privileged-access-shadow-admins', 'separation-of-duties-self-escalation',
366
- ]);
561
+ const weakness = byIds(active, MFA_WEAKNESS);
562
+ const targets = byIds(active, PRIVILEGED_ACCOUNTS);
367
563
  return weakness.length > 0 && targets.length > 0 ? [...weakness, ...targets] : null;
368
564
  },
369
565
  },
@@ -395,28 +591,18 @@ export const NAMED_CHAINS = [
395
591
  'control still applying after authorisation. Treat a vendor breach notice as a trigger to ' +
396
592
  'revoke every token for that publisher rather than waiting to confirm your own org was ' +
397
593
  'touched: with no login row to search, absence of evidence is not evidence of absence here.',
594
+ abuseCase: {
595
+ actor: "the holder of a connected app's refresh token",
596
+ goal: 'use standing API access that no login control sees',
597
+ preconditions: [{ ids: OAUTH_STANDING }, { ids: OAUTH_UNCONTAINED }],
598
+ breakPoint: 0,
599
+ breakPointText: 'Replace Full scope with the scopes each integration uses, and set refresh tokens to expire.',
600
+ },
398
601
  match(_present, active) {
399
- // Standing reach: a token that can act broadly, and keeps being able to.
400
- const standing = byIds(active, [
401
- 'connected-app-full-scope-infinite-token',
402
- 'connected-app-full-scope',
403
- 'connected-app-infinite-refresh-token',
404
- ]);
602
+ const standing = byIds(active, OAUTH_STANDING);
405
603
  if (standing.length === 0)
406
604
  return null;
407
- // What removes the containment or the observation. Any one of these turns standing access
408
- // into access nobody is watching or limiting.
409
- const uncontained = byIds(active, [
410
- // Nobody is reviewing it: tokens with no matching app, or long unused.
411
- 'oauth-token-unmatched-app', 'oauth-token-stale', 'oauth-token-no-app-inventory',
412
- // Nothing is limiting it: the network control that survives authorisation, removed.
413
- 'connected-apps-bypass-ip', 'connected-apps-relax-ip', 'unrestricted-connected-apps',
414
- 'connected-apps-long-session-timeout', 'admin-no-ip-restrictions',
415
- // The authorising identity is worth more than it needs to be, so the token inherits more.
416
- 'integration-least-privilege-escalation-permissions',
417
- 'integration-least-privilege-data-permissions',
418
- 'api-client-permission-assigned',
419
- ]);
605
+ const uncontained = byIds(active, OAUTH_UNCONTAINED);
420
606
  if (uncontained.length === 0)
421
607
  return null;
422
608
  return [...standing, ...uncontained];
@@ -443,26 +629,21 @@ export const NAMED_CHAINS = [
443
629
  'and make sure Apex and Flows reachable from the site run with sharing. Check what the ' +
444
630
  'self-registration handler assigns as the default profile and licence — the exposure is ' +
445
631
  'whatever that profile can reach, and it is rarely reviewed after the site goes live.',
632
+ abuseCase: {
633
+ actor: 'anyone with an email address',
634
+ goal: 'self-register and read more than their own records',
635
+ preconditions: [{ ids: SELF_REGISTRATION }, { ids: PORTAL_REACH }, { ids: SOCIAL_SIGN_ON }],
636
+ breakPoint: 0,
637
+ breakPointText: 'Turn off self-registration on the site.',
638
+ },
446
639
  match(_present, active) {
447
- const acquisition = byIds(active, ['experience-cloud-site-self-registration']);
640
+ const acquisition = byIds(active, SELF_REGISTRATION);
448
641
  if (acquisition.length === 0)
449
642
  return null;
450
- // What an account is worth once obtained. Deliberately excludes report-folder-access-public:
451
- // it is real for internal users, but a self-registered portal account is a Customer Community
452
- // licence, which generally has no report access at all, so including it would overstate reach.
453
- const reach = byIds(active, [
454
- 'sharing-model-external-read', 'sharing-model-external-write',
455
- 'portal-exposed-apex-without-sharing',
456
- 'flows-autolaunched-without-sharing', 'flows-screen-without-sharing',
457
- 'apex-rest-without-sharing',
458
- 'external-account-hierarchy-super-users', 'external-account-hierarchy-active',
459
- ]);
643
+ const reach = byIds(active, PORTAL_REACH);
460
644
  if (reach.length === 0)
461
645
  return null;
462
- // Social sign-on is a second way in rather than a requirement, so it joins as evidence when
463
- // present but never gates the chain on its own.
464
- const alsoOpen = byIds(active, ['auth-providers-social']);
465
- return [...acquisition, ...reach, ...alsoOpen];
646
+ return [...acquisition, ...reach, ...byIds(active, SOCIAL_SIGN_ON)];
466
647
  },
467
648
  },
468
649
  {
@@ -485,21 +666,18 @@ export const NAMED_CHAINS = [
485
666
  'endpoint is cleartext http://, treat the session as already disclosed and change it first, ' +
486
667
  'since anything on the path has seen it. Confirm the outbound message\'s running user is the ' +
487
668
  'least-privileged account that can do the job, because that is the reach being handed out.',
669
+ abuseCase: {
670
+ actor: 'whoever controls the outbound message endpoint',
671
+ goal: 'replay the session it receives as the running user',
672
+ preconditions: [{ ids: SESSION_ID_LEAK }, { ids: SESSION_UNCHECKED }],
673
+ breakPoint: 0,
674
+ breakPointText: 'Clear Send Session ID on the outbound message.',
675
+ },
488
676
  match(_present, active) {
489
- const leak = byIds(active, ['outbound-messages-session-id']);
677
+ const leak = byIds(active, SESSION_ID_LEAK);
490
678
  if (leak.length === 0)
491
679
  return null;
492
- // Why a replayed session would not be stopped or seen. Any one is enough; the point of the
493
- // chain is the credential leaving, and these say what happens next.
494
- const unchecked = byIds(active, [
495
- // Disclosed in transit, so compromising the endpoint is not even required.
496
- 'outbound-messages-cleartext',
497
- // Nothing binds or shortens the session that was handed over.
498
- 'session-hardening-risks', 'session-security-deviations',
499
- 'admin-no-ip-restrictions', 'broad-ip-ranges',
500
- // Nothing would record the replay.
501
- 'event-monitoring-disabled', 'siem-integration-not-detected', 'threat-detection-inactive',
502
- ]);
680
+ const unchecked = byIds(active, SESSION_UNCHECKED);
503
681
  if (unchecked.length === 0)
504
682
  return null;
505
683
  return [...leak, ...unchecked];
@@ -530,21 +708,18 @@ export const NAMED_CHAINS = [
530
708
  'sites that do not depend on it. Treat any credential found in a static resource as ' +
531
709
  'disclosed and rotate it rather than removing the file, since the file has already been ' +
532
710
  'served and may be cached anywhere.',
711
+ abuseCase: {
712
+ actor: 'an anonymous internet caller',
713
+ goal: 'collect org files outside every record control',
714
+ preconditions: [{ ids: ANONYMOUS_FILES }, { ids: FILES_UNACCOUNTED }],
715
+ breakPoint: 0,
716
+ breakPointText: 'Remove anonymous access to files: public documents and static resources, links without expiry or password, and guest file access.',
717
+ },
533
718
  match(_present, active) {
534
- const surface = byIds(active, [
535
- 'public-content-public-documents', 'public-content-public-static-resources',
536
- 'content-links-no-expiry', 'content-links-no-password', 'content-links-stale',
537
- 'guest-site-options-file-access',
538
- ]);
719
+ const surface = byIds(active, ANONYMOUS_FILES);
539
720
  if (surface.length === 0)
540
721
  return null;
541
- // No way to answer "what was in it" or "who took it". Classification and monitoring only:
542
- // content-links-stale is a subset of content-links-no-expiry, so counting it on both sides
543
- // would let one check satisfy the conjunction by itself.
544
- const unaccounted = byIds(active, [
545
- 'data-classification-missing', 'data-encryption-not-detected',
546
- 'event-monitoring-disabled', 'siem-integration-not-detected', 'threat-detection-inactive',
547
- ]);
722
+ const unaccounted = byIds(active, FILES_UNACCOUNTED);
548
723
  if (unaccounted.length === 0)
549
724
  return null;
550
725
  return [...surface, ...unaccounted];
@@ -573,26 +748,21 @@ export const NAMED_CHAINS = [
573
748
  'settings that deviate from the Salesforce baseline and replace insecure http:// CSP trusted ' +
574
749
  'sites with https:// equivalents, both of which widen what an injected script can do once it ' +
575
750
  'runs.',
751
+ abuseCase: {
752
+ actor: 'anyone who can influence a value the page renders',
753
+ goal: "run script in a privileged user's session",
754
+ preconditions: [{ ids: VF_XSS }, { ids: BROWSER_WEAKENED }, { ids: SESSION_TARGETS }],
755
+ breakPoint: 0,
756
+ breakPointText: 'Encode every flagged Visualforce output for the context it lands in.',
757
+ },
576
758
  match(_present, active) {
577
- const vector = byIds(active, [
578
- 'visualforce-xss-escape-false',
579
- 'visualforce-xss-js-merge-field',
580
- 'visualforce-xss-attr-merge-field',
581
- ]);
759
+ const vector = byIds(active, VF_XSS);
582
760
  if (vector.length === 0)
583
761
  return null;
584
- // The browser-side controls that would otherwise contain an injected script. Excludes
585
- // 'experience-csp-verify', which asks the operator to confirm a setting rather than reporting
586
- // a weakness — treating an advisory as a confirmed gap would inflate the chain.
587
- const weakened = byIds(active, ['session-hardening-risks', 'csp-trusted-sites-insecure']);
762
+ const weakened = byIds(active, BROWSER_WEAKENED);
588
763
  if (weakened.length === 0)
589
764
  return null;
590
- // Somebody whose session is worth the trouble.
591
- const targets = byIds(active, [
592
- 'users-super-admin-combo', 'privileged-access-shadow-admins',
593
- 'users-modify-all-data', 'users-view-all-data',
594
- 'separation-of-duties-self-escalation',
595
- ]);
765
+ const targets = byIds(active, SESSION_TARGETS);
596
766
  if (targets.length === 0)
597
767
  return null;
598
768
  return [...vector, ...weakened, ...targets];
@@ -607,17 +777,20 @@ export const NAMED_CHAINS = [
607
777
  'that bypasses CRUD/FLS and sharing. Attackers can trigger unattended data manipulation or code execution without credentials.',
608
778
  remediation: 'Populate AuthorizedSenders on each email service address, set AuthenticationFailureAction to reject spoofed email, ' +
609
779
  'and ensure email handler Apex classes enforce sharing, validate input, and execute as a dedicated least-privilege user.',
780
+ abuseCase: {
781
+ actor: 'any internet email sender',
782
+ goal: 'trigger privileged Apex without credentials',
783
+ preconditions: [{ ids: OPEN_EMAIL_HANDLER }, { ids: EMAIL_FOLLOW_ON }, { capabilities: ['unauth-foothold'] }, { capabilities: ['code-exec'] }],
784
+ breakPoint: 0,
785
+ breakPointText: 'Restrict the email service to authorised senders and reject mail that fails authentication.',
786
+ },
610
787
  match(present, active) {
611
788
  if (!has(present, 'unauth-foothold', 'code-exec'))
612
789
  return null;
613
- const vector = byIds(active, ['inbound-email-handler-unauthenticated-execution']);
790
+ const vector = byIds(active, OPEN_EMAIL_HANDLER);
614
791
  if (vector.length === 0)
615
792
  return null;
616
- const followOn = byIds(active, [
617
- 'apex-crud-fls-without-sharing', 'soql-injection-risk', 'portal-exposed-apex-without-sharing',
618
- 'flows-autolaunched-without-sharing', 'users-modify-all-data', 'users-super-admin-combo',
619
- 'privileged-access-shadow-admins',
620
- ]);
793
+ const followOn = byIds(active, EMAIL_FOLLOW_ON);
621
794
  return followOn.length > 0 ? [...vector, ...followOn] : null;
622
795
  },
623
796
  },
@@ -630,24 +803,25 @@ export const NAMED_CHAINS = [
630
803
  'providing an unauthenticated or low-trust path to system-context privilege escalation and state tampering.',
631
804
  remediation: 'Revoke Create permissions on Platform Events from guest and Experience Cloud profiles. Configure ' +
632
805
  'PlatformEventSubscriberConfig to run event triggers as a dedicated least-privilege user rather than Automated Process or an admin.',
806
+ abuseCase: {
807
+ actor: 'a guest or portal user',
808
+ goal: 'publish an event that runs as a privileged user',
809
+ preconditions: [{ ids: EVENT_PUBLISHER_FOOTHOLD }, { ids: EVENT_SUBSCRIBER_ESCALATION }, { ids: EVENT_PRIVILEGED_TARGETS }, { capabilities: ['unauth-foothold', 'low-trust-authenticated'] }, { capabilities: ['priv-esc', 'data-write'] }],
810
+ breakPoint: 1,
811
+ breakPointText: 'Run event subscribers as a dedicated least-privilege user, not Automated Process or an administrator.',
812
+ },
633
813
  match(present, active) {
634
814
  if (!hasAny(present, 'unauth-foothold', 'low-trust-authenticated'))
635
815
  return null;
636
816
  if (!hasAny(present, 'priv-esc', 'data-write'))
637
817
  return null;
638
- const escalation = byIds(active, ['platform-event-subscriber-escalation']);
818
+ const escalation = byIds(active, EVENT_SUBSCRIBER_ESCALATION);
639
819
  if (escalation.length === 0)
640
820
  return null;
641
- const foothold = byIds(active, [
642
- 'guest-user-read-access', 'guest-user-write-access', 'guest-user-sharing-exposure', 'guest-user-baseline',
643
- 'sharing-model-external-read', 'sharing-model-external-write', 'experience-cloud-site-self-registration',
644
- ]);
821
+ const foothold = byIds(active, EVENT_PUBLISHER_FOOTHOLD);
645
822
  if (foothold.length === 0)
646
823
  return null;
647
- const targets = byIds(active, [
648
- 'users-super-admin-combo', 'users-modify-all-data', 'privileged-access-shadow-admins',
649
- ]);
650
- return [...foothold, ...escalation, ...targets];
824
+ return [...foothold, ...escalation, ...byIds(active, EVENT_PRIVILEGED_TARGETS)];
651
825
  },
652
826
  },
653
827
  ];