
JHyun398998 (Community Member) asked a question.
Hi all. The following pseudo code gets flagged by Veracode with CWE-321
public void setSecretKey(String secretKey) {
SecretKey key = new SecretKeySpec(secretKey.getBytes(), "AES");
...
}
but this does not
public void setSecretKey(String secretKey) {
byte[] bytes = secretKey.getBytes();
SecretKey key = new SecretKeySpec(bytes, "AES");
...
}
It is not clear to me why one has a vulnerability and the other does not.
.png)
Hi @JHyun398998 (Community Member),
this looks odd to me and I would like more information on that. Could you please reach out to support@veracode.com and provide links to the scans in the Veracode platform where this behavior occurs.
Thank you,
Florian Walter
HI @Florian, Security Consultant (Veracode) , I sent an email to support@veracode.com with the information you requested. An automatic support case was created and I got a reply today saying:
"If you have questions regarding your scan results, you may schedule a consultation call with our Application Security Consultant team via the 'Schedule a Consultation' button found on your platform."
We got around the issue by using the latter code sequence and so don't really need a full blown consultation. I just want an explanation why one gets flagged and the other doesn't. Also, I'm sure others would be interested in the explanation and it would be great if that could be provided as an answer to the forum question.
Hi @JHyun398998 (Community Member), this is merely an automatic reply. You may always schedule a consultation for questions about scan results, but for something quick like this, a question to Support is also okay.
What is gonna happen next is that someone from Support will reach out to you and will make sure all required information has been provided and then pass it to my team, the Application Security Consulting team.
Thank you,
Florian Walter
Nobody has reached out to me. Again, it's not a high priority since for whatever reason my code change made it pass the scan. I just wanted to know why it didn't pass the scan in the first place.