For most of Apex’s life, the lazy option and the safe option were different options. A class with no sharing keyword ran without sharing and a query with no access clause ran in system mode, which skips object permissions and field-level security (FLS). Leave both out, which some did, and the code saw every record and field in the org on behalf of whoever clicked the button.
API version 67.0 makes the lazy option the safe one. It does so one class at a time, because the version lives in each class’s meta.xml. I have been bumping classes in an org with 100+ developers and a monorepo of more than 20,000 components. Until the last class is bumped, that repo runs both behaviours at once.
My claim is that the bump works as an audit. Class by class, it shows you where the code had been reading data its users were never given, and the useful part is what breaks.
Two settings, and the keyword is the junior one
Every query and DML (data manipulation language) statement now has two settings that used to blur together. The access mode, USER_MODE or SYSTEM_MODE, decides whether object permissions and FLS are checked. The class’s sharing keyword decides record access, and it is only read when the operation runs in system mode. With no access clause at all, the operation now runs in user mode, where sharing is enforced and the keyword is ignored.
Think of without sharing as the spare swipe card kept in a drawer. At v66, a class with that keyword left the card on the desk for every query in it. At v67 the card stays in the drawer until a query asks for it with SYSTEM_MODE.
To pin down which defaults moved, I built a lab project that runs the same Apex at API 66.0 and 67.0 against a real org. This is what it found for a restricted user. Bold marks a result that changed between versions.
| Row | Declaration | Query mode | At 66.0, enforces | At 67.0, enforces |
|---|---|---|---|---|
| 1 | with sharing | WITH USER_MODE | Sharing and CRUD/FLS | Sharing and CRUD/FLS |
| 2 | with sharing | WITH SYSTEM_MODE | Sharing only | Sharing only |
| 3 | with sharing | no clause | Sharing only | Sharing and CRUD/FLS |
| 4 | without sharing | WITH USER_MODE | Sharing and CRUD/FLS | Sharing and CRUD/FLS |
| 5 | without sharing | WITH SYSTEM_MODE | Neither | Neither |
| 6 | without sharing | no clause | Neither | Sharing and CRUD/FLS |
| 7 | inherited (with) | WITH USER_MODE | Sharing and CRUD/FLS | Sharing and CRUD/FLS |
| 8 | inherited (with) | WITH SYSTEM_MODE | Sharing only | Sharing only |
| 9 | inherited (with) | no clause | Sharing only | Sharing and CRUD/FLS |
| 10 | inherited (without) | WITH USER_MODE | Sharing and CRUD/FLS | Sharing and CRUD/FLS |
| 11 | inherited (without) | WITH SYSTEM_MODE | Neither | Neither |
| 12 | inherited (without) | no clause | Neither | Sharing and CRUD/FLS |
| 13 | no keyword | WITH USER_MODE | Sharing and CRUD/FLS | Sharing and CRUD/FLS |
| 14 | no keyword | WITH SYSTEM_MODE | Neither (as entry point) | Sharing only |
| 15 | no keyword | no clause | Neither (as entry point) | Sharing and CRUD/FLS |
| 16 | trigger | WITH USER_MODE | Sharing and CRUD/FLS | Sharing and CRUD/FLS |
| 17 | trigger | WITH SYSTEM_MODE | Neither | Neither |
| 18 | trigger | no clause | Neither | Sharing and CRUD/FLS |
trigger, then a with sharing handler | WITH SYSTEM_MODE | Sharing only | Sharing only |
“Inherited (with)” is an inherited sharing class called from a with sharing one, and “inherited (without)” the same class called from a without sharing one. CRUD (create, read, update, delete) means object permissions.
The most common class shape in the orgs I have worked in is row 3:
public with sharing class AccountReport {
// No access clause, so the class's API version sets the mode.
List<Account> rows = [SELECT Id, AnnualRevenue FROM Account];
// v66: system mode. Sharing applies (the keyword), FLS does not: AnnualRevenue always populated.
// v67: user mode. Sharing and FLS apply: QueryException if the user can't read AnnualRevenue.
}
In review, with sharing reads as “secure”. At v66 it only ever governed records, and the field-level gap was the default for years without anyone writing it down.
The without sharing class is the one that catches people out at v67 (rows 4 to 6):
public without sharing class Elevated {
List<Account> a = [SELECT Id FROM Account];
// v66: every Account in the org.
// v67: only the user's Accounts. User mode ignores the keyword.
List<Account> b = [SELECT Id FROM Account WITH SYSTEM_MODE];
// Both versions: every Account. System mode reads the keyword, and the keyword says without.
}
Query a looks elevated, which is how it passes review on reputation. Elevation at v67 needs two declarations in two places: the keyword on the class and SYSTEM_MODE on the line. In a 900-line class, the second one is the part a reviewer can see.
A class with no keyword moved too (rows 13 to 15). At v66 it took its caller’s sharing, and ran without sharing only when nothing above it had set a mode. At v67 it means with sharing, unless the class extends a parent, in which case it takes the parent’s mode.
public class AccountService { // no sharing keyword
List<Account> a = [SELECT Id FROM Account WITH SYSTEM_MODE];
// v66, called directly: no keyword meant without sharing, so every Account.
// v67: no keyword means with sharing, so the user's Accounts only. FLS is still off.
}
inherited sharing follows the same rule, with the caller’s context standing in for the keyword. Under the default user mode at v67, inheritance is moot and everything is enforced. Under SYSTEM_MODE, the class takes with or without from whoever called it. I like it for service classes called from both elevated and ordinary code. The price is that reading the class no longer tells you what it does.
SYSTEM_MODE inside a with sharing class still enforces sharing at both versions, which surprises anyone who reached for it meaning “bypass everything”. And WITH SECURITY_ENFORCED no longer compiles at v67. The replacement is WITH USER_MODE, which is what an unqualified query now does anyway.
Where it breaks, and the one failure that stays quiet
Writes fail with an exception. At v67, update cases; and Database.update(cases) both run in user mode. A user without edit access to the object, a field or the record gets a DmlException, a System.NoAccessException or an INSUFFICIENT_ACCESS_ON_CROSS_REFERENCE_ENTITY error. That noise is useful, unless the DML sits inside a catch (Exception e) that writes a log line nobody reads.
The DML failure that surprises people is the one where nothing changed the failing field:
Case c = [SELECT Id, Status, InternalNotes__c FROM Case WHERE Id = :caseId];
c.Status = 'Closed';
update c;
// v66: succeeds.
// v67: throws on InternalNotes__c if the user can't edit it, though this code never touched it.
// User mode checks edit access on every field on the in-memory record, not only the changed ones.
The whole record goes to the write, so a wide SELECT drags read-only fields into the check. Orgs that I have worked in previously carry a lot of this technical debt.
Partial-success DML hides its failures in a different place:
Database.update(cases, false); // allOrNone flag. Mode is still the class default.
Database.update(cases, false, AccessLevel.SYSTEM_MODE); // this is the explicit one
The first line reads like it made a decision about access. The false is the allOrNone flag, so at v67 the call runs in user mode and its SaveResult[] now carries permission errors that never appeared before the bump. Code that branches on getErrors() starts seeing errors it was never written for, and retry loops suffer most, since retrying a record the user cannot edit just burns the retry.
Reads are loud about fields and quiet about records. A query that names a field the user cannot read now throws a QueryException, so FLS gaps show up the same way DML ones do. Records the user cannot see are simply left out of the results. That is the quiet half, and the first symptom is a report total that looks slightly off to someone in finance. An administrator sees everything, so a test that runs as an administrator proves nothing about this half.
Triggers add one more boundary. A trigger cannot declare sharing and always runs implicitly without sharing, but an unqualified query inside it still runs in user mode at v67:
trigger CaseTrigger on Case (after insert) {
List<Account> a = [SELECT Id FROM Account]; // v67: user mode, sharing enforced
List<Account> b = [SELECT Id FROM Account WITH SYSTEM_MODE]; // falls back to the trigger: every Account
CaseHandler.run(Trigger.new);
}
public with sharing class CaseHandler {
public static void run(List<Case> cases) {
List<Account> c = [SELECT Id FROM Account WITH SYSTEM_MODE]; // the handler's keyword governs: sharing enforced
}
}
The trigger’s implicit context stops at the handler boundary, which catches any trigger framework built on the assumption that trigger code runs as the system.
The case for leaving it at 66
The case against bumping is easy to make. A class left at 66.0 keeps working exactly as it does today. If your code already checks permissions itself, moving it to 67.0 adds little protection. The move does add risk: a report someone relies on may suddenly show a different total, because the class now leaves out records it used to return. Sprint planning rarely makes room for a change that ships no feature and probably earns a support ticket.
That argument is right about the cost. Where it goes wrong is in assuming the old numbers were correct.
The lab makes that concrete. Its records are Private, and the restricted user owns one of three and has no access to a field called Secret__c. A class with no keyword, called directly, returns all three records at 66.0 with Secret__c readable (row 15). At 67.0 the same query throws on Secret__c, and with that field taken out it returns one record. All 29 of the lab’s tests pass in a real org, and its Sharing Lab tab shows every cell matching for the restricted user.
The two extra rows at 66.0 were records the user had no right to see, and every report built on that query had been counting them. Leaving the class alone keeps the total stable, which is a fine property in a number until somebody asks where it came from.
Bumping without losing a quarter
Before the first bump, I would find the catch blocks that swallow every exception, because they turn the loud half into the quiet half.
Then I would bump one package or group of classes at a time, so each changed number has an owner. Its tests run as a user with the narrowest profile that should still do the job. Every failure gets one of two answers. If the user should have had access, the fix is a permission. If the code should have had it, the fix is an explicit elevation with both the keyword and SYSTEM_MODE.
The standard that falls out of this is short enough to fit in a pull request template. Every class declares its keyword, even though no keyword is now safe, because a class that extends a decade-old parent takes the parent’s mode. Every elevated operation says SYSTEM_MODE on its own line. A bare without sharing is a review finding, since at v67 it does nothing and tells the next reader it does.
That leaves the elevation register: a search of the repo for SYSTEM_MODE, which lists every place the swipe card leaves the drawer.
In a fully bumped repo I would expect that list to be short enough to review in an afternoon, and in the pipeline it stays current with nobody maintaining it. I would keep a record of which failures went which way. It is the access audit nobody in the org ever commissioned, and v67 runs it for the price of a version number.