By default Apex code executes without checking permissions. Hence the code will not enforce field level security, sharing rules and user permissions during execution of Apex code in Triggers, Classes and Controllers. This creates the risk that unauthorized users may get access to sensitive data records or fields.
To prevent this, developers should use ``++with sharing++`` keyword when declaring their classes if the class has SOQL or SOSL queries or DML Statements. This will ensure that current user's permissions, field level security and sharing rules are enforced during code execution. Thus users will only see or modify records and fields which they have access to.
Use ``++without sharing++`` when a specific class should have full access to records without taking into account current user's permissions. This should be used very carefully.
Use ``++inherited sharing++`` when the code should inherit the level of access from the calling class. This is more secure than not specifying a sharing level as the default will be equivalent to "with sharing".
This rule raises an issue when a class containing DML, SOSL or SOQL queries has no sharing level specified (``++with sharing++``, ``++without sharing++``, ``++inherited sharing++``).
* https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_sharing.htm[Using the with sharing, without sharing, and inherited sharing Keywords]