Optimize the CWE-20 document#642
Merged
Merged
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #642 +/- ##
=======================================
Coverage 78.74% 78.74%
=======================================
Files 64 64
Lines 5325 5325
=======================================
Hits 4193 4193
Misses 1132 1132
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
zinwang
approved these changes
May 8, 2024
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Detect CWE-20 in Android Application
This scenario seeks to find Improper Input Validation in the APK file.
CWE-20 Improper Input Validation
We analyze the definition of CWE-20 and identify its characteristics.
See CWE-20 for more details.
Code of CWE-20 in diva.apk
We use the diva.apk sample to explain the vulnerability code of CWE-20.
Quark Script CWE-20.py
Let’s use the above APIs to show how the Quark script finds this vulnerability.
First, we design a detection rule
openUrlThatUserInput.json, to spot the behavior of opening the URL that the user inputs. Then, we use APIbehaviorInstance.getMethodsInArgs()to get a list of methods that the URL inloadUrlpasses through. Finally, we check if any validation method is in the list. If No, the APK does not validate user input. That causes CWE-20 vulnerability.Quark Rule: openUrlThatUserInput.json
{ "crime": "Open the Url that user input", "permission": [], "api": [ { "class": "Landroid/widget/EditText;", "method": "getText", "descriptor": "()Landroid/text/Editable;" }, { "class": "Landroid/webkit/WebView;", "method": "loadUrl", "descriptor": "(Ljava/lang/String;)V" } ], "score": 1, "label": [] }Quark Script Result