CryptoAnalysis icon indicating copy to clipboard operation
CryptoAnalysis copied to clipboard

Soot 4.3.0 Causes test failure.

Open AnakinRaW opened this issue 4 years ago • 1 comments

For some reason when using soot version 4.3.0-SNAPSHOT, Boomerang throws the an ImperciseException on test SecretKeyTest (clearPasswordPredicateTest, secretKeyUsagePattern7 and clearPasswordPredicateTest2).

The error is:

java.lang.AssertionError: Imprecise results: Did not expect a predicate for keyMaterial (SecretKeyTest.clearPasswordPredicateTest2) @ staticinvoke <test.assertions.Assertions: void notHasEnsuredPredicate(java.lang.Object)>(keyMaterial)

	at org.junit.Assert.fail(Assert.java:89)
	at test.core.selfrunning.AbstractTestingFramework.beforeTestCaseExecution(AbstractTestingFramework.java:45)
        ....

AnakinRaW avatar Sep 15 '20 14:09 AnakinRaW

@svenfeld and me investigated issues on integrating the new Soot version 4.3.0. We found out the following:

Some initial AnalysisSeedWithSpecification are not generated

E.g. having a minimal example for an insecure Cipher, such as Cipher cipher = Cipher.getInstance("AES"), CryptoScanner does not generate an initial seed if and only if the variable cipher is never used in further statements. We inspected the jimple code and found that Soot optimizes the variable cipher away in jimple in the case that no further statements may cause side effects on cipher. In jimple code, the minimal example is thus not represented as an assignment statement anymore. By design, CryptoAnalysis requires an assignment statement to generate a seed, as a seed is initialized with the left side assigned variable which represents the object that should be further analyzed by the seed.

CryptoAnalysis cannot extract parameter values in some cases

An example for this is the PBEKeySpec class. When initializing it with PBEKeySpec(password, salt, iterationcount, keylength), the jimple code generated by the new Soot version is <init>($stack11, salt, $i0, varReplacer0), whereas the old Soot version generates <init>($stack11, salt, varReplacer0, varReplacer1). CryptoAnalysis cannot extract the iterationcount value, because a BackwardBommerangQuery does not find the value for $i0, whereas it do find a value for all varReplacer. For more detail, the jimple code for iterationcount generated by the old Soot version is: varReplacer0 = 20000 whereas the new soot version generates: $i0 = (int) 20000 which seems to represent a pointer instead of a value.

marvinvo avatar Jun 14 '22 09:06 marvinvo