secure-software-engineering / FlowDroid

FlowDroid Static Data Flow Tracker
GNU Lesser General Public License v2.1
1.06k stars 298 forks source link

soot.SootMethodRefImpl$ClassResolutionFailedException #49

Open traceprobe opened 6 years ago

traceprobe commented 6 years ago

I am trying to build info flow graph (no tainting) with the following code: SetupApplication analyzer = new SetupApplication(FRAMEWORK_DIR, APK_PATH); analyzer.getConfig().setTaintAnalysisEnabled(false); analyzer.getConfig().setMergeDexFiles(true); analyzer.constructCallgraph();

For any apk file, i got the following exception: soot.SootMethodRefImpl$ClassResolutionFailedException: Class android.content.ServiceConnection doesn't have method onServiceConnected([android.content.ComponentName]) : void; failed to resolve in superclasses and interfacesLooking in android.content.ServiceConnection which has methods [<android.content.ServiceConnection: void onServiceConnected(android.content.ComponentName,android.os.IBinder)>, <android.content.ServiceConnection: void onServiceDisconnected(android.content.ComponentName)>] at soot.SootMethodRefImpl.resolve(SootMethodRefImpl.java:237) at soot.SootMethodRefImpl.resolve(SootMethodRefImpl.java:152) at soot.jimple.internal.AbstractInvokeExpr.getMethod(AbstractInvokeExpr.java:56) at soot.jimple.validation.InvokeArgumentValidator.validate(InvokeArgumentValidator.java:54) at soot.jimple.JimpleBody.validate(JimpleBody.java:118) at soot.jimple.JimpleBody.validate(JimpleBody.java:98) at soot.jimple.infoflow.cfg.LibraryClassPatcher.patchServiceConnection(LibraryClassPatcher.java:561) at soot.jimple.infoflow.cfg.LibraryClassPatcher.patchLibraries(LibraryClassPatcher.java:55) at soot.jimple.infoflow.android.SetupApplication.initializeSoot(SetupApplication.java:1130) at soot.jimple.infoflow.android.SetupApplication.runInfoflow(SetupApplication.java:1313) at soot.jimple.infoflow.android.SetupApplication.constructCallgraph(SetupApplication.java:1182)

Looked a bit into the code and it seems that the LibraryClassPatcher.patchServiceConnection method is causing the problem: Scene.v().makeMethodRef(sc, "onServiceConnected", Collections.singletonList(smGetFM.getParameterType(0)), VoidType.v(), false),

The inconsistent method signature (onServiceConnected([android.content.ComponentName])) is designed here. Is there any way to avoid this issue?

traceprobe commented 6 years ago

removed b.validate().

StevenArzt commented 6 years ago

This bug seems familiar to me. Are you using the development version, i.e., the "develop" branch? I vaguely remember having fixed that issue there.

traceprobe commented 6 years ago

