-
Notifications
You must be signed in to change notification settings - Fork 6
Add security rules and tests for biometric authentication and WKWebView #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
id: insecure-biometrics-swift | ||
language: swift | ||
severity: info | ||
message: >- | ||
The application was observed to leverage biometrics via Local | ||
Authentication, which returns a simple boolean result for authentication. | ||
This design is subject to bypass with runtime tampering tools such as | ||
Frida, Substrate, and others. Although this is limited to rooted | ||
(jailbroken) devices, consider implementing biometric authentication the | ||
reliable way - via Keychain Services. | ||
note: >- | ||
[CWE-305] Authentication Bypass by Primary Weakness | ||
[REFERENCES] | ||
- https://mobile-security.gitbook.io/mobile-security-testing-guide/ios-testing-guide/0x06f-testing-local-authentication | ||
- https://shirazkhan030.medium.com/biometric-authentication-in-ios-6c53c54f17df | ||
|
||
rule: | ||
kind: navigation_expression | ||
pattern: $X.evaluatePolicy | ||
|
||
constraints: | ||
X: | ||
any: | ||
- pattern: LAContext() | ||
- kind: simple_identifier | ||
inside: | ||
stopBy: end | ||
follows: | ||
stopBy: end | ||
kind: property_declaration | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: simple_identifier | ||
pattern: $X | ||
- has: | ||
stopBy: end | ||
kind: call_expression | ||
field: value | ||
pattern: LAContext() | ||
- kind: simple_identifier | ||
follows: | ||
stopBy: end | ||
kind: property_declaration | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: simple_identifier | ||
pattern: $X | ||
- has: | ||
stopBy: end | ||
kind: call_expression | ||
field: value | ||
pattern: LAContext() |
141 changes: 141 additions & 0 deletions
141
rules/swift/security/swift-webview-config-allows-js-open-windows-swift.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
id: swift-webview-config-allows-js-open-windows-swift | ||
language: swift | ||
severity: warning | ||
message: >- | ||
Webviews were observed that explictly allow JavaScript in an WKWebview | ||
to open windows automatically. Consider disabling this functionality if | ||
not required, following the principle of least privelege. | ||
note: >- | ||
[CWE-272]: Least Privilege Violation | ||
[REFERENCES] | ||
https://mas.owasp.org/MASVS/controls/MASVS-PLATFORM-2/ | ||
https://developer.apple.com/documentation/webkit/wkpreferences/1536573-javascriptcanopenwindowsautomati | ||
utils: | ||
match_JavaScriptCanOpenWindowsAutomatically: | ||
kind: assignment | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: navigation_expression | ||
has: | ||
stopBy: end | ||
kind: simple_identifier | ||
pattern: $R | ||
- has: | ||
stopBy: end | ||
kind: navigation_suffix | ||
has: | ||
stopBy: end | ||
kind: simple_identifier | ||
regex: "^JavaScriptCanOpenWindowsAutomatically$" | ||
- has: | ||
kind: boolean_literal | ||
regex: "^true$" | ||
- follows: | ||
stopBy: end | ||
kind: property_declaration | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: pattern | ||
field: name | ||
has: | ||
kind: simple_identifier | ||
pattern: $R | ||
- has: | ||
stopBy: end | ||
kind: call_expression | ||
field: value | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: simple_identifier | ||
regex: "^WKPreferences$" | ||
- has: | ||
stopBy: end | ||
kind: call_suffix | ||
has: | ||
stopBy: end | ||
kind: value_arguments | ||
- not: | ||
precedes: | ||
stopBy: neighbor | ||
kind: assignment | ||
has: | ||
stopBy: end | ||
kind: boolean_literal | ||
regex: "^true$|false" | ||
- not: | ||
follows: | ||
stopBy: neighbor | ||
kind: assignment | ||
has: | ||
stopBy: end | ||
kind: boolean_literal | ||
regex: "^true$" | ||
match_non_boolean: | ||
kind: assignment | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: navigation_expression | ||
has: | ||
stopBy: end | ||
kind: simple_identifier | ||
pattern: $R | ||
- has: | ||
stopBy: end | ||
kind: navigation_suffix | ||
has: | ||
stopBy: end | ||
kind: simple_identifier | ||
regex: "^JavaScriptCanOpenWindowsAutomatically$" | ||
- has: | ||
kind: simple_identifier | ||
- follows: | ||
stopBy: end | ||
kind: property_declaration | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: pattern | ||
field: name | ||
has: | ||
kind: simple_identifier | ||
pattern: $R | ||
- has: | ||
stopBy: end | ||
kind: call_expression | ||
field: value | ||
all: | ||
- has: | ||
stopBy: end | ||
kind: simple_identifier | ||
regex: "^WKPreferences$" | ||
- has: | ||
stopBy: end | ||
kind: call_suffix | ||
has: | ||
stopBy: end | ||
kind: value_arguments | ||
- not: | ||
precedes: | ||
stopBy: neighbor | ||
kind: assignment | ||
has: | ||
stopBy: end | ||
kind: boolean_literal | ||
regex: "^true$|false" | ||
- not: | ||
follows: | ||
stopBy: neighbor | ||
kind: assignment | ||
has: | ||
stopBy: end | ||
kind: boolean_literal | ||
regex: "^true$" | ||
|
||
rule: | ||
any: | ||
- matches: match_JavaScriptCanOpenWindowsAutomatically | ||
- matches: match_non_boolean |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.