Skip to content

Java: Noisiness of java/weak-cryptographic-algorithm / MD5 detection #17836

Closed

Description

@theveriton

Description of the false positive

This flags every single use of MD5 as a cryptography problem.
MD5 exists for a reason an it's entirely inappropriate to flag any and every usage of it as a cryptographic usage
It is intended to be a lighter weight, simpler algorithm. Using it at all should not be a flag. there are plenty of legitimate use cases that have nothing to do with security

Code samples or links to source code

for example:

Here, we are just using checksum to see if the doc has been modified, not using it for encryption

//computeChecksum will use MD5
String docCheckSum = computeChecksum(text);
if (docCheckSum != previousCheckSum){
docchanged=1;
}

public static String computeChecksum(String s)
{
	if (md == null)
	{
		try
		{
			//This line gets flagged
                       md = MessageDigest.getInstance("MD5");
		}
		catch (NoSuchAlgorithmException e)
		{
			if(log.isDebugEnabled()) e.printStackTrace();
			throw new IllegalStateException(e + " String for MD5: " + s);
		}
	}
	byte[] bytes = s.getBytes();
	return hashData(bytes);
}

Activity

  1. hvitved commented on Oct 24, 2024

    @hvitved
    Contributor

    Thank you for this false positive report. Resolving this issue is not a current product priority, but we acknowledge the report and will track it internally for future consideration, or if we observe repeated instances of the same problem.

  2. theveriton commented on Oct 24, 2024

    @theveriton
    Author

    Thank you, because this is a "High" vulnerability, we have strict guidelines and can't suppress this.
    Also, this is only being detected in java, the same logic in ruby and C# does not get flagged

  3. hvitved commented on Oct 24, 2024

    @hvitved
    Contributor

    CC @github/codeql-java

  4. linked a pull request that will close this issueJava: Improve weak crypto query #17869on Nov 24, 2024
  5. jcogs33 commented on Nov 24, 2024

    @jcogs33
    Contributor

    Thanks for the report @theveriton. We have removed MD5 alerts from java/weak-cryptographic-algorithm in #17869.

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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions