Skip to content

Treat array declarations as sources #51

@zjbthomas

Description

@zjbthomas

Hi all,

I am trying to configure FlowDroid to use variable declarations of String arrays as flow sources (e.g., newarray (java.lang.String)[3];). It appears that FlowDroid only supports specifying methods as sources and sinks. I've tried to convert variable declaration into dummy methods, but that did not work either, with errors related to IFDS solver (heros). The details are below.

  1. I created a dummy method called dummyNewArray() which returns the original String array, under class java.lang.Object. I choose this class since String array is a subclass of class Object. Please see method MyModification::createDummyNewArrayMethod() for details. Resultant Jimple looks like the following:
public java.lang.String[] dummyNewArray()
{
    java.lang.Object this;
    this := @this: java.lang.Object;
    return this;
}

MyModification.java.txt

  1. In soot.jimple.infoflow.android.SetupApplication::initializeSoot(boolean), after executing Scene.v().loadNecessaryClasses, I replace all NewArrayExprs with the call to the dummy method. One example of the final result is:
$r1 = newarray (java.lang.String)[3];
$r1 = virtualinvoke $r1.<java.lang.Object: java.lang.String[] dummyNewArray()>();
$r1[0] = "aid";
$r1[1] = "androidid";
$r1[2] = "limit_tracking";

SetupApplication.java.txt

  1. I added <java.lang.Object: java.lang.String[] dummyNewArray()> -> _SOURCE_ in SourceAndSinks.txt.

However, it doesn't work with errors related to IFDS solver (heros). I think key problems are NullPointerException (Listing 1) and the summary of the method cannot be generated (Listing 2). A full log is enclosed in the attachment.

  • Listing 1:
[Thread-6] ERROR heros.solver.CountingThreadPoolExecutor - Worker thread execution failed: null
java.lang.NullPointerException
	at com.google.common.base.Preconditions.checkNotNull(Preconditions.java:210)
	at com.google.common.cache.LocalCache.get(LocalCache.java:3936)
	at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:3941)
	at com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:4824)
	at com.google.common.cache.LocalCache$LocalLoadingCache.getUnchecked(LocalCache.java:4830)
	at soot.jimple.toolkits.ide.icfg.AbstractJimpleBasedICFG.getOrCreateUnitGraph(AbstractJimpleBasedICFG.java:104)
	at soot.jimple.toolkits.ide.icfg.AbstractJimpleBasedICFG.getPredsOf(AbstractJimpleBasedICFG.java:206)
	at soot.jimple.toolkits.ide.icfg.AbstractJimpleBasedICFG.getPredsOf(AbstractJimpleBasedICFG.java:1)
	at soot.jimple.infoflow.solver.cfg.InfoflowCFG.getPredsOfCallAt(InfoflowCFG.java:222)
	at soot.jimple.infoflow.solver.cfg.InfoflowCFG.getPredsOfCallAt(InfoflowCFG.java:1)
	at soot.jimple.toolkits.ide.icfg.BackwardsInterproceduralCFG.getReturnSitesOfCallAt(BackwardsInterproceduralCFG.java:56)
	at soot.jimple.toolkits.ide.icfg.BackwardsInterproceduralCFG.getReturnSitesOfCallAt(BackwardsInterproceduralCFG.java:1)
	at soot.jimple.infoflow.solver.cfg.InfoflowCFG.getReturnSitesOfCallAt(InfoflowCFG.java:202)
	at soot.jimple.infoflow.solver.cfg.InfoflowCFG.getReturnSitesOfCallAt(InfoflowCFG.java:1)
	at soot.jimple.infoflow.solver.fastSolver.IFDSSolver.processExit(IFDSSolver.java:510)
	at soot.jimple.infoflow.solver.fastSolver.InfoflowSolver.processExit(InfoflowSolver.java:125)
	at soot.jimple.infoflow.solver.fastSolver.IFDSSolver$PathEdgeProcessingTask.run(IFDSSolver.java:739)
	at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
	at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
	at java.lang.Thread.run(Unknown Source)
  • Listing 2:
[Thread-2] ERROR soot.jimple.infoflow.methodSummary.data.provider.LazySummaryProvider - An error occurred while loading the summary of java.util.Arrays
[Thread-5] ERROR soot.jimple.infoflow.methodSummary.data.provider.LazySummaryProvider - An error occurred while loading the summary of java.lang.String

error.txt

I confirmed that these errors only occur when <java.lang.Object: java.lang.String[] dummyNewArray()> -> _SOURCE_ is added. Without this line, everything else works well.

Could you please look into my issue and provide me some suggestions to handle this case? Thank you in advance.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions