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

Issue 305 #394

Closed
wants to merge 2 commits into from
Closed

Conversation

enriozuni
Copy link
Contributor

Description

This PR fixes a typo in the code generator template regarding the "Encode Password for Secure Storage" task, where the generated code produces insecure findings when analyzed with CogniCrypt SAST.

Fixes #305

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

This has been tested in inner Eclipse and produces the expected results.

  • Created a Java project, where I generated the code template there. Afterward, I analyzed it and it did not produce errors anymore.

Test Configuration:

  • Eclipse Version: 2019-06
  • Java Version: 1.8
  • OS: Windows 10

Checklist:

  • I have performed a self-review of my own code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

@enriozuni enriozuni changed the title Issue 305 WIP Issue 305 May 3, 2020
@enriozuni enriozuni changed the title WIP Issue 305 Issue 305 May 4, 2020
@enriozuni
Copy link
Contributor Author

@kruegers This PR is ready to be merged.

@kruegers kruegers self-requested a review May 5, 2020 16:21
@@ -36,7 +36,7 @@ public static boolean verifyPWHash(char[] pwd, java.lang.String pwdhash) throws
byte[] res = null;
int keysize = 160;

CrySLCodeGenerator.getInstance().includeClass("java.security.PBEKeySpec").addParameter(pwd, "password").addParameter(salt, "salt").addParameter(keysize, "keylength")
CrySLCodeGenerator.getInstance().includeClass("java.security.SecureRandom").addParameter(salt, "next").includeClass("java.security.PBEKeySpec").addParameter(pwd, "password").addParameter(salt, "salt").addParameter(keysize, "keylength")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is incorrect, though. The verification must not randomize the hash, but take the one that is used for the creation of the hash (as defined in line 35).

@kruegers kruegers closed this May 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants