Skip to content

Incorrect Hex Conversion

Description

The application is using `Integer.toHexString` on a digest array buffer which may lead to an incorrect version of values. Consider using the `java.util.HexFormat` object introduced in Java 17. For older Java applications, consider using the `javax.xml.bind.DatatypeConverter`.

Examples

Insecure Code

java
Integer.toHexString(byteArray[0])

Secure Code

java
HexFormat.of().formatHex(byteArray)

Remediation

Use `java.util.HexFormat` or `javax.xml.bind.DatatypeConverter` for hex conversion.

Rule Details

FieldValue
IDCODE-0724
CategoryGeneric
SeverityMEDIUM
CWECWE-704
ConfidenceHIGH
ImpactMEDIUM
LikelihoodMEDIUM
ExploitabilityMODERATE
Tagshex conversion, Integer.toHexString
OWASPA6:2017-Security Misconfiguration, A05:2021-Security Misconfiguration