Closed 131220065 closed 5 years ago
Thank you for your bug report. We will confirm this bug in several weeks.
Sorry for late response.
We confirmed 1, 3, 4 bugs in HybriDroid, but we already treat the sub class problem in the "isHotspot" method, which you described in the second bug case. And, in the fourth bug case, HybriDroid can treat multiple objects as a bridge object when one variable points to the multiple objects.
We will fix the bugs as soon as possible, referring to your fix.
Again, thank you for your kind bug report, and please feel free to contact us when you have any questions or problems.
Thank you!
That's all right. And thank you for your response, which is a affirmation of my work.
In the fourth bug case, I didn't consider the case of multiple bridge objects indeed.
And in the third bug case, I find that Not only the AndroidStringAnalysis.java
need add the MultiDex support, but also the AndroidHybridAnalysisScope.java
. Because HybriDroid make twice CallGraph.
And the two CallGraphBuilder can use the same AnalysisCache
, which may save the time and space.
Actually, I run a test for the newest Cordova's example App, and it seems that WALA can't deal with Cordova's JS files, and after 12 hours, the result doesn't come out.
And the Taint Analyzer of HybriDroid seems easy to be out of memory and need too much time, is that true? My eclispe's run configuration arguments setting is "-XX:-UseGCOverheadLimit -Xmx4096m -Xms4096m -Xmn2g", and I ran some tests for real-world Apps.
Yes, HybriDroid constructs call graph twice for string and main analysis. We do not reuse AnalysisCache
to detach the string analysis module from others, but you can reuse it for performance benefit.
HybriDroid cannot analyze Cordova apps precisely, even though they are implemented in hybrid apps. The main reason is that Cordova uses String based commands to access device resources from JavaScript code. The Cordova structure makes HybriDroid to take long time for analysis and make much false positives via spurious control flows. We think that additional models or approaches are needed to handle that.
Did you use TaintAnalysisForHybrid
module for taint analysis? We recommend PrivateLeakageDetector
instead of it. TaintAnalysisForHybrid
is not tested and we will revise or eliminate the module when it does not have differences from PrivateLeakageDetector
.
I used PrivateLeakageDetector
, and did a test for this apk. And below is the code:
ModeledCallGraphForTaint mcg = new ModeledCallGraphForTaint(p.fst);
PrivateLeakageDetector pld = new PrivateLeakageDetector(mcg, p.snd);
pld.analyze();
System.out.println("#taint anlysis time: " + (System.currentTimeMillis() - endTime) / 1000 + "s");
for(LeakWarning w : pld.getWarnings()){
System.out.println("=========");
System.out.println(w);
System.out.println("=========");
w.printPathFlow("leak.dot");
}
Usually, ModeledCallGraphForTaint
is not necessary to track taint data, because the module adds additional edges via Inter-component implicit flows. The module finds the flows using CHA style analysis and spends much memory, so you should use an original call graph instead of ModeledCallGraphForTaint
.
Also, the apk does not have any local html files. In that case, HybriDroid does not analyze it fully, when the StringAnalysis module can not find any target html addresses. You can use another string analysis module, like JSA, to analyze target html addresses more precisely.
OK, after using the original call graph, the program can finish quickly. Thanks a lot. But I don't know what does the "JSA" mean, what's the "JSA"?
JSA is a string analysis tool based-on Soot. We firstly tried to use the module instead of our own module, but its forward analysis is too heavy for us. But in some cases, it may produce more adequate than our module.
Thank you very much again!
Sorry for the quite late update! Finally, we have fixed the bugs you found out! It is quite late because of my personal works related to this project. Thank you.
Hello, Mr Lee, I'm a Chinese student in Nanjing University and I'm doing my graduation project with HybriDroid. Then, I found some bugs in HybriDroid, they're below:
1. com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/html/DomLessSourceExtractor.java
After you modified
com.ibm.wala.cast.js/source/com/ibm/wala/cast/js/html/DomLessSourceExtractor.java
, I found that the js file linked to the html file never be added to the analysis scope. So I modified it back, then it returned to normal. And below is my code:2. Having no regard for sub classes of
WebView
for gettingloadUrl
method's parameter in String AnalysisIn
AndroidStringAnalysis.java
, theanalyse
method, the hotspots is only theWebView.loadUrl
hotspot, Then infindHotspots
method, calling theisHotspot
method only judged theinstruction
's class and method descriptor equalsWebView
andloadUrl
, having no regard for the sub classes ofWebView
. My method to solve the problem is getting the sub classes ofWebView
and add to the hotspots:3. Multi Dex
Some big Android Apps have more than one dex file. Also in
AndroidStringAnalysis.java
, the methodaddAnalysisScope
only add the apk file to the analysis scope. However, it only can add the first dex file "classes.dex" to the analysis scope. What I do is unzip the all dex files to a folder, and add the all dex files to the analysis scope:Also, in
AndroidResourceAnalysis.extractResources
, the smali dir maybe multi, the apktool can extract multi dex to multi smali dirs. TheextractResources
method only considered one smali dir.4. Bridge Object's Dealing
Above is my hybrid android example, there is a field
privateDataGetter
in my bridge classMyJSBridge
, and it is initialized inMyJSBridge
's constructor method, and my bridge methodgetContactsInfo()
calls the fieldprivateDataGetter
's methodgetPhoneContacts
andgetSIMContacts
. Then,addJavascriptInterface
to insert the object to JS environment as"bridge"
. The bridge method is called in JS environment. However, theCallGraph
that HybriDroid generates doesn't contains the two nodesgetPhoneContacts
andgetSIMContacts
. Then I found that inAndroidHybridCallGraphBuilder.java
, theHybridJavaConstraintVisitor.visitInvoke
method deals with the bridge classes. However, it creates a newInstanceKey
for the bridge classes, having no regard for thePointerAnalysis
result about the bridge classes, so maybe the WALA don't know where is the fieldprivateDataGetter initialized
. These are what I do to solve the bug:I use the
PointerAnalysis
to get the bridge class'sInstanceKey
, then change theIClass
binded to theInstanceKey
(modify theConcreteTypeKey
class to add thechangeTypeTo
method, though that is ugly, it works). After that, do the next things as the same as the original. Also, I think there is some needless code in the visitInvoke method, such as theBridgeInfo bi
's use, and theConcreteTypeKey objKeys[]
array (I think the visitInvoke method can determine one bridge at a time), So I change the method to below:Then, the
CallGraph
HybriDroid generated contains the two nodesgetPhoneContacts
andgetSIMContacts
.