@cclabsnz/sf-audit 1.19.0 → 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 (38) hide show
  1. package/CHANGELOG.md +31 -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 +5 -5
  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/incident/collect/orgErrors.js +3 -1
  19. package/lib/incident/collect/streamGuestLogs.js +3 -2
  20. package/lib/lib/apiErrorText.d.ts +8 -0
  21. package/lib/lib/apiErrorText.js +15 -0
  22. package/lib/renderers/AttackChainDagRenderer.d.ts +5 -1
  23. package/lib/renderers/AttackChainDagRenderer.js +16 -31
  24. package/lib/renderers/ClientReportRenderer.js +4 -1
  25. package/lib/renderers/HtmlRenderer.js +10 -2
  26. package/lib/renderers/MarkdownRenderer.js +61 -2
  27. package/lib/renderers/SarifRenderer.js +10 -2
  28. package/lib/threats/linddun.d.ts +3 -0
  29. package/lib/threats/linddun.js +40 -0
  30. package/lib/threats/resolve.d.ts +8 -0
  31. package/lib/threats/resolve.js +18 -0
  32. package/lib/threats/stride.d.ts +3 -0
  33. package/lib/threats/stride.js +120 -0
  34. package/lib/threats/types.d.ts +16 -0
  35. package/lib/threats/types.js +22 -0
  36. package/lib/threats/view.d.ts +27 -0
  37. package/lib/threats/view.js +51 -0
  38. package/package.json +3 -3
package/CHANGELOG.md CHANGED
@@ -9,6 +9,37 @@ published note and carries the signed provenance attestation and CycloneDX SBOM
9
9
 
10
10
  ## [Unreleased]
11
11
 
12
+ ## [v1.20.0](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.20.0) — 2026-10-28
13
+
14
+ Findings now say which threats they enable, and each named attack chain says who would run it and
15
+ which single fix stops it.
16
+
17
+ ### Added
18
+
19
+ - **STRIDE and LINDDUN on every finding.** Each check is mapped to the STRIDE categories it guards (all 109 checks) and, where personal data is involved, to LINDDUN privacy categories (32 checks). Findings carry them as `threats` in JSON, as a **Threats:** line in Markdown, and as `stride:` / `linddun:` rule tags in SARIF. Tagging never changes severity, score or grade.
20
+ - **Threat view in the Markdown report.** One row per category, reading "N findings (from N checks)", "no findings from N checks", "not assessed in this run" or "not assessed by this tool". An empty category is never shown as assurance, and privacy and security readings of the same finding are kept apart, not netted against each other.
21
+ - **Named attack chains are abuse cases.** Every named chain states its actor, goal and preconditions, and its break point: the fix that stops the chain in every case it fires. Markdown, HTML and the executive report show "Abuse case:" and "Breaks the chain:", with the full remediation below it. SARIF chain results carry `abuseCase`, and break-point steps carry `breaksChain`.
22
+
23
+ ### Changed
24
+
25
+ - **The attack-chain diagram marks the proven break point** ("✂ BREAK POINT", on every step of a multi-step break point) instead of guessing one cut-point. Steps whose capability was inferred no longer show a capability label.
26
+ - Potential chains label their fix text "Recommended fixes" in Markdown, HTML and the executive report, since no single break point is proven for them.
27
+ - **`cred-theft-pivot` needs an exposed secret.** The chain now fires only when one of its steps exposes a credential (including credentials stored in custom settings), so orgs without one no longer show it.
28
+ - **Moves to `@cclabsnz/sf-core` 0.12.** `queryAll` now reads every page instead of stopping at the client's row limit, so reads that came back short on large orgs are complete.
29
+
30
+ ### Fixed
31
+
32
+ - **The executive report's "Breaks the chain" line no longer shows the full remediation list.** It now names the break point; the full list follows as "Full remediation".
33
+ - **An expired session stops `incident collect` again.** sf-core 0.12 reports a failed log download as `INVALID_SESSION_ID` instead of "HTTP 401", so collect recorded every remaining log as failed instead of stopping. Error classifiers now read the error's code and status, not only its message.
34
+ - A Salesforce error that arrives with only a code (`INSUFFICIENT_ACCESS`, or `ERROR_HTTP_403` with no body) is classified as a permission problem in `incident collect` and the API log listing, and `ERROR_HTTP_404` counts as a missing object in the checks that probe for optional features.
35
+ - **A malformed agent query no longer reads as "Agentforce not enabled".** The AI & Agents checks counted `MALFORMED_QUERY` as an absent object, which became reachable with sf-core 0.12; they now share the missing-object test the other checks use, so a broken query is inconclusive.
36
+ - A failed download whose error body is empty now names its code and status (`ERROR_HTTP_403 HTTP 403`) in `incident collect` and the API log listing, instead of an empty reason.
37
+ - `users-and-admins` no longer advises raising `org-max-query-limit`, which no longer limits the read. When the assignment count differs from the rows read, it advises re-running the audit.
38
+
39
+ ### Security
40
+
41
+ - `fast-uri` pinned to 3.1.9 or later, closing Dependabot alerts #44–47. (#181)
42
+
12
43
  ## [v1.19.0](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.19.0) — 2026-10-23
