Rule Definition
Running an application which does not fail of/correctly use the platform capability is a mandatory step from development team. The defining characteristic of risks in this category of rules is that the platform (iOS, Android, Windows Phone, etc.) provides a feature or a capability that is documented and well understood.
Remediation
Always manage the error options:
BIOMETRIC_ERROR_CANCELED
BIOMETRIC_ERROR_HW_NOT_PRESENT
BIOMETRIC_ERROR_HW_UNAVAILABLE
BIOMETRIC_ERROR_LOCKOUT
BIOMETRIC_ERROR_LOCKOUT_PERMANENT
BIOMETRIC_ERROR_NO_BIOMETRICS
BIOMETRIC_ERROR_NO_SPACE
BIOMETRIC_ERROR_TIMEOUT
BIOMETRIC_ERROR_UNABLE_TO_PROCESS
BIOMETRIC_ERROR_USER_CANCELED
BIOMETRIC_ERROR_VENDOR
Violation Code Sample
private BiometricPrompt.AuthenticationCallback getAuthenticationCallback() {
// Callback for biometric authentication result
return new BiometricPrompt.AuthenticationCallback() {
@Override
public void onAuthenticationError(int errorCode, CharSequence errString) {
super.onAuthenticationError(errorCode, errString);
}
};
}
Fixed Code Sample
private BiometricPrompt.AuthenticationCallback getAuthenticationCallback() {
// Callback for biometric authentication result
return new BiometricPrompt.AuthenticationCallback() {
@Override
public void onAuthenticationError(int errorCode, CharSequence errString) {
super.onAuthenticationError(errorCode, errString);
switch(errorCode) {
case BIOMETRIC_ERROR_CANCELED:
case BIOMETRIC_ERROR_HW_UNAVAILABLE:
Log.i("The operation was canceled because the biometric sensor is unavailable");
break;
case BIOMETRIC_ERROR_HW_NOT_PRESENT:
Log.i("The device does not have a biometric sensor");
break;
// etc...
}
}
};
}
Related Technologies
Technical Criterion
CWE-391 - Unchecked Error Condition
About CAST Appmarq
CAST Appmarq is by far the biggest repository of data about real IT systems. It's built on thousands of analyzed applications, made of 35 different technologies, by over 300 business organizations across major verticals. It provides IT Leaders with factual key analytics to let them know if their applications are on track.