Skip to content

Commit 2296673

Browse files
committed
StubDroid: do not apply identity on unhandled methods
1 parent 5756eda commit 2296673

File tree

3 files changed

+21
-4
lines changed

3 files changed

+21
-4
lines changed

soot-infoflow-summaries/src/soot/jimple/infoflow/methodSummary/taintWrappers/SummaryTaintWrapper.java

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -527,9 +527,7 @@ public Set<Abstraction> getTaintsForMethod(Stmt stmt, Abstraction d1, Abstractio
527527
return Collections.singleton(taintedAbs);
528528
else {
529529
reportMissingSummary(callee, stmt, taintedAbs);
530-
if (fallbackWrapper != null) {
531-
return fallbackWrapper.getTaintsForMethod(stmt, d1, taintedAbs);
532-
}
530+
return fallbackWrapper != null ? fallbackWrapper.getTaintsForMethod(stmt, d1, taintedAbs) : null;
533531
}
534532
}
535533
}
@@ -1763,9 +1761,12 @@ public Set<Abstraction> getInverseTaintsForMethod(Stmt stmt, Abstraction d1, Abs
17631761
ClassSummaries flowsInCallees = getFlowSummariesForMethod(stmt, method, taintedAbs, null);
17641762

17651763
// If we have no data flows, we can abort early
1766-
if (flowsInCallees.isEmpty())
1764+
if (flowsInCallees.isEmpty()) {
17671765
if (fallbackWrapper != null && fallbackWrapper instanceof IReversibleTaintWrapper)
17681766
return ((IReversibleTaintWrapper) fallbackWrapper).getInverseTaintsForMethod(stmt, d1, taintedAbs);
1767+
else
1768+
return null;
1769+
}
17691770

17701771
// Create a level-0 propagator for the initially tainted access path
17711772
ByReferenceBoolean killIncomingTaint = new ByReferenceBoolean();

soot-infoflow-summaries/test/soot/jimple/infoflow/test/methodSummary/ApiClassClient.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -309,4 +309,15 @@ public void iterator() {
309309
if (it.hasNext())
310310
sink(it.next());
311311
}
312+
313+
private static void overwrite(Data d) {
314+
d.stringField = "";
315+
}
316+
317+
public void noPropagationOverUnhandledCallee() {
318+
Data d = new Data();
319+
d.stringField = stringSource();
320+
overwrite(d);
321+
sink(d.stringField);
322+
}
312323
}

soot-infoflow-summaries/test/soot/jimple/infoflow/test/methodSummary/junit/SummaryTaintWrapperTests.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,11 @@ public void iterator() {
232232
testFlowForMethod("<soot.jimple.infoflow.test.methodSummary.ApiClassClient: void iterator()>");
233233
}
234234

235+
@Test(timeout = 30000)
236+
public void noPropagationOverUnhandledCallee() {
237+
testNoFlowForMethod("<soot.jimple.infoflow.test.methodSummary.ApiClassClient: void noPropagationOverUnhandledCallee()>");
238+
}
239+
235240
@Test
236241
public void testAllSummaries() throws URISyntaxException, IOException {
237242
EagerSummaryProvider provider = new EagerSummaryProvider(TaintWrapperFactory.DEFAULT_SUMMARY_DIR);

0 commit comments

Comments
 (0)