@cclabsnz/sf-audit 1.23.0 → 1.24.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +70 -0
- package/PERMISSIONS.md +16 -2
- package/docs/permissionset/SF_Audit_MFA.permissionset-meta.xml +36 -0
- package/lib/chains/Capability.d.ts +1 -1
- package/lib/chains/Capability.js +1 -1
- package/lib/chains/CapabilityRegistry.js +20 -7
- package/lib/chains/ChainEngine.js +10 -2
- package/lib/chains/namedChains.d.ts +1 -0
- package/lib/chains/namedChains.js +79 -26
- package/lib/checks/impl/ApexCrudFLSCheck.js +11 -2
- package/lib/checks/impl/ApexRestEndpointCheck.js +15 -7
- package/lib/checks/impl/ApexSharingCheck.js +19 -8
- package/lib/checks/impl/FlowsWithoutSharingCheck.d.ts +1 -1
- package/lib/checks/impl/FlowsWithoutSharingCheck.js +17 -12
- package/lib/checks/impl/GuestExecutableApexCheck.js +18 -9
- package/lib/checks/impl/GuestObjectExposureCheck.d.ts +6 -7
- package/lib/checks/impl/GuestObjectExposureCheck.js +123 -38
- package/lib/checks/impl/GuestSiteOptionsCheck.js +40 -6
- package/lib/checks/impl/GuestUserAccessCheck.d.ts +1 -0
- package/lib/checks/impl/GuestUserAccessCheck.js +88 -57
- package/lib/checks/impl/GuestUserVisibilityCheck.d.ts +9 -6
- package/lib/checks/impl/GuestUserVisibilityCheck.js +59 -66
- package/lib/checks/impl/MfaMethodStrengthCheck.js +2 -2
- package/lib/checks/impl/MfaRegistrationCheck.d.ts +1 -1
- package/lib/checks/impl/MfaRegistrationCheck.js +52 -18
- package/lib/checks/impl/PublicGroupSharingCheck.js +7 -2
- package/lib/checks/impl/ReleaseUpdatesCheck.js +1 -1
- package/lib/checks/impl/SsoEnforcementCheck.js +6 -4
- package/lib/checks/support/apexAccess.d.ts +21 -1
- package/lib/checks/support/apexAccess.js +55 -0
- package/lib/checks/support/guestShares.d.ts +39 -0
- package/lib/checks/support/guestShares.js +113 -0
- package/lib/findings/CheckMeta.js +2 -2
- package/lib/preflight/permissions.d.ts +1 -1
- package/lib/preflight/permissions.js +10 -2
- package/lib/renderers/ClientReportRenderer.js +8 -6
- package/lib/threats/attack.js +1 -0
- package/lib/threats/view.d.ts +1 -1
- package/lib/threats/view.js +2 -1
- package/package.json +3 -2
package/CHANGELOG.md
CHANGED
|
@@ -9,6 +9,76 @@ published note and carries the signed provenance attestation and CycloneDX SBOM
|
|
|
9
9
|
|
|
10
10
|
## [Unreleased]
|
|
11
11
|
|
|
12
|
+
## [v1.24.1](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.24.1) — 2026-11-01
|
|
13
|
+
|
|
14
|
+
The threat model reads as the threats it found. Inventory lines no longer sit in the STRIDE view as
|
|
15
|
+
open findings, and the MFA bypass chain fires only when a privileged user can actually sign in
|
|
16
|
+
without a second factor, starting at initial access on the ATT&CK slide.
|
|
17
|
+
|
|
18
|
+
### Fixed
|
|
19
|
+
|
|
20
|
+
- The threat view (Markdown Threat View, executive STRIDE heatmap and LINDDUN bars) no longer
|
|
21
|
+
counts INFO results as open findings. An inventory line such as "0 scheduled jobs
|
|
22
|
+
found" or "No certificates found" sat under a STRIDE category as if it were a threat. The heatmap
|
|
23
|
+
loses its Info column; the check still counts as coverage for its category (RULE-104).
|
|
24
|
+
- The insider bulk-export chain narrative reads without an em dash.
|
|
25
|
+
- **MFA bypass to privileged compromise** fires only when the MFA weakness reaches a privileged user:
|
|
26
|
+
a trusted IP range (which exempts everyone), or users without MFA that include an admin-level
|
|
27
|
+
holder (a full 50-user list counts, since the list stops there). Portal users without MFA no
|
|
28
|
+
longer fire it on their own, since a portal user is not an admin. Some grades rise where that
|
|
29
|
+
was the only path.
|
|
30
|
+
- The same chain now starts at **Initial access** on the ATT&CK slide. Weak MFA grants a new
|
|
31
|
+
`valid-account` capability, mapped to T1078.004 Valid Accounts: Cloud Accounts, so the three MFA
|
|
32
|
+
findings now carry T1078.004 in every output (Markdown, HTML, JSON, SARIF). It is not an entry
|
|
33
|
+
point of a potential chain, so no other chain changes.
|
|
34
|
+
|
|
35
|
+
## [v1.24.0](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.24.0) — 2026-10-30
|
|
36
|
+
|
|
37
|
+
Several checks were filtering on values the platform never writes, so they found nothing; they now
|
|
38
|
+
find what they look for. Guest exposure is graded one way, Apex follows the API 67.0 sharing and
|
|
39
|
+
user-mode defaults, and MFA registration reads every method. Some grades will fall where exposures
|
|
40
|
+
are newly found, and some will rise where findings were overstated.
|
|
41
|
+
|
|
42
|
+
### Added
|
|
43
|
+
|
|
44
|
+
- **An optional permission set for MFA registration**, `docs/permissionset/SF_Audit_MFA.permissionset-meta.xml`, separate from the read-only one. Salesforce grants "Manage MFA in API" only with user-management permissions, so it is meant for an audit user who is already an administrator.
|
|
45
|
+
|
|
46
|
+
- **`docs/FEATURES.md` lists what sf-audit already does**: commands, checks, attack chains, renderers, shared helpers, framework mappings and test tooling, each with its file. Search it before building something. A test fails when a check, chain, command, shared helper, renderer or chain module is missing from it.
|
|
47
|
+
- **The schema guard catches filters that match nothing.** The schema snapshot now keeps picklist values (all but geography, locale, currency and encoding lists, and without custom or namespaced values), and a query that filters on a value the picklist does not have fails the guard. A new deep-path guard seeds a consistent org so checks get past their first empty result, and validates the queries behind it.
|
|
48
|
+
|
|
49
|
+
### Security
|
|
50
|
+
|
|
51
|
+
- **deepmerge is pinned to 4.1.1 under jest.** GHSA-gcqx-w48m-w2h4 (prototype poisoning in `mergeObject()`, low) affects 4.2.0 to 4.3.1 and has no patched release. deepmerge reaches the project only through `jest-config`, a development dependency, and jest runs unchanged on 4.1.1, which is outside the affected range.
|
|
52
|
+
|
|
53
|
+
### Fixed
|
|
54
|
+
|
|
55
|
+
- **Guest-executable Apex is found again.** The check read Apex class access by filtering `SetupEntityAccess.ParentId` on the guest profile Ids. That field holds permission set Ids, so in a real org it matched nothing and reported "Guest profiles cannot execute any Apex classes". It now reads the guest users' permission sets, both the one each guest profile owns and any assigned to the guest. Some orgs will see new `guest-executable-apex-*` findings and the unauthenticated bulk-exfiltration chain they open, so some grades may fall.
|
|
56
|
+
- **The unauthenticated bulk-exfiltration chain needs the guest to reach the data itself.** The bulk read, write or code execution must now come from one of its guest-side steps. Before, an internal user's View All Data or an admin's Author Apex, together with any guest exposure, was enough to fire it. The potential-chain pass no longer pairs a guest foothold with those internal grants either.
|
|
57
|
+
- **The same chain no longer counts Apex or Flow that is only shown to run without sharing.** `portal-exposed-apex-without-sharing` flags classes with `@AuraEnabled`, `@RemoteAction` or `@RestResource` methods that lack sharing enforcement, and `flows-*-without-sharing` flags flows by run mode. Neither shows that a guest can call them. Guest-callable Apex is counted through `guest-executable-apex-*`.
|
|
58
|
+
- **A public external OWD on a guest-readable object no longer makes it CRITICAL.** Secure guest record access has been enforced since Winter '21, so the external OWD alone gives guests nothing: record sharing gives a guest a record only through sharing or ownership. `guest-object-exposure-public-owd` now needs `UserRecordAccess` to show that a guest user (every site's guest user is checked) can read one of up to 200 sampled records, and it is HIGH, like every other way records are shared with guests (see below). An object whose records a guest user owns stays CRITICAL as `guest-object-exposure-guest-owned`. Otherwise the check reports the new MEDIUM finding `guest-object-exposure-public-owd-unconfirmed`, which feeds no attack chain and notes whether the probe ran.
|
|
59
|
+
- **The unauthenticated bulk-exfiltration chain needs a step that reaches records.** Guest API access, guest object permissions, or guest-callable Apex not shown to bypass sharing reach nothing on their own under secure guest record access, yet any one of them, beside a guest user existing, fired a CRITICAL chain. The potential-chain pass does not report them as a guest path either. One step must now show the guest reaching records: a guest sharing rule, guest-owned or confirmed-readable records, the whole User roster, guest-callable Apex that runs without sharing, or secure guest record access not being enforced.
|
|
60
|
+
- **The flows-without-sharing check flags the flows it names.** It flagged autolaunched and screen flows in Default Mode, where a screen flow runs as the user, and missed flows explicitly set to run in system context without sharing. It now flags autolaunched and screen flows explicitly set that way, so most orgs will see fewer of these findings and some will see new ones. Record-, schedule- and platform-event-triggered flows always run that way, have no setting to change, and are not flagged.
|
|
61
|
+
- **Guest exposure findings say what a guest can do.** Affected items read "guest Create permission" instead of "guest WRITE": guests cannot hold Edit or Delete since Winter '21. The guest-owned remediation now says to reassign existing records, instead of enabling two settings the platform has enforced since Winter '21.
|
|
62
|
+
- **Guest sharing rules are found.** The guest-access and public-group sharing checks counted share rows with `RowCause = 'SharingRule'`, a value the platform never writes, so they found no sharing rule at all. They now count `Rule`, and the guest check also counts `GuestRule`, the value guest user sharing rules write. Orgs with guest or public-group sharing rules will see new findings, and some grades may fall.
|
|
63
|
+
- **MFA registration covers the same users as the count.** Frozen users are now dropped from the registrations, as they already were from the count, and the 2000-row cap is gone.
|
|
64
|
+
- **Apex classes saved at API 67.0 or later are no longer reported for a missing sharing keyword.** From Summer '26 an Apex class compiled at API 67.0 or later that declares no sharing keyword runs with sharing. The guest-executable Apex, Apex sharing and Apex REST endpoint checks now read each class's API version. They report a keyword-less class only when it, or a keyword-less parent it inherits from, is below 67.0, or when its version cannot be read. A keyword-less guest-callable class at 67.0 drops from CRITICAL to the HIGH "executable by guests" finding, so some grades may rise. The REST check now also follows inheritance: an endpoint that extends a `without sharing` class is reported as without sharing.
|
|
65
|
+
- **A keyword-less class reached only from Aura or LWC is no longer reported as running without sharing.** Since Winter '21 an `@AuraEnabled` call into a class with no sharing keyword runs with sharing. A class whose only way in is `@AuraEnabled` (no REST, SOAP, remoting or Visualforce use) leaves the guest CRITICAL finding and the portal-exposed list. The Apex sharing check still lists it below API 67.0 as missing a keyword.
|
|
66
|
+
- **Apex saved at API 67.0 or later is no longer reported for missing CRUD/FLS checks.** From that version queries and DML run in user mode by default, which enforces object and field permissions. SYSTEM_MODE in such a class is still reported.
|
|
67
|
+
- **Records shared with guests are found, whatever the object's OWD.** The guest object exposure check looked only for guest-owned records when an object's external OWD was Private, so it missed guest user sharing rules, the main way a guest reaches records under secure guest record access. The guest-access check looked only at sharing-rule rows naming the guest user. Both now read share tables the same way. A row gives guests access when it comes from a guest sharing rule, or from the parent or person-account access one implies, whoever it names. It also counts when it is a manual, Apex or group share naming a guest user or a public group or queue a guest belongs to. Winter '21 did not remove those. The guest-access check reports Account, Case, Contact and Opportunity (`guest-user-sharing-exposure`). The guest object exposure check reports every other guest-readable object as the new HIGH finding `guest-object-exposure-guest-shared`, falling back to `UserRecordAccess` on a sample when the share table shows nothing or cannot be read. Shares to a site's guest user group count too, and group membership is followed through nested groups. The guest-access check also asks `UserRecordAccess` on a sample when Account, Case, Contact or Opportunity show no share row, or the share table cannot be read: for example a Contact controlled by its parent. It asks only where a guest can read the object and owns none of its records. The guest object exposure check leaves those four objects to it, except for guest-owned records, so each exposure is reported once.
|
|
68
|
+
- **Guest object access is found again.** The guest-access check filtered `ObjectPermissions.ParentId` on the guest profile Ids. That field holds permission set Ids, so it never found a guest Read, Create, Edit or Delete on Account, Contact, Case, Lead or Opportunity, and `guest-user-read-access` and `guest-user-write-access` could not fire. It now reads the guest users' permission sets: the one each guest profile owns, and any assigned to a guest. Some orgs will see these findings for the first time, and some grades may fall. It is HIGH, not CRITICAL, because a guest sharing rule is how a site publishes records on purpose: the finding asks the org to confirm they are meant to be public. Share rows on a public-OWD object are graded the same way, since the external OWD does not reach guests. All of these count as the guest reaching records in the unauthenticated bulk-exfiltration chain, which still needs a guest step that reads in bulk, writes or runs code (guest API access, guest-owned records, guest-callable Apex without sharing). Guest-owned records remain the CRITICAL bulk sink. Some grades may fall.
|
|
69
|
+
- **A public external OWD on User no longer counts as a guest exposure.** Secure guest record access keeps the guest OWD Private on every object, User included, so `guest-user-visibility-owd` shows the staff roster to logged-in portal and community users, not to guests. It is now MEDIUM instead of HIGH, says who it reaches, is reported whether or not the org has a guest user (but only when it has an active external user or an Experience Cloud site, so someone can be reached), and feeds the low-trust chains (such as self-registration) instead of the unauthenticated one.
|
|
70
|
+
- **Guest member visibility counts only on live sites, and as a read.** "Let guest users see other members of this site" shows a live site's members to guests. It now joins the unauthenticated chain as a step when that chain fires, but it opens no chain, unauthenticated or low-trust, since it shows members, not business records. On a site that is not live it is reported apart, at LOW, as `guest-site-options-member-visibility-not-live`.
|
|
71
|
+
- **MFA registration reads every method.** The check read `TwoFactorInfo`, whose `Type` can only be `TOTP`, so users registered with Salesforce Authenticator, a security key or a built-in authenticator counted as unregistered (`TwoFactorInfo.Type` has `TOTP` as its only picklist value). It now reads `TwoFactorMethodsInfo`. An authenticator app, Salesforce Authenticator, a security key or a built-in authenticator counts as registered. A verified phone number or email address, or a temporary code, does not: those are sign-in fallbacks. Only registered users go to the method strength check, with every method they hold. A user with just a phone number or email address is reported as unregistered, not graded as having weak MFA, so an admin who verified an email address no longer rates worse than one who did nothing. Preflight now reports the permission as optional. The object needs "Manage MFA in API", which Salesforce grants only with user-management permissions. It is therefore optional and not in the read-only permission set; see PERMISSIONS.md.
|
|
72
|
+
- **The guest User visibility check no longer looks for a Read grant on User.** User takes no object permissions, so `ObjectPermissions` never holds a User row (a Developer Edition org had none across all its permission sets, against 141 for Account), and `guest-user-visibility-object-read` could never fire. The leg and its finding are removed. Guest access to the roster is still reported through View All Users and a site's guest member visibility.
|
|
73
|
+
- **The guest read probe samples both ends of an object's history.** It took the first 200 records in no order, so a share matching only recent records could read as no guest access. It now samples the 100 most and 100 least recently changed records, and falls back to an unordered sample when the object cannot be ordered.
|
|
74
|
+
- **Guest file access counts only on live sites.** As with member visibility, a site that is not live is reported apart, at LOW, as `guest-site-options-file-access-not-live`, and feeds no chain.
|
|
75
|
+
- **The Apex REST check reads `without sharing` from code.** A comment or string containing the words no longer marks an endpoint as running without sharing. An inner class declared `without sharing` still counts.
|
|
76
|
+
- **Three checks filtered on values the platform never writes, so they found nothing.** Salesforce accepts a filter on a picklist value that does not exist and matches no rows, so these checks passed in every org:
|
|
77
|
+
- **SSO enforcement** looked for `LoginType = 'Username-Password'`. Credential logins are recorded in `LoginSubType` (`UI Username-Password`, `OAuth Username-Password`), which the check now reads. Orgs where users still log in with Salesforce credentials will see the finding.
|
|
78
|
+
- **Public group sharing** looked for the All Internal Users group as `Group.Type = 'AllInternal'`. That group's type is `Organization`. Orgs that share records to All Internal Users through sharing rules will see the finding.
|
|
79
|
+
- **Release updates** also asked for a `Revoked` status, which does not exist. The check's results do not change.
|
|
80
|
+
Some grades may fall.
|
|
81
|
+
|
|
12
82
|
## [v1.23.0](https://github.com/cclabsnz/sf-audit-plugin/releases/tag/v1.23.0) — 2026-10-29
|
|
13
83
|
|
|
14
84
|
Attack chains and checks now match what the platform does. One chain is re-rated, so some grades may
|
package/PERMISSIONS.md
CHANGED
|
@@ -38,7 +38,7 @@ permissions below, and nothing else. A starter permission-set definition is in
|
|
|
38
38
|
| **API Enabled** | `ApiEnabled` | All access is via SOQL/Tooling/REST over the API | Audit cannot run at all |
|
|
39
39
|
| **View Setup and Configuration** | `ViewSetup` | Reads the bulk of the surface: `SetupAuditTrail`, `TraceFlag`, `ConnectedApplication`, `RemoteProxy`, `CorsWhitelistEntry`, `CspTrustedSite`, `NamedCredential`, `AuthConfig`, `CriticalUpdate`/release updates, `Network` (Experience sites), `ProfileLoginIpRange`, `NetworkAccess`, `Certificate`, `ExternalString` (Custom Labels), `OrgWideEmailAddress`, `EmailServicesFunction`/`EmailServicesAddress`, and Tooling metadata (`ApexClass`, `Flow`, `CustomObject`/`CustomField`, `EntityDefinition`, `FieldDefinition`, `FieldPermissions`, `ObjectPermissions`, `SetupEntityAccess`, `WorkflowOutboundMessage`, `StaticResource`) | Most setup/config checks return **inconclusive** |
|
|
40
40
|
| **Read `OauthToken`** | n/a (object read) | Standing OAuth authorisations per app, for `oauth-token-inventory`. Read separately from `ConnectedApplication`: a refresh token is exchanged without producing a login, so this is the only surface that shows an app which can still act | `oauth-token-inventory` returns **inconclusive** rather than reporting an org with no standing tokens |
|
|
41
|
-
| **View All Users** | `ViewAllUsers` | Enumerate every `User`, `UserLogin
|
|
41
|
+
| **View All Users** | `ViewAllUsers` | Enumerate every `User`, `UserLogin` and `PermissionSetAssignment` record org-wide (not just role-hierarchy-visible users) | User/admin/MFA checks under-count and miss accounts |
|
|
42
42
|
| **View Health Check** | `ViewHealthCheckScreen` | Read `SecurityHealthCheck` and `SecurityHealthCheckRisks` (Tooling) | Health Check + Password/Session checks inconclusive |
|
|
43
43
|
| **Author Apex** | `AuthorApex` | **Read-only use:** the only standard gate that exposes `ApexClass`/`ApexTrigger`/`ApexPage` **`Body`** via the Tooling API. Used by the ~9 Apex/Visualforce code-security checks. Grants *no* ability to modify org data | The 9 code-security checks return **inconclusive**; rest of the audit is unaffected |
|
|
44
44
|
| **View Event Log Files** | `ViewEventLogFiles` | Read `EventLogFile` for the Event Monitoring check | Event Monitoring check inconclusive |
|
|
@@ -49,6 +49,20 @@ permissions below, and nothing else. A starter permission-set definition is in
|
|
|
49
49
|
|---|---|---|
|
|
50
50
|
| **View Roles and Role Hierarchy** | `ViewRoles` | Complete visibility of role-based sharing context |
|
|
51
51
|
|
|
52
|
+
### Optional, and not in the read-only set: MFA registration
|
|
53
|
+
|
|
54
|
+
`mfa-registration` reads `TwoFactorMethodsInfo`, which records each user's MFA methods. The
|
|
55
|
+
object is hidden without **Manage MFA in API** (`ManageTwoFactor`), and Salesforce will not grant
|
|
56
|
+
that permission without user-management permissions alongside it: Manage Users, Manage Internal
|
|
57
|
+
Users, Manage Sharing, Manage Roles, Reset Passwords, Freeze Users, Manage Profiles and Permission
|
|
58
|
+
Sets, Assign Permission Sets and others. That is far more than a read-only audit needs, so it is
|
|
59
|
+
not in `SF_Audit_ReadOnly`. Without it the check returns **inconclusive** and says why, and
|
|
60
|
+
`mfa-method-strength` has nothing to grade. Grant it only where the audit runs as an
|
|
61
|
+
administrator who already holds those permissions, using the separate
|
|
62
|
+
[`SF_Audit_MFA`](docs/permissionset/SF_Audit_MFA.permissionset-meta.xml) permission set: on a
|
|
63
|
+
System Administrator it adds just Manage MFA in API. Otherwise review MFA registration in Setup →
|
|
64
|
+
Identity → Identity Verification. Preflight lists it as optional.
|
|
65
|
+
|
|
52
66
|
- **View Event Log Files**, **View Setup and Configuration**: required by `sf audit incident collect`.
|
|
53
67
|
- **Query All Files**: lets `incident collect` see files owned by guest users. Without it the report states the gap.
|
|
54
68
|
|
|
@@ -67,7 +81,7 @@ security team is right to refuse them:
|
|
|
67
81
|
- **`Manage Users`** / **`Manage Internal Users`**
|
|
68
82
|
- Any **Create / Edit / Delete (DML)** permission on any object
|
|
69
83
|
- **Metadata API** deploy/retrieve (`deployMetadata`, `modifyMetadata`)
|
|
70
|
-
- Password, MFA, or session **management** permissions (the tool *reads* MFA/session config, it does not change it)
|
|
84
|
+
- Password, MFA, or session **management** permissions (the tool *reads* MFA/session config, it does not change it). The one exception is optional: see "MFA registration" above
|
|
71
85
|
|
|
72
86
|
## Important caveats
|
|
73
87
|
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
|
2
|
+
<!--
|
|
3
|
+
SF Audit (MFA registration) permission set: optional, and separate from SF_Audit_ReadOnly.
|
|
4
|
+
|
|
5
|
+
`mfa-registration` reads TwoFactorMethodsInfo, which Salesforce hides without "Manage MFA in
|
|
6
|
+
API" (ManageTwoFactor). Salesforce refuses that permission unless the permission set also holds
|
|
7
|
+
the user-management permissions below, so this set is NOT read-only: it lets the holder manage
|
|
8
|
+
users, roles, sharing and passwords. Assign it only to an audit user who is already a System
|
|
9
|
+
Administrator (who holds all of these), where it adds just Manage MFA in API. Otherwise leave it
|
|
10
|
+
out: the check reports inconclusive and says why. See ../../PERMISSIONS.md.
|
|
11
|
+
|
|
12
|
+
Deploy it with the Salesforce CLI (metadata PermissionSet:SF_Audit_MFA), then assign it with
|
|
13
|
+
`sf org assign permset -n SF_Audit_MFA -o <orgAlias>`.
|
|
14
|
+
-->
|
|
15
|
+
<PermissionSet xmlns="http://soap.sforce.com/2006/04/metadata">
|
|
16
|
+
<description>Optional: Manage MFA in API for the sf-audit MFA registration check, with the user-management permissions Salesforce requires alongside it. Assign only to an audit user who is already a System Administrator.</description>
|
|
17
|
+
<hasActivationRequired>false</hasActivationRequired>
|
|
18
|
+
<label>SF Audit (MFA registration)</label>
|
|
19
|
+
<userPermissions><enabled>true</enabled><name>ManageTwoFactor</name></userPermissions>
|
|
20
|
+
<userPermissions><enabled>true</enabled><name>AssignPermissionSets</name></userPermissions>
|
|
21
|
+
<userPermissions><enabled>true</enabled><name>DelegatedTwoFactor</name></userPermissions>
|
|
22
|
+
<userPermissions><enabled>true</enabled><name>FreezeUsers</name></userPermissions>
|
|
23
|
+
<userPermissions><enabled>true</enabled><name>ManageInternalUsers</name></userPermissions>
|
|
24
|
+
<userPermissions><enabled>true</enabled><name>ManageIpAddresses</name></userPermissions>
|
|
25
|
+
<userPermissions><enabled>true</enabled><name>ManageLoginAccessPolicies</name></userPermissions>
|
|
26
|
+
<userPermissions><enabled>true</enabled><name>ManagePasswordPolicies</name></userPermissions>
|
|
27
|
+
<userPermissions><enabled>true</enabled><name>ManageProfilesPermissionsets</name></userPermissions>
|
|
28
|
+
<userPermissions><enabled>true</enabled><name>ManageRoles</name></userPermissions>
|
|
29
|
+
<userPermissions><enabled>true</enabled><name>ManageSharing</name></userPermissions>
|
|
30
|
+
<userPermissions><enabled>true</enabled><name>ManageUsers</name></userPermissions>
|
|
31
|
+
<userPermissions><enabled>true</enabled><name>MonitorLoginHistory</name></userPermissions>
|
|
32
|
+
<userPermissions><enabled>true</enabled><name>ResetPasswords</name></userPermissions>
|
|
33
|
+
<userPermissions><enabled>true</enabled><name>ViewAllUsers</name></userPermissions>
|
|
34
|
+
<userPermissions><enabled>true</enabled><name>ViewRoles</name></userPermissions>
|
|
35
|
+
<userPermissions><enabled>true</enabled><name>ViewSetup</name></userPermissions>
|
|
36
|
+
</PermissionSet>
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export type Capability = 'unauth-foothold' | 'low-trust-authenticated' | 'data-read' | 'data-read-bulk' | 'data-write' | 'code-exec' | 'credential-theft' | 'priv-esc' | 'org-takeover' | 'external-egress';
|
|
1
|
+
export type Capability = 'unauth-foothold' | 'low-trust-authenticated' | 'data-read' | 'data-read-bulk' | 'data-write' | 'code-exec' | 'credential-theft' | 'priv-esc' | 'org-takeover' | 'external-egress' | 'valid-account';
|
|
2
2
|
export declare const ALL_CAPABILITIES: readonly Capability[];
|
|
3
3
|
/** Capabilities that represent an attacker entry point. */
|
|
4
4
|
export declare const SOURCE_CAPS: readonly Capability[];
|
package/lib/chains/Capability.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
export const ALL_CAPABILITIES = [
|
|
2
2
|
'unauth-foothold', 'low-trust-authenticated', 'data-read', 'data-read-bulk',
|
|
3
|
-
'data-write', 'code-exec', 'credential-theft', 'priv-esc', 'org-takeover', 'external-egress',
|
|
3
|
+
'data-write', 'code-exec', 'credential-theft', 'priv-esc', 'org-takeover', 'external-egress', 'valid-account',
|
|
4
4
|
];
|
|
5
5
|
/** Capabilities that represent an attacker entry point. */
|
|
6
6
|
export const SOURCE_CAPS = ['unauth-foothold', 'low-trust-authenticated'];
|
|
@@ -46,9 +46,13 @@ export const CAPABILITY_REGISTRY = {
|
|
|
46
46
|
// control of a matching origin and a logged-in victim visiting it, and yields at most that user's
|
|
47
47
|
// own session-scoped access.
|
|
48
48
|
'escalation-perms-found': { grants: ['priv-esc'], techniques: { 'priv-esc': ['T1098'] } },
|
|
49
|
-
// Guest
|
|
50
|
-
|
|
49
|
+
// Guest-owned records (UI-API reachable) are the confirmed bulk sink: form submissions nobody
|
|
50
|
+
// chose to publish. Records shared with guests are reach, not bulk: a guest sharing rule is how a
|
|
51
|
+
// site publishes records on purpose, so like 'guest-user-sharing-exposure' they need a step that
|
|
52
|
+
// reads in bulk, writes or runs code before the unauthenticated chain fires.
|
|
51
53
|
'guest-object-exposure-guest-owned': { grants: ['unauth-foothold', 'data-read-bulk'] },
|
|
54
|
+
'guest-object-exposure-public-owd': { grants: ['unauth-foothold', 'data-read'] },
|
|
55
|
+
'guest-object-exposure-guest-shared': { grants: ['unauth-foothold', 'data-read'] },
|
|
52
56
|
// Observed guest recon in EventLogFile — an active unauthenticated foothold
|
|
53
57
|
'guest-traffic-anomaly-recon': { grants: ['unauth-foothold'], techniques: { 'unauth-foothold': [] } },
|
|
54
58
|
'guest-traffic-anomaly-anonymizer': { grants: ['unauth-foothold'], techniques: { 'unauth-foothold': [] } },
|
|
@@ -56,12 +60,16 @@ export const CAPABILITY_REGISTRY = {
|
|
|
56
60
|
'guest-api-access-enabled': { grants: ['unauth-foothold', 'data-read-bulk'] },
|
|
57
61
|
'guest-api-hard-delete': { grants: ['unauth-foothold', 'data-write'], techniques: { 'data-write': ['T1485'] } },
|
|
58
62
|
// Guest enumeration of other USERS. The staff roster is the targeting asset behind credential
|
|
59
|
-
// stuffing and phishing at named admins
|
|
60
|
-
//
|
|
61
|
-
//
|
|
63
|
+
// stuffing and phishing at named admins. View All Users exposes every User record, so it is a bulk
|
|
64
|
+
// read; it can no longer be granted to guests since Winter '21, so it is found only where an old
|
|
65
|
+
// grant survived. A live site's guest member visibility exposes that site's members, not the org's
|
|
66
|
+
// records: a read, not a bulk read.
|
|
62
67
|
'guest-user-visibility-view-all-users': { grants: ['unauth-foothold', 'data-read-bulk'], techniques: { 'data-read-bulk': ['T1087.004', 'T1213.004'] } },
|
|
63
|
-
'guest-
|
|
64
|
-
|
|
68
|
+
'guest-site-options-member-visibility': { grants: ['unauth-foothold', 'data-read'], techniques: { 'data-read': ['T1087.004'] } },
|
|
69
|
+
// The User external OWD reaches logged-in external users, not guests: secure guest record access
|
|
70
|
+
// keeps the guest OWD Private on every object. Like 'sharing-model-external-read', it is what an
|
|
71
|
+
// external account is worth.
|
|
72
|
+
'guest-user-visibility-owd': { grants: ['low-trust-authenticated', 'data-read-bulk'], techniques: { 'data-read-bulk': ['T1087.004', 'T1213.004'] } },
|
|
65
73
|
// Classic Visualforce sites — a second unauthenticated foothold surface
|
|
66
74
|
'classic-sites-active': { grants: ['unauth-foothold'], techniques: { 'unauth-foothold': [] } },
|
|
67
75
|
// Mass data-export capability — a bulk-read sink for an authenticated actor
|
|
@@ -72,6 +80,11 @@ export const CAPABILITY_REGISTRY = {
|
|
|
72
80
|
'login-access-policy-login-as-enabled': { grants: ['priv-esc', 'data-read-bulk'], techniques: { 'priv-esc': ['T1078.004'] } },
|
|
73
81
|
// External federation an attacker could ride in on
|
|
74
82
|
'auth-providers-social': { grants: ['low-trust-authenticated'] },
|
|
83
|
+
// Weak MFA: a stolen or guessed password is enough to sign in as the user. The capability is not an
|
|
84
|
+
// entry point of a potential path; the MFA chain pairs it with the privileged users it reaches.
|
|
85
|
+
'trusted-ip-broad-ranges': { grants: ['valid-account'] },
|
|
86
|
+
'internal-user-mfa-gaps': { grants: ['valid-account'] },
|
|
87
|
+
'mfa-portal-users-without-enforcement': { grants: ['valid-account'] },
|
|
75
88
|
// Toxic permission combinations held by one user. Capabilities follow each combo's own stated
|
|
76
89
|
// outcome — see COMBOS in SeparationOfDutiesCheck, where the ids are defined.
|
|
77
90
|
'separation-of-duties-self-escalation': { grants: ['priv-esc', 'org-takeover'] },
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { SOURCE_CAPS, HIGH_IMPACT_SINKS } from './Capability.js';
|
|
2
2
|
import { capabilitiesFor } from './CapabilityRegistry.js';
|
|
3
3
|
import { orderStepsByTactic, techniquesForGrant } from '../threats/attack.js';
|
|
4
|
-
import { NAMED_CHAINS, inGroup } from './namedChains.js';
|
|
4
|
+
import { NAMED_CHAINS, UNAUTH_EXFIL_STEPS, UNAUTH_RECORD_REACH, inGroup } from './namedChains.js';
|
|
5
5
|
const SEVERITY_ORDER = {
|
|
6
6
|
CRITICAL: 0, HIGH: 1, MEDIUM: 2, LOW: 3, INFO: 4,
|
|
7
7
|
};
|
|
@@ -119,9 +119,17 @@ export class ChainEngine {
|
|
|
119
119
|
const hasRealSource = active.some((f) => !SURFACE_ONLY.has(f.id) && (grantsByFinding.get(f) ?? []).includes(src));
|
|
120
120
|
if (!hasRealSource)
|
|
121
121
|
continue;
|
|
122
|
+
// A guest reaches only what the guest side grants: an internal user's View All Data or an
|
|
123
|
+
// admin's Author Apex is no sink for an unauthenticated foothold (as in unauth-bulk-exfil).
|
|
124
|
+
const reaches = (f) => src !== 'unauth-foothold' || UNAUTH_EXFIL_STEPS.includes(f.id);
|
|
125
|
+
// Nor is a guest path potential when no step shows the guest reaching a record.
|
|
126
|
+
if (src === 'unauth-foothold' && !active.some((f) => UNAUTH_RECORD_REACH.includes(f.id)))
|
|
127
|
+
continue;
|
|
122
128
|
for (const sink of HIGH_IMPACT_SINKS) {
|
|
123
129
|
if (!present.has(sink))
|
|
124
130
|
continue;
|
|
131
|
+
if (!active.some((f) => reaches(f) && (grantsByFinding.get(f) ?? []).includes(sink)))
|
|
132
|
+
continue;
|
|
125
133
|
const key = `${src}->${sink}`;
|
|
126
134
|
if (covered.has(key) || seen.has(key))
|
|
127
135
|
continue;
|
|
@@ -130,7 +138,7 @@ export class ChainEngine {
|
|
|
130
138
|
const members = [];
|
|
131
139
|
for (const f of active) {
|
|
132
140
|
const g = grantsByFinding.get(f) ?? [];
|
|
133
|
-
if (g.includes(src) || g.includes(sink) || g.includes('code-exec'))
|
|
141
|
+
if (g.includes(src) || (reaches(f) && (g.includes(sink) || g.includes('code-exec'))))
|
|
134
142
|
members.push(f);
|
|
135
143
|
if (members.length >= MAX_STEPS)
|
|
136
144
|
break;
|
|
@@ -52,6 +52,7 @@ export declare const GUEST_EXPOSURE: string[];
|
|
|
52
52
|
export declare const LOW_TRUST_ENTRY: string[];
|
|
53
53
|
export declare const NON_ADMIN_ESCALATION: string[];
|
|
54
54
|
export declare const UNAUTH_EXFIL_STEPS: string[];
|
|
55
|
+
export declare const UNAUTH_RECORD_REACH: string[];
|
|
55
56
|
export declare const UNAUTH_EXFIL_WIDENERS: string[];
|
|
56
57
|
export declare const GUEST_TRAFFIC: string[];
|
|
57
58
|
export declare const GUEST_BULK_SURFACE: string[];
|
|
@@ -24,16 +24,19 @@ const byPrefixes = (active, prefixes) => active.filter((f) => prefixes.some((p)
|
|
|
24
24
|
export const GUEST_EXPOSURE = [
|
|
25
25
|
'guest-user-read-access', 'guest-user-write-access', 'guest-user-sharing-exposure',
|
|
26
26
|
'guest-executable-apex-unprotected', 'guest-executable-apex-exposed', 'guest-executable-apex-system-mode',
|
|
27
|
-
'guest-object-exposure-public-owd', 'guest-object-exposure-guest-owned',
|
|
27
|
+
'guest-object-exposure-public-owd', 'guest-object-exposure-guest-owned', 'guest-object-exposure-guest-shared',
|
|
28
28
|
'guest-api-access-enabled', 'guest-api-hard-delete',
|
|
29
|
-
|
|
29
|
+
// Not 'guest-user-visibility-owd': the User external OWD reaches logged-in external users, not guests.
|
|
30
|
+
// Not 'guest-site-options-member-visibility': a site's member list is no foothold into org data,
|
|
31
|
+
// and this list also gates the low-trust chains (LOW_TRUST_ENTRY).
|
|
32
|
+
'guest-user-visibility-view-all-users',
|
|
30
33
|
'guest-record-access-policy-not-enforced',
|
|
31
34
|
'inbound-email-handler-unauthenticated-execution',
|
|
32
35
|
];
|
|
33
36
|
// Ways in for a low-trust principal: external users with public sharing, social sign-on,
|
|
34
37
|
// self-registration, or a confirmed guest exposure. RULE-072.
|
|
35
38
|
export const LOW_TRUST_ENTRY = [
|
|
36
|
-
'sharing-model-external-read', 'sharing-model-external-write',
|
|
39
|
+
'sharing-model-external-read', 'sharing-model-external-write', 'guest-user-visibility-owd',
|
|
37
40
|
'auth-providers-social', 'experience-cloud-site-self-registration',
|
|
38
41
|
...GUEST_EXPOSURE,
|
|
39
42
|
];
|
|
@@ -49,31 +52,49 @@ export const NON_ADMIN_ESCALATION = [
|
|
|
49
52
|
export const UNAUTH_EXFIL_STEPS = [
|
|
50
53
|
'guest-user-read-access', 'guest-user-write-access', 'guest-user-sharing-exposure', 'guest-user-baseline',
|
|
51
54
|
'guest-executable-apex-unprotected', 'guest-executable-apex-exposed', 'guest-executable-apex-system-mode',
|
|
52
|
-
'guest-object-exposure-public-owd', 'guest-object-exposure-guest-owned',
|
|
55
|
+
'guest-object-exposure-public-owd', 'guest-object-exposure-guest-owned', 'guest-object-exposure-guest-shared',
|
|
53
56
|
'guest-api-access-enabled', 'guest-api-hard-delete', 'classic-sites-active',
|
|
54
|
-
'guest-user-visibility-view-all-users', 'guest-
|
|
57
|
+
'guest-user-visibility-view-all-users', 'guest-site-options-member-visibility',
|
|
55
58
|
// Not 'sharing-model-external-*': since Winter '21 guest record access is always secured, so the
|
|
56
59
|
// external OWD reaches logged-in portal users, not guests. Those findings drive the low-trust chains.
|
|
57
|
-
'portal-exposed-apex-without-sharing'
|
|
60
|
+
// Not 'portal-exposed-apex-without-sharing' or 'flows-*-without-sharing' either: they flag any
|
|
61
|
+
// @AuraEnabled class or any Flow, which a logged-in user may be the only one able to call. The
|
|
62
|
+
// guest-side counterpart is 'guest-executable-apex-*', read from the guest profile's class access.
|
|
58
63
|
'field-level-security-high', 'field-level-security-medium',
|
|
59
|
-
// The guardrail whose absence lets guest-owned records defeat a Private OWD
|
|
60
|
-
// analogue of portal-exposed Apex running without sharing.
|
|
64
|
+
// The guardrail whose absence lets guest-owned records defeat a Private OWD.
|
|
61
65
|
'guest-record-access-policy-not-enforced',
|
|
62
|
-
'flows-autolaunched-without-sharing', 'flows-screen-without-sharing',
|
|
63
66
|
// An open inbound email handler grants unauth-foothold, so it must appear whenever it
|
|
64
67
|
// is what opened the gate.
|
|
65
68
|
'inbound-email-handler-unauthenticated-execution',
|
|
66
69
|
];
|
|
70
|
+
// Steps that show a guest reaching records: a guest sharing rule, guest-owned or confirmed-readable
|
|
71
|
+
// records, the User roster, or guest-callable Apex that runs without sharing. Object permissions,
|
|
72
|
+
// API access, or guest-callable Apex not shown to bypass sharing (SYSTEM_MODE lifts CRUD/FLS only)
|
|
73
|
+
// reach no record on their own: secure guest record access leaves the guest nothing to read.
|
|
74
|
+
export const UNAUTH_RECORD_REACH = [
|
|
75
|
+
'guest-user-sharing-exposure', 'guest-object-exposure-public-owd', 'guest-object-exposure-guest-owned',
|
|
76
|
+
'guest-object-exposure-guest-shared',
|
|
77
|
+
// Not 'guest-user-visibility-owd': the guest OWD is Private on every object, User included.
|
|
78
|
+
// Not 'guest-site-options-member-visibility': it shows a site's members, not business records.
|
|
79
|
+
'guest-user-visibility-view-all-users',
|
|
80
|
+
'guest-executable-apex-unprotected',
|
|
81
|
+
// Secure guest record access is what makes the rest of this list necessary: with it off, legacy
|
|
82
|
+
// sharing and guest ownership reach records directly.
|
|
83
|
+
'guest-record-access-policy-not-enforced',
|
|
84
|
+
];
|
|
85
|
+
// What a guest-side step must grant for the visitor to reach data or run code.
|
|
86
|
+
const UNAUTH_EXFIL_REACH = ['code-exec', 'data-read-bulk', 'data-write'];
|
|
67
87
|
// Internal-only weaknesses that widen what a foothold reaches. They join as evidence but
|
|
68
88
|
// never count toward the floor: without a guest-side step they describe no unauthenticated path.
|
|
69
89
|
export const UNAUTH_EXFIL_WIDENERS = ['data-cloud-data-space-default-overshared', 'restriction-rules-inactive'];
|
|
70
90
|
export const GUEST_TRAFFIC = ['guest-traffic-anomaly-recon', 'guest-traffic-anomaly-anonymizer'];
|
|
71
91
|
// A readable User roster counts as an exposed surface in its own right — recon against an org
|
|
72
|
-
// that leaks its staff list is the same incident.
|
|
73
|
-
//
|
|
92
|
+
// that leaks its staff list is the same incident.
|
|
93
|
+
// Records shared with guests are left out: a site publishes those on purpose, and they are reads,
|
|
94
|
+
// not the bulk surface this chain needs.
|
|
74
95
|
export const GUEST_BULK_SURFACE = [
|
|
75
|
-
'guest-object-exposure-
|
|
76
|
-
'guest-user-visibility-view-all-users',
|
|
96
|
+
'guest-object-exposure-guest-owned',
|
|
97
|
+
'guest-user-visibility-view-all-users',
|
|
77
98
|
];
|
|
78
99
|
// Admin powers: they widen what a takeover reaches but are not themselves the escalation.
|
|
79
100
|
export const TAKEOVER_ADMIN_EVIDENCE = [
|
|
@@ -146,6 +167,30 @@ export const DETECTION_BLIND_SPOTS = [
|
|
|
146
167
|
];
|
|
147
168
|
export const EXPLOITABLE_ACCESS = ['unauth-foothold', 'priv-esc', 'org-takeover'];
|
|
148
169
|
export const MFA_WEAKNESS = ['trusted-ip-broad-ranges', 'internal-user-mfa-gaps', 'mfa-portal-users-without-enforcement'];
|
|
170
|
+
// Org-wide: a trusted range exempts every user signing in from it, admins included.
|
|
171
|
+
const MFA_WEAKNESS_ORG_WIDE = ['trusted-ip-broad-ranges'];
|
|
172
|
+
// The internal-user MFA finding lists at most this many users, so a full list may leave a privileged
|
|
173
|
+
// user out. Portal users never qualify this way: a portal user is not one of the admins.
|
|
174
|
+
const MFA_USER_LIST_CAP = 50;
|
|
175
|
+
const MFA_CAPPED_INTERNAL = 'internal-user-mfa-gaps';
|
|
176
|
+
/** The user Ids (from a record link) and usernames a finding's affected items name. */
|
|
177
|
+
function userKeys(f) {
|
|
178
|
+
const keys = new Set();
|
|
179
|
+
for (const item of f.affectedItems ?? []) {
|
|
180
|
+
const id = /\/(005[A-Za-z0-9]{12}(?:[A-Za-z0-9]{3})?)$/.exec(item.url ?? '')?.[1];
|
|
181
|
+
if (id)
|
|
182
|
+
keys.add(id.slice(0, 15));
|
|
183
|
+
keys.add(item.label.replace(/ \(.*\)$/, ''));
|
|
184
|
+
}
|
|
185
|
+
return keys;
|
|
186
|
+
}
|
|
187
|
+
/** The MFA weaknesses that reach a privileged user: org-wide, or naming one of those users. */
|
|
188
|
+
function weaknessReachingPrivileged(weakness, targets) {
|
|
189
|
+
const privileged = new Set(targets.flatMap((t) => [...userKeys(t)]));
|
|
190
|
+
return weakness.filter((w) => MFA_WEAKNESS_ORG_WIDE.includes(w.id)
|
|
191
|
+
|| (w.id === MFA_CAPPED_INTERNAL && (w.affectedItems?.length ?? 0) >= MFA_USER_LIST_CAP)
|
|
192
|
+
|| [...userKeys(w)].some((k) => privileged.has(k)));
|
|
193
|
+
}
|
|
149
194
|
export const PRIVILEGED_ACCOUNTS = [
|
|
150
195
|
'users-modify-all-data', 'users-view-all-data', 'users-super-admin-combo',
|
|
151
196
|
'privileged-access-shadow-admins', 'separation-of-duties-self-escalation',
|
|
@@ -175,6 +220,8 @@ export const SELF_REGISTRATION = ['experience-cloud-site-self-registration'];
|
|
|
175
220
|
// licence, which generally has no report access at all, so including it would overstate reach.
|
|
176
221
|
export const PORTAL_REACH = [
|
|
177
222
|
'sharing-model-external-read', 'sharing-model-external-write',
|
|
223
|
+
// A public external OWD on User shows every logged-in external user the staff roster.
|
|
224
|
+
'guest-user-visibility-owd',
|
|
178
225
|
'portal-exposed-apex-without-sharing',
|
|
179
226
|
'flows-autolaunched-without-sharing', 'flows-screen-without-sharing',
|
|
180
227
|
'apex-rest-without-sharing',
|
|
@@ -235,22 +282,22 @@ export const NAMED_CHAINS = [
|
|
|
235
282
|
id: 'unauth-bulk-exfil',
|
|
236
283
|
title: 'Unauthenticated bulk exfiltration',
|
|
237
284
|
severity: 'CRITICAL',
|
|
238
|
-
narrative: 'An unauthenticated guest foothold combines with guest-reachable code execution or
|
|
239
|
-
'
|
|
285
|
+
narrative: 'An unauthenticated guest foothold combines with guest-reachable code execution or guest ' +
|
|
286
|
+
'record access to read business data in bulk without any login. In practice this is ' +
|
|
240
287
|
'reached over the site\'s Aura endpoint (/s/sfsites/aura) with aura.token=null: ' +
|
|
241
288
|
'RecordUiController/ACTION$executeGraphQL returns record data the guest user can see, and ' +
|
|
242
289
|
'aura.ApexAction.execute invokes @AuraEnabled Apex — which, in a class that runs without ' +
|
|
243
290
|
'sharing, skips record-level access control entirely and will accept arbitrary record ids. ' +
|
|
244
291
|
'No credentials are involved at any point, so login-based controls (MFA, IP ranges, SSO) ' +
|
|
245
292
|
'never engage.',
|
|
246
|
-
remediation: 'Remove guest object
|
|
247
|
-
'
|
|
293
|
+
remediation: 'Remove guest object permissions and guest sharing rules, and ensure no guest-invokable Apex ' +
|
|
294
|
+
'runs without sharing. Because the ' +
|
|
248
295
|
'requests never reach a login page, tightening authentication does not mitigate this — the ' +
|
|
249
296
|
'object permissions, sharing model and Apex sharing declarations are the controls that apply.',
|
|
250
297
|
abuseCase: {
|
|
251
298
|
actor: 'an unauthenticated site visitor',
|
|
252
299
|
goal: 'read or change business data in bulk without logging in',
|
|
253
|
-
preconditions: [{ ids: GUEST_EXPOSURE }, { ids: UNAUTH_EXFIL_STEPS }, { ids: UNAUTH_EXFIL_WIDENERS }, { capabilities: ['unauth-foothold'] }, { capabilities:
|
|
300
|
+
preconditions: [{ ids: GUEST_EXPOSURE }, { ids: UNAUTH_EXFIL_STEPS }, { ids: UNAUTH_EXFIL_WIDENERS }, { capabilities: ['unauth-foothold'] }, { capabilities: UNAUTH_EXFIL_REACH }, { ids: UNAUTH_RECORD_REACH }],
|
|
254
301
|
breakPoint: 0,
|
|
255
302
|
tactics: { entry: 'initial-access', goal: 'collection' },
|
|
256
303
|
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.',
|
|
@@ -258,8 +305,6 @@ export const NAMED_CHAINS = [
|
|
|
258
305
|
match(present, active) {
|
|
259
306
|
if (!has(present, 'unauth-foothold'))
|
|
260
307
|
return null;
|
|
261
|
-
if (!hasAny(present, 'code-exec', 'data-read-bulk', 'data-write'))
|
|
262
|
-
return null;
|
|
263
308
|
// A surface and internal weaknesses are not a path: an unauthenticated visitor must be shown
|
|
264
309
|
// to reach something.
|
|
265
310
|
if (byIds(active, GUEST_EXPOSURE).length === 0)
|
|
@@ -267,6 +312,12 @@ export const NAMED_CHAINS = [
|
|
|
267
312
|
const steps = byIds(active, UNAUTH_EXFIL_STEPS);
|
|
268
313
|
if (steps.length < 2)
|
|
269
314
|
return null;
|
|
315
|
+
// The bulk read, write or code execution must be the guest's own. An internal user's
|
|
316
|
+
// Modify All Data or an admin's Author Apex says nothing about what a visitor reaches.
|
|
317
|
+
if (!steps.some((s) => capabilitiesFor(s).grants.some((c) => UNAUTH_EXFIL_REACH.includes(c))))
|
|
318
|
+
return null;
|
|
319
|
+
if (byIds(steps, UNAUTH_RECORD_REACH).length === 0)
|
|
320
|
+
return null;
|
|
270
321
|
return [...steps, ...byIds(active, UNAUTH_EXFIL_WIDENERS)];
|
|
271
322
|
},
|
|
272
323
|
},
|
|
@@ -506,7 +557,7 @@ export const NAMED_CHAINS = [
|
|
|
506
557
|
'permission set can export it en masse (Weekly Data Export, or API access combined with ' +
|
|
507
558
|
'View/Modify All Data), and there is no monitoring that would record the export happening. ' +
|
|
508
559
|
'Broad read plus bulk egress plus no audit trail is the insider-threat and post-credential-' +
|
|
509
|
-
'compromise path
|
|
560
|
+
'compromise path. The missing audit trail is what makes it impossible to reconstruct afterwards.',
|
|
510
561
|
remediation: 'Narrow the broad internal sharing, restrict Weekly Data Export and Bulk API access to a named ' +
|
|
511
562
|
'few, and enable Event Monitoring (plus forwarding to a SIEM) so bulk reads are recorded and ' +
|
|
512
563
|
'alertable.',
|
|
@@ -563,20 +614,22 @@ export const NAMED_CHAINS = [
|
|
|
563
614
|
id: 'mfa-bypass-admin',
|
|
564
615
|
title: 'MFA bypass to privileged compromise',
|
|
565
616
|
severity: 'HIGH',
|
|
566
|
-
narrative: '
|
|
567
|
-
'
|
|
617
|
+
narrative: 'A privileged account signs in without a second factor: a trusted IP range exempts it from MFA, or ' +
|
|
618
|
+
'the account itself lacks MFA enforcement. A credential-stuffing or phishing attacker who has the ' +
|
|
619
|
+
'password can take over an admin.',
|
|
568
620
|
remediation: 'Enforce MFA for all internal users, remove trusted-IP MFA bypass ranges, and minimise privileged accounts.',
|
|
569
621
|
abuseCase: {
|
|
570
622
|
actor: 'a credential-stuffing or phishing attacker',
|
|
571
623
|
goal: 'take over a privileged account without a second factor',
|
|
572
|
-
preconditions: [{ ids: MFA_WEAKNESS }, { ids: PRIVILEGED_ACCOUNTS }],
|
|
624
|
+
preconditions: [{ ids: MFA_WEAKNESS, role: 'valid-account' }, { ids: PRIVILEGED_ACCOUNTS }],
|
|
573
625
|
breakPoint: 0,
|
|
574
|
-
tactics: { goal: 'privilege-escalation' },
|
|
626
|
+
tactics: { entry: 'initial-access', goal: 'privilege-escalation' },
|
|
575
627
|
breakPointText: 'Enforce MFA for every user and remove trusted-IP ranges that bypass it.',
|
|
576
628
|
},
|
|
577
629
|
match(_present, active) {
|
|
578
|
-
|
|
630
|
+
// A portal user without MFA is not an admin: the weakness must reach a privileged user.
|
|
579
631
|
const targets = byIds(active, PRIVILEGED_ACCOUNTS);
|
|
632
|
+
const weakness = weaknessReachingPrivileged(byIds(active, MFA_WEAKNESS), targets);
|
|
580
633
|
return weakness.length > 0 && targets.length > 0 ? [...weakness, ...targets] : null;
|
|
581
634
|
},
|
|
582
635
|
},
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { testApexPattern } from '@cclabsnz/sf-core';
|
|
2
|
-
import { apexCode, codeWithoutStrings, DML_AS_USER, usesSystemMode } from '../support/apexAccess.js';
|
|
2
|
+
import { apexApiVersions, apexCode, codeWithoutStrings, DML_AS_USER, OMITTED_SHARING_ENFORCED_FROM, usesSystemMode } from '../support/apexAccess.js';
|
|
3
3
|
// Patterns that indicate DML or inline SOQL is being performed
|
|
4
4
|
const HAS_DML = /\b(?:insert|update|delete|upsert|undelete|merge)\s+\w+|Database\.(?:insert|update|delete|upsert|undelete|merge)\w*\s*\(/i;
|
|
5
5
|
// SOQL and SOSL, inline or dynamic.
|
|
@@ -39,6 +39,11 @@ export class ApexCrudFLSCheck {
|
|
|
39
39
|
const withoutSharingNoFls = [];
|
|
40
40
|
const withDmlNoFls = [];
|
|
41
41
|
const systemMode = [];
|
|
42
|
+
// From API 67.0 (Summer '26) SOQL, SOSL, DML and Database methods run in user mode unless they
|
|
43
|
+
// say otherwise, so a class saved at 67.0 or later enforces CRUD/FLS by default (spec RULE-009).
|
|
44
|
+
// SYSTEM_MODE is still reported above that default.
|
|
45
|
+
const versions = await apexApiVersions(ctx);
|
|
46
|
+
let userModeByDefault = 0;
|
|
42
47
|
// apexBodies is pre-filtered by HardcodedCredentialsCheck, which excludes @IsTest classes
|
|
43
48
|
// before populating the cache. There is deliberately no second guard here: a cache miss
|
|
44
49
|
// yields an empty array, not unfiltered bodies, so there is nothing for one to catch.
|
|
@@ -59,6 +64,10 @@ export class ApexCrudFLSCheck {
|
|
|
59
64
|
continue;
|
|
60
65
|
if (testApexPattern(body, IS_BATCH_OR_SCHEDULED))
|
|
61
66
|
continue;
|
|
67
|
+
if ((versions.get(name.toLowerCase()) ?? 0) >= OMITTED_SHARING_ENFORCED_FROM) {
|
|
68
|
+
userModeByDefault++;
|
|
69
|
+
continue;
|
|
70
|
+
}
|
|
62
71
|
// Enforcement must be code, not text: 'WITH USER_MODE' inside a debug string enforces nothing.
|
|
63
72
|
const enforcementCode = codeWithoutStrings(raw);
|
|
64
73
|
const hasFls = testApexPattern(enforcementCode, HAS_FLS) || testApexPattern(enforcementCode, DML_AS_USER);
|
|
@@ -123,7 +132,7 @@ export class ApexCrudFLSCheck {
|
|
|
123
132
|
riskLevel: 'LOW',
|
|
124
133
|
passed: true,
|
|
125
134
|
title: 'All scanned Apex classes with DML/SOQL include CRUD/FLS permission checks',
|
|
126
|
-
detail:
|
|
135
|
+
detail: `No Apex classes were found performing DML or SOQL without corresponding object-level or field-level security checks. This scan covers non-test, non-batch classes in the org namespace.${userModeByDefault > 0 ? ` ${userModeByDefault} class(es) saved at API 67.0 or later rely on user mode, the default for their queries and DML from that version.` : ''}`,
|
|
127
136
|
remediation: 'Continue monitoring as new Apex classes are developed.',
|
|
128
137
|
});
|
|
129
138
|
}
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
+
import { apexApiVersions, declaresWithoutSharing, effectiveSharing, omittedSharingEnforced } from '../support/apexAccess.js';
|
|
1
2
|
const REST_RESOURCE_RE = /@RestResource\s*\(\s*urlMapping\s*=/i;
|
|
2
|
-
const WITHOUT_SHARING_RE = /\bwithout\s+sharing\b/i;
|
|
3
|
-
const NO_SHARING_DECLARED_RE = /\b(with|without|inherited)\s+sharing\b/i;
|
|
4
3
|
const IS_TEST_RE = /@IsTest\b/i;
|
|
5
4
|
export class ApexRestEndpointCheck {
|
|
6
5
|
id = 'apex-rest-endpoint';
|
|
@@ -51,8 +50,14 @@ export class ApexRestEndpointCheck {
|
|
|
51
50
|
note: 'Custom REST endpoint: review access controls',
|
|
52
51
|
})),
|
|
53
52
|
});
|
|
54
|
-
//
|
|
55
|
-
const
|
|
53
|
+
// A class with no keyword takes its parent's sharing (spec MN-001).
|
|
54
|
+
const bodyByName = new Map(apexBodies.map((b) => [b.name.toLowerCase(), b.body ?? '']));
|
|
55
|
+
const lookup = (n) => bodyByName.get(n.toLowerCase());
|
|
56
|
+
const sharingOf = (c) => effectiveSharing(c.name, c.body, lookup);
|
|
57
|
+
// Flag endpoints declared (or inheriting) without sharing — REST callers bypass record-level access
|
|
58
|
+
// Read from code, not text: "without sharing" in a comment or string runs nothing. An inner class
|
|
59
|
+
// declared without sharing counts, as in the guest Apex check: the endpoint can call into it.
|
|
60
|
+
const withoutSharing = restClasses.filter((c) => declaresWithoutSharing(c.body) || sharingOf(c) === 'without');
|
|
56
61
|
if (withoutSharing.length > 0) {
|
|
57
62
|
findings.push({
|
|
58
63
|
id: 'apex-rest-without-sharing',
|
|
@@ -68,15 +73,18 @@ export class ApexRestEndpointCheck {
|
|
|
68
73
|
})),
|
|
69
74
|
});
|
|
70
75
|
}
|
|
71
|
-
// Flag endpoints with no sharing declaration at all
|
|
72
|
-
|
|
76
|
+
// Flag endpoints with no sharing declaration at all, unless compiled at API 67.0 or later,
|
|
77
|
+
// where an omitted keyword means with sharing (spec RULE-007).
|
|
78
|
+
const undeclared = restClasses.filter((c) => !withoutSharing.includes(c) && sharingOf(c) === 'none');
|
|
79
|
+
const versions = undeclared.length > 0 ? await apexApiVersions(ctx) : new Map();
|
|
80
|
+
const noSharingDeclaration = undeclared.filter((c) => !omittedSharingEnforced(c.name, c.body, lookup, (n) => versions.get(n.toLowerCase())));
|
|
73
81
|
if (noSharingDeclaration.length > 0) {
|
|
74
82
|
findings.push({
|
|
75
83
|
id: 'apex-rest-no-sharing-declaration',
|
|
76
84
|
category: this.category,
|
|
77
85
|
riskLevel: 'MEDIUM',
|
|
78
86
|
title: `${noSharingDeclaration.length} REST endpoint class(es) have no sharing declaration`,
|
|
79
|
-
detail: `
|
|
87
|
+
detail: `These REST endpoint classes declare no sharing keyword and are not shown to be saved at API 67.0 or later (with every keyword-less parent; a version that could not be read counts as older). A REST call enters the class directly, so it runs without sharing, and every caller reaches records beyond its own sharing. From API 67.0 (Summer '26) an omitted keyword means with sharing, but only for classes saved at that version. Explicit "with sharing" is required for predictable, secure behaviour.`,
|
|
80
88
|
remediation: 'Add "with sharing" to all @RestResource classes to make sharing enforcement explicit and predictable.',
|
|
81
89
|
affectedItems: noSharingDeclaration.map(({ name }) => ({
|
|
82
90
|
label: name,
|