# What is the difference between WITH SECURITY_ENFORCED and Security.stripInaccessible()?

**Topic:** Soql · **Difficulty:** Hard · **Asked at:** Deloitte, Accenture, PwC · **Tags:** soql, security, fls

Read it on the site: https://www.forcechallenges.com/interview-questions/what-is-the-difference-between-with-security-enforced-and-security-stripinaccessible

## Answer

- **`WITH SECURITY_ENFORCED`**: checks FLS/CRUD for fields in the SELECT (and some parents) and **throws** a `System.QueryException` if any are inaccessible. It does not check fields in WHERE/ORDER BY.
- **`Security.stripInaccessible()`**: does not throw; it **removes** inaccessible fields from records (or the whole record) and lets you continue, also usable for DML sanitization.

```apex
SObjectAccessDecision d = Security.stripInaccessible(AccessType.READABLE, [SELECT Id, Phone FROM Account]);
List<Account> safe = d.getRecords();
```
Use `stripInaccessible` when you want graceful degradation; use `WITH USER_MODE` (newer) for strict enforcement.

---
Source: ForceChallenges · last updated 2026-10-21
