Software security is not security software. Here we're concerned with topics like authentication, access control, confidentiality, cryptography, and privilege management.
with sharing
: The user sharing rules will be enforced.without sharing
: The sharing rules will not be enforced.inherited sharing
: The sharing rules of the calling class will be enforced. When the calling class does not specify a sharing keyword, or when the class itself is an entrypoint such as a Visualforce controller, the user sharing rules will be enforced by default.
public class MyClass1 {
public List<Contact> getAllTheSecrets() {
return Database.query('SELECT Name FROM Contact');
}
}
public without sharing class MyClass2 {
public List<Contact> getAllTheSecrets() {
return Database.query('SELECT Name FROM Contact');
}
}
public inherited sharing class MyClass3 {
public List<Contact> getAllTheSecrets() {
return Database.query('SELECT Name FROM Contact');
}
}
MyClass1
and MyClass2
are unsafe because the records can be retrieved without the enforcement of user sharing rules.MyClass3
is safer because it enforces sharing rules by default. However, unauthorized access can still be granted if function getAllTheSecrets()
is called in a class that explicitly declares without sharing
.<security constraint>
element suggests the program does not employ role-based access control, which is commonly accepted best practice for protecting sensitive operations in secure web applications. If the application provides access to sensitive operations or data, there might not be sufficient controls in place to prevent unauthorized users from gaining access. Furthermore, if there is a wildcard (*) in the <url-pattern>
, it can be an indication that the pattern is overly broad.
<property name="filterInvocationDefinitionSource">
<value>
CONVERT_URL_TO_LOWERCASE_BEFORE_COMPARISON
\A/secure/.*\Z=REQUIRES_SECURE_CHANNEL
\A/acegilogin.jsp.*\Z=REQUIRES_SECURE_CHANNEL
\A/j_acegi_security_check.*\Z=REQUIRES_SECURE_CHANNEL
\A.*\Z=REQUIRES_INSECURE_CHANNEL
</value>
</property>
<bean id="bankManagerSecurity" class="org.acegisecurity.intercept.method.aopalliance.MethodSecurityInterceptor">
...
<property name="objectDefinitionSource">
<value>
com.example.service.PrivateCatalog.getData=ROLE_PEON,RUN_AS_UBER_BOSS
...
</value>
</property>
</bean>
writePermission
defined.writePermission
could be misleading. Due to the nature of SQL, generating true write-only queries is generally impossible: even when the user does not have direct access to the data, an attacker may reconstruct the stored data by manipulating the where
clause.writePermission
.<provider android:name=".ContentProvider" android:writePermission="content.permission.WRITE_CONTENT"/>
...
context.registerReceiver(broadcastReceiver, intentFilter);
...
exported
attribute for the activity, receiver, and service components in an Android application depends on the presence or absence of an intent-filter
. Presence of an intent-filter
implies, the component is intended for external use, thus setting the exported
attribute to true. This component is now accessible to any other applications on the Android platform.intent-filter
and no explicit access permission set.<activity android:name=".AndroidActivity"/>
<intent-filter android:label="activityName"/>
<action android:name=".someFunAction"/>
</intent-filter>
...
</activity>
<provider android:name=".ContentProvider"/>
...
context.sendBroadcast(intent);
...
normal
protection level.normal
, dangerous
, signature
, and signature or system
. Normal
permissions are granted to any application that requests them. Dangerous
permissions are granted only after user confirmation. Signature
permissions are granted only to applications signed by the same developer key as the package that defines the permission. Signature or system
permissions are similar to signature
permissions, but are also granted to packages in the Android system image.normal
protection level.<permission android:name="custom.PERMISSION"
android:label="@string/label_permission"
android:description="@string/desc_permission"
android:protectionLevel="normal">
</permission>
permission
.permission
will be accessible to the entities that request either read or write access to the provider. However, in many cases, just like in the case of files on a file system, entities that need read access to the data stored by the provider should not be allowed to modify the data. Setting the permission
attribute does not allow to distinguish between data users and interactions that affect the data's integrity.permission
.<provider android:name=".ContentProvider" android:permission="content.permission.READ_AND_WRITE_CONTENT"/>
...
context.sendStickyBroadcast(intent);
...
android.permission
namespace.android.permission
namespace can have unexpected consequences when the OS is updated. If the newer version of the OS defines the exact same permission, the Android Package Management Service (PMS) will silently grant the permission to the app without asking the user allowing privilege escalation attacks.
myModule.config(function($compileProvider){
$compileProvider.imgSrcSanitizationWhitelist(/^(http(s)?|javascript):.*/);
});