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

Please review this md5 implementation, this fall under Cryptography.InsecureAlgorithm #52

Closed
asimmanzoor opened this issue Aug 10, 2020 · 6 comments
Milestone

Comments

@asimmanzoor
Copy link

return MessageDigest.getInstance("MD5").digest(data);

@osiegmar
Copy link
Owner

This is not used for any sort of cryptography. This method aims to generate a (more or less) unique Message ID for datagram chunking when using the UDP transport. Unfortunately the GELF protocol limits the Message ID field to 8 byte – this is why using UUID (16-byte) isn't possible.

Having said that, I'm open for specific suggestions to improve this.

@asimmanzoor
Copy link
Author

Thanks for quick response, I agree that due to limitation of Message ID at GELF format we can't use UUID, However my concern with putting MD5 as Algo, which raise a concern with various security tools.
E.g.
https://help.hcltechsw.com/appscan/Source/9.0.3/topics/intro_products.html

As an alternative, we can use SHA-256 , Apparently will have same 8 byte that is supported by GELF. It's supported by MessageDigest as MessageDigest.getInstance("SHA-256").digest(data) and it will not be concern by security tools for now.

Looking forward to hear your response.

@osiegmar
Copy link
Owner

My concern with SHA-256 is, that I'm already cutting half of the MD5-hash to fit into the Message ID field. With SHA-256 I'd have to cut 8 out of 32 byte and fear that collisions might occur more likely. Furthermore, at some point in the future SHA-256 probably will have the same fate as MD5.

Probably its better to implement something that creates a message id based a timestamp (System.currentTimeMillis() returns 4 byte) and an also 4-byte host specific or random value.

@asimmanzoor
Copy link
Author

I think, you are right, We don't know how long SHA-256 last. Keeping actual use of messgeId in mind, I am agree with you.

@osiegmar
Copy link
Owner

One correction to my post earlier: The timestamp (regardless of System.currentTimeMillis() or System.nanoTime()) already consumes 8 byte (long).

I re-implemented the MessageIdSupplier to create Message-IDs based on a random host value (integer) and concatenating that with a timestamp that is cased to an integer. That should do the job pretty fine.

Although this breaks the API and a new major release is needed for that.

Feedback is very welcome!

@asimmanzoor
Copy link
Author

Look good to me.
I would like to appreciate you for quick addressing the issue.

@osiegmar osiegmar added this to the 3.0.0 milestone Jan 18, 2021
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