Aller au contenu principal

Keystore Password

Description​

General​

Java and Android keystores (.jks, .p12, .pfx, .keystore) hold private keys: application signing keys, TLS server keys and mTLS client certificates. The keystore file is protected by a store password, and each key inside it can be protected by a separate key password.

Build pipelines need both the keystore and its password to sign an artifact, so the two are frequently committed side by side. The Keystore Password detector catches the password itself. The keystore file is reported separately by the sensitive filepath insight.

This detector complements Generic Password, which misses several of the forms used in this ecosystem: the abbreviated storepass and keypass keywords, the Groovy syntax used in build.gradle, and the command-line flags of keytool and jarsigner. When both detectors match the same value, Keystore Password takes precedence.

Specifications​

The detector only runs on documents mentioning a keystore context: keystore, storepass, keypass, signingConfig, keytool or jarsigner.

Three forms are recognised:

  • Assignments, covering properties files, YAML, Groovy and Kotlin DSL build scripts, JVM system properties, CI environment variables and Maven pom.xml elements. Example keywords: storePassword, keyPassword, key-store-password, KEYSTORE_PASS, SIGNING_STORE_PASSWORD, javax.net.ssl.keyStorePassword.
  • Groovy method-call syntax, where the value follows the keyword without an assignment operator, as in storePassword 'value'.
  • Command-line options of keytool and jarsigner: -storepass, -keypass, -srcstorepass, -deststorepass, -srckeypass and -destkeypass.

Revoke the secret​

A keystore password cannot be rotated on its own: it protects a private key that is now considered compromised.

  1. Identify the keystore the password unlocks, usually named next to the match (storeFile, key-store, -keystore).
  2. For a TLS or mTLS keystore, generate a new key pair, request a new certificate from the certificate authority, revoke the previous certificate and deploy the replacement.
  3. For an Android application signing key, the key cannot be revoked. If the application is distributed through Google Play, use Play App Signing to request a key upgrade. Otherwise, the application must be republished under a new key.
  4. Store the new password in a secret manager and reference it from the build instead of committing it.

Examples​

Examples that WILL be caught

- text: >
MYAPP_UPLOAD_STORE_PASSWORD=Xh7!qVr2TmLd
password: Xh7!qVr2TmLd

- text: >
storePassword 'Lp3@wGx6VsQn'
password: Lp3@wGx6VsQn

- text: >
keytool -genkeypair -keystore release.jks -storepass Fy8!zHn5TqWb -alias upload
password: Fy8!zHn5TqWb

Examples that WILL NOT be caught

  • The password protects a truststore, which only holds public certificates.
- text: >
server.ssl.trust-store-password=Bw5$kNc8RdZt
  • The value is the documented default password of the JDK truststore.
- text: >
keytool -list -keystore cacerts -storepass changeit
  • The value is a reference to an environment variable, not the password itself.
- text: >
storePassword = System.getenv("KEYSTORE_PASSWORD")