keystore-go flaw lets attackers alter JKS truststores without detection

  • keystore-go
  • JKS
  • SHA-1
  • integrity
  • vulnerability

Flaw in keystore.Decode function fails to validate SHA-1 digest

The bug can bypass password checks in certificate-only truststores

Users should migrate to version 3.0.0 or higher

The keystore-go library’s keystore.Decode() function fails to validate the trailing SHA-1 integrity digest in Java Keystore (JKS) files, allowing an attacker with write access to bypass integrity checks and, in certificate-only truststores, password verification. The flaw was addressed in a commit dated September 16, 2019.

The bug occurs when the final 20 bytes containing the digest are removed from a JKS file. The digest read then returns no data, the comparison is skipped and Decode() can return the parsed keystore without an error. An attacker who can modify the file but does not know its password can therefore inject or replace trusted certificate authority (CA) certificates without detection.

Applications that use Decode() to load JKS truststores and rely on the password to detect tampering are affected. Forged trusted certificates can enable interception of TLS connections that trust them, compromising those connections’ confidentiality and integrity.

The fix was included in v3.0.0 of the successor module path github.com/pavel-v-chernykh/keystore-go/v3 and is also available in v4 modules from v4.0.0. The legacy github.com/pavel-v-chernykh/keystore-go path remains vulnerable through version 2.1.0; users of that path should migrate to a fixed module version.