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
Ensure all the following status have been checked:
BIOMETRIC_ACQUIRED_GOOD (The image acquired was good.)
BIOMETRIC_ACQUIRED_IMAGER_DIRTY (The biometric image was too noisy due to suspected or detected dirt on the sensor.)
BIOMETRIC_ACQUIRED_INSUFFICIENT (The biometric image was too noisy to process due to a detected condition or a possibly dirty sensor)
BIOMETRIC_ACQUIRED_PARTIAL (Only a partial biometric image was detected.)
BIOMETRIC_ACQUIRED_TOO_FAST (The biometric image was incomplete due to quick motion.)
BIOMETRIC_ACQUIRED_TOO_SLOW (The biometric image was unreadable due to lack of motion.)
Violation Code Sample
private BiometricPrompt.AuthenticationCallback getAuthenticationCallback() {
// Callback for biometric authentication result
return new BiometricPrompt.AuthenticationCallback() {
@Override
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
Log.i(TAG, "onAuthenticationSucceeded");
super.onAuthenticationSucceeded(result);
// do not check success status
}
};
}
Fixed Code Sample
private BiometricPrompt.AuthenticationCallback getAuthenticationCallback() {
// Callback for biometric authentication result
return new BiometricPrompt.AuthenticationCallback() {
@Override
public void onAuthenticationSucceeded(BiometricPrompt.AuthenticationResult result) {
Log.i(TAG, "onAuthenticationSucceeded");
super.onAuthenticationSucceeded(result);
switch(result) {
case BIOMETRIC_ACQUIRED_GOOD:
Log.i("The image acquired was good");
// call the success method
break;
case BIOMETRIC_ACQUIRED_IMAGER_DIRTY:
case BIOMETRIC_ACQUIRED_INSUFFICIENT:
Log.i("The image acquired was not good, please try again");
// call again the authentication method
break;
case BIOMETRIC_ACQUIRED_PARTIAL:
case BIOMETRIC_ACQUIRED_TOO_FAST:
case BIOMETRIC_ACQUIRED_TOO_SLOW:
Log.i("Technical issue happened, please try again");
// call again the authentication method
break;
}
}
};
}
Reference
https://developer.android.com/reference/android/hardware/biometrics/BiometricPrompt#constants
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.