Skip to content

Commit 4d68bb3

Browse files
committed
insecure-biometrics-swift
1 parent 8fe5055 commit 4d68bb3

File tree

3 files changed

+154
-0
lines changed

3 files changed

+154
-0
lines changed
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
id: insecure-biometrics-swift
2+
language: swift
3+
severity: info
4+
message: >-
5+
The application was observed to leverage biometrics via Local
6+
Authentication, which returns a simple boolean result for authentication.
7+
This design is subject to bypass with runtime tampering tools such as
8+
Frida, Substrate, and others. Although this is limited to rooted
9+
(jailbroken) devices, consider implementing biometric authentication the
10+
reliable way - via Keychain Services.
11+
note: >-
12+
[CWE-305] Authentication Bypass by Primary Weakness
13+
[REFERENCES]
14+
- https://mobile-security.gitbook.io/mobile-security-testing-guide/ios-testing-guide/0x06f-testing-local-authentication
15+
- https://shirazkhan030.medium.com/biometric-authentication-in-ios-6c53c54f17df
16+
17+
rule:
18+
kind: navigation_expression
19+
pattern: $X.evaluatePolicy
20+
21+
constraints:
22+
X:
23+
any:
24+
- pattern: LAContext()
25+
- kind: simple_identifier
26+
inside:
27+
stopBy: end
28+
follows:
29+
stopBy: end
30+
kind: property_declaration
31+
all:
32+
- has:
33+
stopBy: end
34+
kind: simple_identifier
35+
pattern: $X
36+
- has:
37+
stopBy: end
38+
kind: call_expression
39+
field: value
40+
pattern: LAContext()
41+
- kind: simple_identifier
42+
follows:
43+
stopBy: end
44+
kind: property_declaration
45+
all:
46+
- has:
47+
stopBy: end
48+
kind: simple_identifier
49+
pattern: $X
50+
- has:
51+
stopBy: end
52+
kind: call_expression
53+
field: value
54+
pattern: LAContext()
Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
id: insecure-biometrics-swift
2+
snapshots:
3+
? |
4+
let context = LAContext()
5+
class Testing {
6+
var name: LAContext
7+
8+
init(name: LAContext) {
9+
self.name = name
10+
}
11+
12+
func speak() {
13+
// ruleid: insecure-biometrics
14+
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Authenticate to the application") { success, evaluationError in
15+
guard success else {
16+
// do...
17+
}
18+
}
19+
}
20+
: labels:
21+
- source: context.evaluatePolicy
22+
style: primary
23+
start: 179
24+
end: 201
25+
- source: context
26+
style: secondary
27+
start: 4
28+
end: 11
29+
- source: LAContext()
30+
style: secondary
31+
start: 14
32+
end: 25
33+
- source: let context = LAContext()
34+
style: secondary
35+
start: 0
36+
end: 25
37+
- source: let context = LAContext()
38+
style: secondary
39+
start: 0
40+
end: 25
41+
? |
42+
let context = LAContext()
43+
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Authenticate to the application") { success, evaluationError in
44+
guard success else {
45+
// do...
46+
}
47+
}
48+
: labels:
49+
- source: context.evaluatePolicy
50+
style: primary
51+
start: 26
52+
end: 48
53+
- source: context
54+
style: secondary
55+
start: 4
56+
end: 11
57+
- source: LAContext()
58+
style: secondary
59+
start: 14
60+
end: 25
61+
- source: let context = LAContext()
62+
style: secondary
63+
start: 0
64+
end: 25
65+
- source: let context = LAContext()
66+
style: secondary
67+
start: 0
68+
end: 25
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
id: insecure-biometrics-swift
2+
valid:
3+
- |
4+
let context = LAContext()
5+
guard context.canEvaluatePolicy(.deviceOwnerAuthentication, error: &error) else {
6+
// do...
7+
}
8+
invalid:
9+
- |
10+
let context = LAContext()
11+
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Authenticate to the application") { success, evaluationError in
12+
guard success else {
13+
// do...
14+
}
15+
}
16+
- |
17+
let context = LAContext()
18+
class Testing {
19+
var name: LAContext
20+
21+
init(name: LAContext) {
22+
self.name = name
23+
}
24+
25+
func speak() {
26+
// ruleid: insecure-biometrics
27+
context.evaluatePolicy(.deviceOwnerAuthentication, localizedReason: "Authenticate to the application") { success, evaluationError in
28+
guard success else {
29+
// do...
30+
}
31+
}
32+
}

0 commit comments

Comments
 (0)