13
44
 
14
45
  When the audit user cannot see who holds Modify All Data or View All Data, the report now says so
@@ -1,6 +1,7 @@
1
1
  import { mkdtempSync, readFileSync, rmSync } from 'node:fs';
2
2
  import { tmpdir } from 'node:os';
3
3
  import { join } from 'node:path';
4
+ import { apiErrorText } from '../lib/apiErrorText.js';
4
5
  export const API_LOG_TYPES = ['RestApi', 'BulkApi2', 'GraphQlQueryExecution', 'AuraRequest'];
5
6
  /** Thrown when the EventLogFile listing itself fails: there is no usage to analyze at all. */
6
7
  export class ApiLogListingError extends Error {
@@ -24,7 +25,7 @@ export async function downloadApiLogs(deps, since) {
24
25
  `AND LogDate = LAST_N_DAYS:${since} ORDER BY LogDate DESC`);
25
26
  }
26
27
  catch (e) {
27
- const msg = e instanceof Error ? e.message : String(e);
28
+ const msg = apiErrorText(e);
28
29
  const permission = /INSUFFICIENT_ACCESS|HTTP 403|INVALID_TYPE|not supported/i.test(msg);
29
30
  throw new ApiLogListingError(permission
30
31
  ? `Cannot list API event logs: EventLogFile is not readable (the running user needs View Event Log Files, and the org needs Event Monitoring). ${msg}`
@@ -46,7 +47,7 @@ export async function downloadApiLogs(deps, since) {
46
47
  }
47
48
  }
48
49
  catch (e) {
49
- failed.push({ id: r.Id, eventType: r.EventType, error: e instanceof Error ? e.message : String(e) });
50
+ failed.push({ id: r.Id, eventType: r.EventType, error: apiErrorText(e) });
50
51
  }
51
52
  finally {
52
53
  rmSync(tmp, { force: true });
@@ -5,9 +5,19 @@ export interface AttackChainStep {
5
5
  checkId?: string;
6
6
  /** The capability this step contributes to the chain. */
7
7
  capability: Capability;
8
+ /** The finding grants no capability; `capability` is a fallback and is not rendered (RULE-110). */
9
+ capabilityInferred?: true;
10
+ /** The step belongs to the named chain's break point: fixing all such steps stops the chain (RULE-111). */
11
+ breaksChain?: true;
8
12
  title?: string;
9
13
  severity?: RiskLevel;
10
14
  }
15
+ /** A named chain's abuse case as rendered: roles and plain language, never finding ids (RULE-112). */
16
+ export interface AttackChainAbuseCase {
17
+ actor: string;
18
+ goal: string;
19
+ breakPoint: string;
20
+ }
11
21
  export interface AttackChain {
12
22
  id: string;
13
23
  title: string;
@@ -15,6 +25,8 @@ export interface AttackChain {
15
25
  confidence: 'named' | 'potential';
16
26
  narrative: string;
17
27
  remediation: string;
28
+ /** Named chains only; potential chains have no proven break point. */
29
+ abuseCase?: AttackChainAbuseCase;
18
30
  steps: AttackChainStep[];
19
31
  }
20
32
  //# sourceMappingURL=AttackChain.d.ts.map
@@ -1,6 +1,6 @@
1
1
  import { SOURCE_CAPS, HIGH_IMPACT_SINKS } from './Capability.js';
2
2
  import { capabilitiesFor } from './CapabilityRegistry.js';
3
- import { NAMED_CHAINS } from './namedChains.js';
3
+ import { NAMED_CHAINS, inGroup } from './namedChains.js';
4
4
  const SEVERITY_ORDER = {
5
5
  CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3, INFO: 4,
6
6
  };
@@ -41,13 +41,16 @@ export class ChainEngine {
41
41
  return (c.confidence === 'named' ? 0 : 100) + SEVERITY_ORDER[c.severity];
42
42
  }
43
43
  stepFor(f, grants) {
44
- return {
44
+ const step = {
45
45
  findingId: f.id,
46
46
  checkId: f.checkId,
47
47
  capability: grants[0] ?? 'data-read',
48
48
  title: f.title,
49
49
  severity: f.riskLevel,
50
50
  };
51
+ if (grants.length === 0)
52
+ step.capabilityInferred = true;
53
+ return step;
51
54
  }
52
55
  runNamedPass(present, active, grantsByFinding) {
53
56
  const out = [];
@@ -62,7 +65,13 @@ export class ChainEngine {
62
65
  confidence: 'named',
63
66
  narrative: def.narrative,
64
67
  remediation: def.remediation,
65
- steps: members.map((f) => this.stepFor(f, grantsByFinding.get(f) ?? [])),
68
+ abuseCase: { actor: def.abuseCase.actor, goal: def.abuseCase.goal, breakPoint: def.abuseCase.breakPointText },
69
+ steps: members.map((f) => {
70
+ const step = this.stepFor(f, grantsByFinding.get(f) ?? []);
71
+ if (inGroup(f, def.abuseCase.preconditions[def.abuseCase.breakPoint]))
72
+ step.breaksChain = true;
73
+ return step;
74
+ }),
66
75
  });
67
76
  }
68
77
  return out;
@@ -1,14 +1,86 @@
1
1
  import type { RiskLevel } from '@cclabsnz/sf-core';
2
2
  import type { Finding } from '../findings/Finding.js';
3
3
  import type { Capability } from './Capability.js';
4
+ /**
5
+ * Findings a chain reads: by exact id, by id prefix, or any finding granting one of the capabilities.
6
+ * A group is satisfied by any one member; a chain that needs two capabilities lists two groups.
7
+ */
8
+ export interface FindingGroup {
9
+ ids?: readonly string[];
10
+ prefixes?: readonly string[];
11
+ capabilities?: readonly Capability[];
12
+ }
13
+ /**
14
+ * A named chain as a structured abuse case (RULE-110). `preconditions` are the groups `match()`
15
+ * reads, built from the same constants; `breakPoint` indexes the one group whose complete removal
16
+ * stops the chain (RULE-111). The prose fields name roles, never people or finding ids (RULE-112).
17
+ */
18
+ export interface AbuseCaseDef {
19
+ actor: string;
20
+ goal: string;
21
+ preconditions: readonly FindingGroup[];
22
+ breakPoint: number;
23
+ /** What to fix to break the chain, in plain language for every output. */
24
+ breakPointText: string;
25
+ }
4
26
  export interface NamedChainDef {
5
27
  id: string;
6
28
  title: string;
7
29
  severity: RiskLevel;
8
30
  narrative: string;
9
31
  remediation: string;
32
+ abuseCase: AbuseCaseDef;
10
33
  /** Returns the member findings (chain steps) if present in this org, else null. */
11
34
  match(present: Set<Capability>, active: Finding[]): Finding[] | null;
12
35
  }
36
+ /** True when the finding belongs to the group (a capability group matches on granted capabilities). */
37
+ export declare function inGroup(f: Finding, g: FindingGroup): boolean;
38
+ export declare const GUEST_EXPOSURE: string[];
39
+ export declare const LOW_TRUST_ENTRY: string[];
40
+ export declare const NON_ADMIN_ESCALATION: string[];
41
+ export declare const UNAUTH_EXFIL_STEPS: string[];
42
+ export declare const UNAUTH_EXFIL_WIDENERS: string[];
43
+ export declare const GUEST_TRAFFIC: string[];
44
+ export declare const GUEST_BULK_SURFACE: string[];
45
+ export declare const TAKEOVER_ADMIN_EVIDENCE: string[];
46
+ export declare const EXPOSED_SECRETS: string[];
47
+ export declare const EGRESS_PATHS: string[];
48
+ export declare const SOQL_INJECTION: string[];
49
+ export declare const SOQL_READ_SINKS: string[];
50
+ export declare const AGENT_GUEST_CHANNEL: string[];
51
+ export declare const AGENT_PRIVILEGE: string[];
52
+ export declare const AGENT_WRITE_ACTIONS: string[];
53
+ export declare const ACTIVE_AGENTS: string[];
54
+ export declare const STALE_TRUSTED_URL: string[];
55
+ export declare const AGENT_NO_CAPTURE: string[];
56
+ export declare const AGENT_QUERY_REACH: string[];
57
+ export declare const AGENT_OUTBOUND: string[];
58
+ export declare const UNTRUSTED_INPUT: string[];
59
+ export declare const SANDBOX_PII: string[];
60
+ export declare const SANDBOX_WEAK_CONTROLS: string[];
61
+ export declare const INSIDER_BROAD_READ: string[];
62
+ export declare const INSIDER_BULK_EGRESS: string[];
63
+ export declare const INSIDER_BLIND_SPOT: string[];
64
+ export declare const DETECTION_BLIND_SPOTS: string[];
65
+ export declare const EXPLOITABLE_ACCESS: readonly Capability[];
66
+ export declare const MFA_WEAKNESS: string[];
67
+ export declare const PRIVILEGED_ACCOUNTS: string[];
68
+ export declare const OAUTH_STANDING: string[];
69
+ export declare const OAUTH_UNCONTAINED: string[];
70
+ export declare const SELF_REGISTRATION: string[];
71
+ export declare const PORTAL_REACH: string[];
72
+ export declare const SOCIAL_SIGN_ON: string[];
73
+ export declare const SESSION_ID_LEAK: string[];
74
+ export declare const SESSION_UNCHECKED: string[];
75
+ export declare const ANONYMOUS_FILES: string[];
76
+ export declare const FILES_UNACCOUNTED: string[];
77
+ export declare const VF_XSS: string[];
78
+ export declare const BROWSER_WEAKENED: string[];
79
+ export declare const SESSION_TARGETS: string[];
80
+ export declare const OPEN_EMAIL_HANDLER: string[];
81
+ export declare const EMAIL_FOLLOW_ON: string[];
82
+ export declare const EVENT_SUBSCRIBER_ESCALATION: string[];
83
+ export declare const EVENT_PUBLISHER_FOOTHOLD: string[];
84
+ export declare const EVENT_PRIVILEGED_TARGETS: string[];
13
85
  export declare const NAMED_CHAINS: NamedChainDef[];
14
86
  //# sourceMappingURL=namedChains.d.ts.map