Optimize the document of Quark Script CWE-23 #52
Closed
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-23 in Android Application
This scenario aims to demonstrate the detection of the Relative Path Traversal vulnerability.
CWE-23: Relative Path Traversal
We analyze the definition of CWE-23 and identify its characteristics.
See CWE-23 for more details.
Code of CWE-23 in ovaa.apk
We use the ovaa.apk sample to explain the vulnerability code of CWE-23.
CWE-23 Detection Process Using Quark Script API
Let’s use the above APIs to show how the Quark script finds this vulnerability.
To begin with, we create a detection rule named
accessFileInExternalDir.json
to identify behavior that accesses a file in an external directory.Next, we use
methodInstance.getArguments()
to retrieve the file path argument and check whether it belongs to the APK. If it does not belong to the APK, the argument is likely from external input.Then, we use the Quark Script API
quarkResultInstance.findMethodInCaller(callerMethod, targetMethod)
to search for any APIs in the caller method that are used to match strings. If no API is found, that implies the APK does not neutralize special elements within the argument, possibly resulting in CWE-23 vulnerability.Quark Script: CWE-23.py
Quark Rule: accessFileInExternalDir.json
Quark Script Result