Hi Steven, thank you very much for your quick reply. I am using the release version FlowDroid 2.5.1, and the problem happens when analyzing "mydlink Home" (https://apkpure.com/mydlink-home/com.dlink.mydlinkmyhome). I doubt whether I misconfigured any option here.

The code I am using is: SetupApplication analyzer = new SetupApplication(FRAMEWORK_DIR, APK_PATH); analyzer.getConfig().setTaintAnalysisEnabled(false); analyzer.getConfig().setMergeDexFiles(true); analyzer.getConfig().setSootOutputFormat(soot.options.Options.output_format_dex); analyzer.getConfig().setSootOutputDir(OUT_DIR); analyzer.getConfig().setWriteOutputFiles(true); analyzer.constructCallgraph();

JovanovicMarija commented 6 years ago

I'm facing the same error while trying to create a call graph of an Android app (apk file). I created a new Maven project for JRE 1.8.0_171, included soot as a Maven dependency as stated in their readme file, included soot-infoflow-android-classes.jar and soot-infoflow-classes.jar downloaded from here and the following three lines of code SetupApplication app = new SetupApplication("/path/to/Library/Android/sdk/platforms/", "/path/to/app-debug.apk"); app.constructCallgraph(); Scene.v().getCallGraph(); My exact output is: [main] INFO soot.jimple.infoflow.android.SetupApplication - Initializing Soot... [main] INFO soot.jimple.infoflow.android.SetupApplication - Loading dex files... Exception in thread "main" soot.SootMethodRefImpl$ClassResolutionFailedException: Class android.content.ServiceConnection doesn't have method onServiceConnected([android.content.ComponentName]) : void; failed to resolve in superclasses and interfacesLooking in android.content.ServiceConnection which has methods [<android.content.ServiceConnection: void onServiceConnected(android.content.ComponentName,android.os.IBinder)>, <android.content.ServiceConnection: void onServiceDisconnected(android.content.ComponentName)>, <android.content.ServiceConnection: void onBindingDied(android.content.ComponentName)>] Looking in java.lang.Object which has methods [<java.lang.Object: void ()>, <java.lang.Object: java.lang.Class getClass()>, <java.lang.Object: int hashCode()>, <java.lang.Object: boolean equals(java.lang.Object)>, <java.lang.Object: java.lang.Object clone()>, <java.lang.Object: java.lang.String toString()>, <java.lang.Object: void notify()>, <java.lang.Object: void notifyAll()>, <java.lang.Object: void wait(long)>, <java.lang.Object: void wait(long,int)>, <java.lang.Object: void wait()>, <java.lang.Object: void finalize()>]

at soot.SootMethodRefImpl.resolve(SootMethodRefImpl.java:237)
at soot.SootMethodRefImpl.resolve(SootMethodRefImpl.java:152)
at soot.jimple.internal.AbstractInvokeExpr.getMethod(AbstractInvokeExpr.java:56)
at soot.jimple.validation.InvokeArgumentValidator.validate(InvokeArgumentValidator.java:54)
at soot.jimple.JimpleBody.validate(JimpleBody.java:118)
at soot.jimple.JimpleBody.validate(JimpleBody.java:98)
at soot.jimple.infoflow.cfg.LibraryClassPatcher.patchServiceConnection(LibraryClassPatcher.java:561)
at soot.jimple.infoflow.cfg.LibraryClassPatcher.patchLibraries(LibraryClassPatcher.java:55)
at soot.jimple.infoflow.android.SetupApplication.initializeSoot(SetupApplication.java:1130)
at soot.jimple.infoflow.android.SetupApplication.runInfoflow(SetupApplication.java:1313)
at soot.jimple.infoflow.android.SetupApplication.constructCallgraph(SetupApplication.java:1182)
at report.Main.main(Main.java:11)
jtoman commented 6 years ago

I just tried the develop branch version, and can confirm the error still occurs. The issue appears to be that the generated onServiceConnected body tries to call the "onServiceConnected(android.content.ComponentName)" method on this, but this method does not exist in ServiceConnection class (nor has it every appeared to).

gilm501 commented 6 years ago

Any update?

gilm501 commented 6 years ago

I have encountered this issue as-well and solved it by updating to Soot 4.0.1.

louison commented 5 years ago

Hello there, It seems that I still have the error using the develop branch of FlowDroid :

soot.SootMethodRefImpl$ClassResolutionFailedException: Class android.view.ViewParent doesn't have method onNestedScrollAccepted([android.view.View, android.view.View, int]) : void; failed to resolve in superclasses and interfacesLooking in android.view.ViewParent which has methods [<android.view.ViewParent: void requestLayout()>, <android.view.ViewParent: boolean isLayoutRequested()>, <android.view.ViewParent: void requestTransparentRegion(android.view.View)>, <android.view.ViewParent: void invalidateChild(android.view.View,android.graphics.Rect)>, <android.view.ViewParent: android.view.ViewParent invalidateChildInParent(int[],android.graphics.Rect)>, <android.view.ViewParent: android.view.ViewParent getParent()>, <android.view.ViewParent: void requestChildFocus(android.view.View,android.view.View)>, <android.view.ViewParent: void recomputeViewAttributes(android.view.View)>, <android.view.ViewParent: void clearChildFocus(android.view.View)>, <android.view.ViewParent: boolean getChildVisibleRect(android.view.View,android.graphics.Rect,android.graphics.Point)>, <android.view.ViewParent: android.view.View focusSearch(android.view.View,int)>, <android.view.ViewParent: void bringChildToFront(android.view.View)>, <android.view.ViewParent: void focusableViewAvailable(android.view.View)>, <android.view.ViewParent: boolean showContextMenuForChild(android.view.View)>, <android.view.ViewParent: void createContextMenu(android.view.ContextMenu)>, <android.view.ViewParent: android.view.ActionMode startActionModeForChild(android.view.View,android.view.ActionMode$Callback)>, <android.view.ViewParent: void childDrawableStateChanged(android.view.View)>, <android.view.ViewParent: void requestDisallowInterceptTouchEvent(boolean)>, <android.view.ViewParent: boolean requestChildRectangleOnScreen(android.view.View,android.graphics.Rect,boolean)>, <android.view.ViewParent: boolean requestSendAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent)>, <android.view.ViewParent: void childHasTransientStateChanged(android.view.View,boolean)>, <android.view.ViewParent: void requestFitSystemWindows()>, <android.view.ViewParent: android.view.ViewParent getParentForAccessibility()>, <android.view.ViewParent: void notifySubtreeAccessibilityStateChanged(android.view.View,android.view.View,int)>, <android.view.ViewParent: boolean canResolveLayoutDirection()>, <android.view.ViewParent: boolean isLayoutDirectionResolved()>, <android.view.ViewParent: int getLayoutDirection()>, <android.view.ViewParent: boolean canResolveTextDirection()>, <android.view.ViewParent: boolean isTextDirectionResolved()>, <android.view.ViewParent: int getTextDirection()>, <android.view.ViewParent: boolean canResolveTextAlignment()>, <android.view.ViewParent: boolean isTextAlignmentResolved()>, <android.view.ViewParent: int getTextAlignment()>]
Looking in java.lang.Object which has methods [<java.lang.Object: void <init>()>, <java.lang.Object: java.lang.Object clone()>, <java.lang.Object: boolean equals(java.lang.Object)>, <java.lang.Object: void finalize()>, <java.lang.Object: java.lang.Class getClass()>, <java.lang.Object: int hashCode()>, <java.lang.Object: void notify()>, <java.lang.Object: void notifyAll()>, <java.lang.Object: java.lang.String toString()>, <java.lang.Object: void wait()>, <java.lang.Object: void wait(long)>, <java.lang.Object: void wait(long,int)>]

I've tried to use soot 4.0 with FlowDroid 2.7, but it seems that FlowDroid 2.7 is still using Soot 3.1 so I'm a little confused here.

What would be the right course of action ?

Thanks in advance

EDIT: Here is the full error log:

soot.SootMethodRefImpl$ClassResolutionFailedException: Class android.view.ViewParent doesn't have method onStopNestedScroll([android.view.View]) : void; failed to resolve in superclasses and interfacesLooking in android.view.ViewParent which has methods [<android.view.ViewParent: void requestLayout()>, <android.view.ViewParent: boolean isLayoutRequested()>, <android.view.ViewParent: void requestTransparentRegion(android.view.View)>, <android.view.ViewParent: void invalidateChild(android.view.View,android.graphics.Rect)>, <android.view.ViewParent: android.view.ViewParent invalidateChildInParent(int[],android.graphics.Rect)>, <android.view.ViewParent: android.view.ViewParent getParent()>, <android.view.ViewParent: void requestChildFocus(android.view.View,android.view.View)>, <android.view.ViewParent: void recomputeViewAttributes(android.view.View)>, <android.view.ViewParent: void clearChildFocus(android.view.View)>, <android.view.ViewParent: boolean getChildVisibleRect(android.view.View,android.graphics.Rect,android.graphics.Point)>, <android.view.ViewParent: android.view.View focusSearch(android.view.View,int)>, <android.view.ViewParent: void bringChildToFront(android.view.View)>, <android.view.ViewParent: void focusableViewAvailable(android.view.View)>, <android.view.ViewParent: boolean showContextMenuForChild(android.view.View)>, <android.view.ViewParent: void createContextMenu(android.view.ContextMenu)>, <android.view.ViewParent: android.view.ActionMode startActionModeForChild(android.view.View,android.view.ActionMode$Callback)>, <android.view.ViewParent: void childDrawableStateChanged(android.view.View)>, <android.view.ViewParent: void requestDisallowInterceptTouchEvent(boolean)>, <android.view.ViewParent: boolean requestChildRectangleOnScreen(android.view.View,android.graphics.Rect,boolean)>, <android.view.ViewParent: boolean requestSendAccessibilityEvent(android.view.View,android.view.accessibility.AccessibilityEvent)>, <android.view.ViewParent: void childHasTransientStateChanged(android.view.View,boolean)>, <android.view.ViewParent: void requestFitSystemWindows()>, <android.view.ViewParent: android.view.ViewParent getParentForAccessibility()>, <android.view.ViewParent: void notifySubtreeAccessibilityStateChanged(android.view.View,android.view.View,int)>, <android.view.ViewParent: boolean canResolveLayoutDirection()>, <android.view.ViewParent: boolean isLayoutDirectionResolved()>, <android.view.ViewParent: int getLayoutDirection()>, <android.view.ViewParent: boolean canResolveTextDirection()>, <android.view.ViewParent: boolean isTextDirectionResolved()>, <android.view.ViewParent: int getTextDirection()>, <android.view.ViewParent: boolean canResolveTextAlignment()>, <android.view.ViewParent: boolean isTextAlignmentResolved()>, <android.view.ViewParent: int getTextAlignment()>]
Looking in java.lang.Object which has methods [<java.lang.Object: void <init>()>, <java.lang.Object: java.lang.Object clone()>, <java.lang.Object: boolean equals(java.lang.Object)>, <java.lang.Object: void finalize()>, <java.lang.Object: java.lang.Class getClass()>, <java.lang.Object: int hashCode()>, <java.lang.Object: void notify()>, <java.lang.Object: void notifyAll()>, <java.lang.Object: java.lang.String toString()>, <java.lang.Object: void wait()>, <java.lang.Object: void wait(long)>, <java.lang.Object: void wait(long,int)>]

    at soot.SootMethodRefImpl.resolve(SootMethodRefImpl.java:256)
    at soot.SootMethodRefImpl.resolve(SootMethodRefImpl.java:170)
    at soot.jimple.internal.AbstractInvokeExpr.getMethod(AbstractInvokeExpr.java:56)
    at soot.jimple.validation.InvokeArgumentValidator.validate(InvokeArgumentValidator.java:54)
    at soot.jimple.JimpleBody.validate(JimpleBody.java:118)
    at soot.jimple.JimpleBody.validate(JimpleBody.java:98)
    at soot.PackManager.runBodyPacks(PackManager.java:1021)
    at soot.PackManager.access$000(PackManager.java:146)
    at soot.PackManager$1.run(PackManager.java:664)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
    at java.lang.Thread.run(Thread.java:748)