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

Weak Algorithm Name as String Parameter not detected after Transformation #269

Open
LordAmit opened this issue Jun 21, 2020 · 2 comments
Open

Comments

@LordAmit
Copy link

LordAmit commented Jun 21, 2020

Hi,

My team is conducting academic research on Java Cryptography API based misuse using your tool. We found that we could not detect some potential cryptographic misuses.

We believe this may be due to underlying implementation or design gaps. Each cryptographic vulnerability was generated as a barebone Java project that only contained a single vulnerability in the main function and used up to two java source files. A jar was made which was then scanned.

Additionally, all cryptographic API calls were from Java Cryptographic Architecture (JCA).

Problem

Replacing a Secure Parameter with an Insecure Parameter:

MessageDigest.getInstance("SHA-256".replace("SHA-256", "MD5"));

Replacing an Insecure Parameter with an Insecure Parameter:

Cipher.getInstance("AES".replace("A", "D"));

where "AES" by itself is insecure as it defaults to using ECB.

Transforming string case, e.g., from lower to upper case:

Cipher.getInstance("des".toUpperCase(Locale.English));

Replacing a noisy version of insecure parameters:

Cipher.getInstance("DE$S".replace("$", ""));

Environment

Component Version
Java Runtime OpenJDK version 1.8.0_232 64 bit
CogniCrypt version used CryptoAnalysis-2.0-jar-with-dependencies.jar

I understand that the current release snapshot is version 2.7. However, when we started using it - the recommended release was 2.0 in readme.md file. I hope this report will be useful for making your tool (including the current combined version) even better.

Please let me know if you need any additional information (e.g., logs from our side) for fixing these issues.

Thanks again!

@johspaeth
Copy link
Member

Thanks for reporting.

Those transformation are indeed not yet handled by CryptoAnalysis. We have not found such transformation to appear in practice (we did not analyze malware!), and we did not further spend time on it.

Do you have concrete use cases that require such transformation?

I am happy to provide you pointers in the implementation to where one has to model the transformation.

@LordAmit
Copy link
Author

Hi!

Thanks for getting back. These transformations can happen in several, non-malicious scenarios. For example, a string can be converted to a different case by a novice developer who is trying to follow naming conventions. Or a developer can replace characters that he added for his own convenience before passing it on as parameter.

Here is an example from a github repository that shows such behavior:

String algsPadd = (algs.name() + "/" + mode.name() + "/" + padd.name()).replace('_', '-');
Cipher cipher = Cipher.getInstance(algsPadd);

Of course, it does not match exactly with the examples I provided, but it is similar.

We also noticed that other similar tools for crypto API misuse detection, such as Xanitizer, catch such transformations.

If ignoring such transformations is a design choice, I request that such design choices be mentioned in documentation (readme/wiki).

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

No branches or pull requests

2 participants