Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Static field accesses is not properly modeled #97

Open
johspaeth opened this issue Nov 23, 2018 · 2 comments
Open

Static field accesses is not properly modeled #97

johspaeth opened this issue Nov 23, 2018 · 2 comments
Assignees

Comments

@johspaeth
Copy link
Member

The data-flow of a static field is not correctly detected.

The test case below succeeds

@Test
public void generateNewAES128GCMKeySet() throws GeneralSecurityException {
	KeyTemplate kt = AeadKeyTemplates.createAesGcmKeyTemplate(16);
	Assertions.hasEnsuredPredicate(kt);
}

whereas when we replace it to the equivalent usage of (AES128_GCM is instantiated via a call to createAesGcmKeyTemplate)

@Test
public void generateNewAES128GCMKeySet_static() throws GeneralSecurityException {
	KeyTemplate kt = AeadKeyTemplates.AES128_GCM;
	Assertions.hasEnsuredPredicate(kt);
}

The predicate does not reach the assertion

@kruegers
Copy link
Member

kruegers commented May 6, 2020

Make sure to check out the examples given in #163 and eclipse-cognicrypt/CogniCrypt#292 when working on this issue.

@rakshitkr rakshitkr self-assigned this Jun 10, 2020
rakshitkr added a commit that referenced this issue Aug 10, 2020
Signed-off-by: Rakshit Krishnappa Ravi <rakshitkrishnapparavi@gmail.com>

- generates seed for assignment statements with static field from CrySL ruleclass
- fixed ensuresPred method to handle seeds with static field assignment
@rakshitkr
Copy link
Contributor

Current solution: Determine the actual method used for initialising the static field. If the method is an initial transition, then the seed is generated for the original statement that has the static field.

Roadblock: The above solution requires the body of the initialiser method (clinit) of the class whose static field is used in the test code. For this, one must avoid the addition of rule classes to excluded packages. With this, the analysis fails for the tests with two or more seeds (e.g. below). The reason is StatementValWeightTable in the boomerang results has values other than the ones from TestMAC.generateNewHMACSHA256_128BitTag method resulting in satisfied field in InAcceptingStateAssertion class not being set to true. However, this doesn't happen when one adds the rule classes to the excluded packages.

@Test
	public void generateNewHMACSHA256_128BitTag() throws GeneralSecurityException {
		KeyTemplate kt = MacKeyTemplates.createHmacKeyTemplate(32, 16, HashType.SHA256);
		KeysetHandle ksh = KeysetHandle.generateNew(kt);
		Assertions.mustBeInAcceptingState(kt);
		Assertions.mustBeInAcceptingState(ksh);
	}

Alternate solution : Retrieve the body of the initialiser method (clinit) of the class whose static field is used in the test code while excluding the rule classes.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants