Software security is not security software. Here we're concerned with topics like authentication, access control, confidentiality, cryptography, and privilege management.
<uses-permission .../>
element of AndroidManifest.xml declares usage of the BODY_SENSORS
permission, which enables an application to access data from body or environmental sensors on the device or connected wearables.<uses-permission android:name="android.permission.BODY_SENSORS"/>
number = tm.getCompleteVoiceMailNumber();
FLAG_GRANT_READ_URI_PERMISSION
and FLAG_GRANT_WRITE_URI_PERMISSION
. If a malicious program is able to intercept this intent, it will then gain permission to read from or write to the specified URI. These can often be more susceptible to being intercepted if the intent is implicit rather than explicit.
myIntent.setFlags(Intent.FLAG_GRANT_WRITE_URI_PERMISSION);
AUTHID
clause default to AUTHID DEFINER
.AUTHID DEFINER
or AUTHID CURRENT_USER
. Functions and procedures with definer's rights execute under the privileges of the user that defines the code. This can allow updates and access to specific pieces of data without granting access to entire tables or schemas. With invoker's rights, or AUTHID CURRENT_USER
, functions and procedures execute under the privileges of the user who invokes them. This does not allow a user to gain access to data it didn't already have access to. If no AUTHID
clause is provided, the function or procedure defaults to definer's rights.SYS
or another highly privileged user, making any exploits of the code potentially more dangerous.AUTHID
clause default to AUTHID DEFINER
.AUTHID DEFINER
or AUTHID CURRENT_USER
. Functions and procedures in a package with definer's rights execute under the privileges of the user that defines the package. This can allow updates and access to specific pieces of data without granting access to entire tables or schemas. In a package with invoker's rights, or AUTHID CURRENT_USER
, functions and procedures execute under the privileges of the user who invokes them. This does not allow a user to gain access to data it didn't already have access to. If no AUTHID
clause is provided, the package defaults to definer's rights.SYS
or another highly privileged user, making any exploits of the code potentially more dangerous.AndroidManifest.xml
file via <uses-permission/>
tags. If the required permissions are not requested, the operations that require these permissions will fail at runtime. In some cases, a java.lang.SecurityException
is thrown back to the application. Other times, operations fail silently without an exception.sms.sendTextMessage(recipient, null, message, PendingIntent.getBroadcast(SmsMessaging.this, 0, new Intent(ACTION_SMS_SENT), 0), null);
android.permission.SEND_SMS
permission. If this permission is not requested by the application in the manifest file, the application will fail to send an SMS.AndroidManifest.xml
file via <uses-permission/>
tags. If the required permissions are not requested, the operations that require these permissions will fail at runtime. In some cases, a java.lang.SecurityException
is thrown back to the application. Other times, operations fail silently without an exception.Cursor cursor = getContentResolver().query(ContactsContract.Contacts.CONTENT_URI, null, null, null, null);
android.permission.READ_CONTACTS
permission. If this permission is not requested by the application in the manifest file, the application will fail to read contacts information.AndroidManifest.xml
file via <uses-permission/>
tags. If the required permissions are not requested, the operations that require these permissions will fail at runtime. In some cases, a java.lang.SecurityException
is thrown back to the application. Other times, operations fail silently without an exception.android.provider.Telephony.SMS_RECEIVED
action.
Intent i = new Intent("android.provider.Telephony.SMS_RECEIVED");
context.sendBroadcast(i);
android.permission.BROADCAST_SMS
permission. If this permission is not requested by the application in the manifest file, the application will fail to send the intent.public
methods can be called from anywhere in the JVM.public
access specifier means that any external code is allowed to call it. Public methods that perform privileged actions can be dangerous when code is shared in libraries or in environments where code can dynamically enter the system (e.g. Code Injection, Dangerous File Inclusion, File Upload, etc).doPrivilegedOpenFile()
is declared public
and performs a privileged operation.
public static void doPrivilegedOpenFile(final String filePath) {
final BadFileNamePrivilegedAction pa = new BadFileNamePrivilegedAction(filePath);
FileInputStream fis = null;
...
fis = (FileInputStream)AccessController.doPrivileged(pa);
...
}
ALL PRIVILEGES
or ALL
option will grant the user all of the permissions that can be applied to an object. The programmer may not be aware of all of the privileges being granted.
GRANT ALL ON employees TO john_doe;
john_doe
now has permission to change the definition of the table.true
to specify that permission was given:
public void onGeolocationPermissionsShowPrompt(String origin, GeolocationPermissions$Callback callback){
super.onGeolocationPermissionsShowPrompt(origin, callback);
callback.invoke(origin, true, false);
}
ACTUATOR
role may access them.
management.security.enabled=false
endpoints.health.sensitive=false
@Component
public class CustomEndpoint implements Endpoint<List<String>> {
public String getId() {
return "customEndpoint";
}
public boolean isEnabled() {
return true;
}
public boolean isSensitive() {
return false;
}
public List<String> invoke() {
// Custom logic to build the output
...
}
}
spring.application.admin.enabled
property. This exposes the SpringApplicationAdminMXBean
on the platform MBeanServer
. Developers could use this feature to administer the Spring Boot application remotely, however this feature exposes an additional attack surface in the form of a remote JMX endpoint. Depending on the configuration of the MBeanServer
the MBean
can be exposed locally or remotely, and may or may not require authentication. In the worst case, attackers will be able to manage the application remotely, including shutting it down without any authentication. In the best case, the service will be as strong as the credentials used to protect the server.spring-boot-devtools
on a remote application is a security risk. You should never enable support on a production deployment."
endpoints.shutdown.enabled=true
<http auto-config="true">
...
<intercept-url pattern="/app/admin" access="ROLE_ADMIN" />
<intercept-url pattern="/**" access="permitAll" />
</http>
Cache-Control: no-cache, no-store, max-age=0, must-revalidate
Pragma: no-cache
Expires: 0
X-Content-Type-Options: nosniff
Strict-Transport-Security: max-age=31536000 ; includeSubDomains
X-Frame-Options: DENY
X-XSS-Protection: 1; mode=block
<http auto-config="true">
...
<headers disabled="true"/>
...
</http>
Ant
path expressions to specify how to protect endpoints./admin
" Ant
path expression requires administrator privileges for access:
<http auto-config="true">
...
<intercept-url pattern="/app/admin" access="ROLE_ADMIN" />
...
<intercept-url pattern="/**" access="permitAll" />
</http>
Accept
header or by specifying the desired content-type using an extension. For example, you can request the /admin
resource as a JSON document by sending the request to /admin.json
.Ant
path expressions do not account for content-negotiation extensions, and therefore, the request does not match the /admin
expression and the endpoint is not protected.