Salesforce Decode
Salesforcedecode
Back to questions
ApexBeginnersecuritycrudfls

What is CRUD and FLS security in Apex?

Real World Scenario

A class with sharing disabled exposes salary fields to users who should not see them. You explain security checks.

Expected Answer

• CRUD checks whether user can create, read, update, delete object type • FLS (field-level security) controls visibility and editability per field • Use WITH SECURITY_ENFORCED in SOQL or Schema.Describe calls to respect permissions • Classes default to user sharing with "with sharing" keyword—without sharing bypasses record rules • Never assume admin-written Apex is safe for all users—enforce least privilege

Follow-Up Questions & Answers

Click to expand — each follow-up includes a direct, interview-ready answer

Class ignores sharing rules and runs in system context for record access. Use sparingly with explicit CRUD/FLS checks.

Architect Perspective

with sharing + stripInaccessible is the modern junior security combo to name-drop.