Add Quark script showcase of detecting CWE-256 #66
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-256 in Android Application
This scenario seeks to find Plaintext Storage of a Password.
CWE-256: Plaintext Storage of a Password
We analyze the definition of CWE-256 and identify its characteristics.
See CWE-256 for more details.
Code of CWE-256 in ovaa.apk
We use the ovaa.apk sample to explain the vulnerability code of CWE-256.
CWE-256 Detection Process Using Quark Script API
First, we define a detection rule
putStrAndCommit.json
to identify behaviors that store information usingSharedPreferences.Editor
.Next, we call
behaviorInstance.getParamValues()
to retrieve all parameter values associated with this behavior. We then check whether any parameter contains keywords that suggest it is being used as a password (e.g.,password
,pswd
, orpasswd
).Finally, we use
behaviorInstance.isArgFromMethod(targetMethod)
to verify whether thedoFinal
method for encryption is applied on the second argumentvalue
. (Note: this Quark Script API checks all arguments, not just a specific one. Therefore, the API returnsTrue
even if thedoFinal
method is applied on thekey
argument rather than thevalue
argument ofputString
. But the situation is so rare that we can neglect it.)If the answer is NO, it indicates that the value may be stored in plaintext, which could lead to a CWE-256 vulnerability.
Quark Script CWE-256.py
Quark Rule: putStrAndCommit.json
Quark Script Result