Skip to content

Commit 444f5d4

Browse files
committed
drop support for obsolete deny new USB setting
This was replaced by our newer generation USB-C port and pogo pins. The software USB enforcement was extended to USB gadget mode in addition to USB peripherals and the feature is now mainly based on hardware level enforcement for USB-C and pogo pins eliminating far more attack surface. Checking the value of the new setting will require creating an SELinux domain for Auditor to allow it to read the new property.
1 parent 4d62bb9 commit 444f5d4

2 files changed

Lines changed: 3 additions & 16 deletions

File tree

app/src/main/java/app/attestation/auditor/AttestationProtocol.java

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ class AttestationProtocol {
204204
private static final int OS_ENFORCED_FLAGS_ADB_ENABLED = 1 << 3;
205205
private static final int OS_ENFORCED_FLAGS_ADD_USERS_WHEN_LOCKED = 1 << 4;
206206
private static final int OS_ENFORCED_FLAGS_ENROLLED_BIOMETRICS = 1 << 5;
207-
private static final int OS_ENFORCED_FLAGS_DENY_NEW_USB = 1 << 6;
207+
private static final int OS_ENFORCED_FLAGS_DENY_NEW_USB = 1 << 6; // obsolete
208208
private static final int OS_ENFORCED_FLAGS_DEVICE_ADMIN_NON_SYSTEM = 1 << 7;
209209
private static final int OS_ENFORCED_FLAGS_OEM_UNLOCK_ALLOWED = 1 << 8;
210210
private static final int OS_ENFORCED_FLAGS_SYSTEM_USER = 1 << 9;
@@ -215,7 +215,6 @@ class AttestationProtocol {
215215
OS_ENFORCED_FLAGS_ADB_ENABLED |
216216
OS_ENFORCED_FLAGS_ADD_USERS_WHEN_LOCKED |
217217
OS_ENFORCED_FLAGS_ENROLLED_BIOMETRICS |
218-
OS_ENFORCED_FLAGS_DENY_NEW_USB |
219218
OS_ENFORCED_FLAGS_DEVICE_ADMIN_NON_SYSTEM |
220219
OS_ENFORCED_FLAGS_OEM_UNLOCK_ALLOWED |
221220
OS_ENFORCED_FLAGS_SYSTEM_USER;
@@ -951,7 +950,7 @@ private static VerificationResult verify(final Context context, final byte[] fin
951950
final boolean accessibility, final boolean deviceAdmin,
952951
final boolean deviceAdminNonSystem, final boolean adbEnabled,
953952
final boolean addUsersWhenLocked, final boolean enrolledBiometrics,
954-
final boolean denyNewUsb, final boolean oemUnlockAllowed, final boolean systemUser)
953+
final boolean oemUnlockAllowed, final boolean systemUser)
955954
throws GeneralSecurityException, IOException {
956955
final String fingerprintHex = BaseEncoding.base16().encode(fingerprint);
957956
final byte[] currentFingerprint = getFingerprint(attestationCertificates[0]);
@@ -1122,8 +1121,6 @@ private static VerificationResult verify(final Context context, final byte[] fin
11221121
toYesNoString(context, adbEnabled)));
11231122
osEnforced.append(context.getString(R.string.add_users_when_locked,
11241123
toYesNoString(context, addUsersWhenLocked)));
1125-
osEnforced.append(context.getString(R.string.deny_new_usb,
1126-
toYesNoString(context, denyNewUsb)));
11271124
osEnforced.append(context.getString(R.string.oem_unlock_allowed,
11281125
toYesNoString(context, oemUnlockAllowed)));
11291126
osEnforced.append(context.getString(R.string.system_user,
@@ -1219,7 +1216,6 @@ static VerificationResult verifySerialized(final Context context, final byte[] a
12191216
final boolean adbEnabled = (osEnforcedFlags & OS_ENFORCED_FLAGS_ADB_ENABLED) != 0;
12201217
final boolean addUsersWhenLocked = (osEnforcedFlags & OS_ENFORCED_FLAGS_ADD_USERS_WHEN_LOCKED) != 0;
12211218
final boolean enrolledBiometrics = (osEnforcedFlags & OS_ENFORCED_FLAGS_ENROLLED_BIOMETRICS) != 0;
1222-
final boolean denyNewUsb = (osEnforcedFlags & OS_ENFORCED_FLAGS_DENY_NEW_USB) != 0;
12231219
final boolean oemUnlockAllowed = (osEnforcedFlags & OS_ENFORCED_FLAGS_OEM_UNLOCK_ALLOWED) != 0;
12241220
final boolean systemUser = (osEnforcedFlags & OS_ENFORCED_FLAGS_SYSTEM_USER) != 0;
12251221

@@ -1237,8 +1233,7 @@ static VerificationResult verifySerialized(final Context context, final byte[] a
12371233
final byte[] challenge = Arrays.copyOfRange(challengeMessage, 1 + RANDOM_TOKEN_LENGTH, 1 + RANDOM_TOKEN_LENGTH * 2);
12381234
return verify(context, fingerprint, challenge, deserializer.asReadOnlyBuffer(), signature,
12391235
certificates, userProfileSecure, accessibility, deviceAdmin, deviceAdminNonSystem,
1240-
adbEnabled, addUsersWhenLocked, enrolledBiometrics, denyNewUsb, oemUnlockAllowed,
1241-
systemUser);
1236+
adbEnabled, addUsersWhenLocked, enrolledBiometrics, oemUnlockAllowed, systemUser);
12421237
}
12431238

12441239
static class AttestationResult {
@@ -1433,10 +1428,6 @@ static AttestationResult generateSerialized(final Context context, final byte[]
14331428
final boolean addUsersWhenLocked = Settings.Global.getInt(context.getContentResolver(),
14341429
ADD_USERS_WHEN_LOCKED, 0) != 0;
14351430

1436-
final String denyNewUsbValue =
1437-
SystemProperties.get("persist.security.deny_new_usb", "disabled");
1438-
final boolean denyNewUsb = !denyNewUsbValue.equals("disabled");
1439-
14401431
final String oemUnlockAllowedValue = SystemProperties.get("sys.oem_unlock_allowed", "0");
14411432
final boolean oemUnlockAllowed = oemUnlockAllowedValue.equals("1");
14421433

@@ -1487,9 +1478,6 @@ static AttestationResult generateSerialized(final Context context, final byte[]
14871478
if (enrolledBiometrics) {
14881479
osEnforcedFlags |= OS_ENFORCED_FLAGS_ENROLLED_BIOMETRICS;
14891480
}
1490-
if (denyNewUsb) {
1491-
osEnforcedFlags |= OS_ENFORCED_FLAGS_DENY_NEW_USB;
1492-
}
14931481
if (oemUnlockAllowed) {
14941482
osEnforcedFlags |= OS_ENFORCED_FLAGS_OEM_UNLOCK_ALLOWED;
14951483
}

app/src/main/res/values/strings.xml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@
8484
<string name="device_admin_non_system">yes, with non-system apps</string>
8585
<string name="adb_enabled">Android Debug Bridge enabled: %s\n</string>
8686
<string name="add_users_when_locked">Add users from lock screen: %s\n</string>
87-
<string name="deny_new_usb">Deny new USB peripherals when locked: %s\n</string>
8887
<string name="oem_unlock_allowed">OEM unlocking allowed: %s\n</string>
8988
<string name="system_user">Main user account: %s\n</string>
9089

0 commit comments

Comments
 (0)