Summary
Jervis, a library for Job DSL plugin scripts and shared Jenkins pipeline libraries, derived its encryption salt directly from sha256Sum(passphrase) prior to version 2.2.
Because the same passphrase always produced the same derived key, repeated encryptions with the same password became predictable and weakened the confidentiality of encrypted data.
Affected context
This weakness affects environments where Jervis is used to encrypt data within Job DSL scripts or shared Jenkins pipeline libraries and the encryption mechanism relies on a passphrase-derived key.
In affected versions (prior to 2.2), the salt for key derivation was deterministically computed as sha256Sum(passphrase), meaning:
- All uses of the same passphrase share the same derived key
- No per-encryption randomness or uniqueness is introduced via the salt
The vulnerability manifests in setups where secrets or sensitive configuration values are encrypted with Jervis and where an attacker may observe multiple ciphertexts or gain partial knowledge of passphrases or ciphertext-plaintext relationships.
Exploit preconditions
- Attack surface: Cryptographic operations performed by Jervis when encrypting or decrypting data, particularly secrets stored or managed in Jenkins-related workflows.
- Required access:
- Ability to access ciphertexts produced by Jervis (e.g., repository files, configuration, or logs), and
- Optionally, knowledge or guesses about the passphrase or about probable plaintexts.
- Trigger point: Any encryption operation that uses Jervis's passphrase-based mechanism in versions prior to 2.2, where the same passphrase is reused across multiple encryptions.
- Why exploitation is possible:
- The salt is derived deterministically as
sha256Sum(passphrase), so it does not introduce additional randomness. - Key derivation becomes a one-to-one function of the passphrase, causing:
- Identical keys for all uses of the same passphrase
- Easier offline guessing/brute-force attacks due to a predictable derivation process
- Potential cross-correlation of ciphertexts encrypted with the same passphrase.
Why this happens
The core issue is the misuse of cryptographic primitives: instead of using a random or unique salt for each encryption operation, Jervis derived the salt deterministically from sha256Sum(passphrase).
This pattern falls under CWE-326: Inadequate Encryption Strength, because:
- The effective entropy of the key material is limited to the passphrase itself, without any additional per-operation randomness.
- The salt does not diversify keys across different encryption events or users using the same passphrase.
In secure designs, salts are non-secret, randomly generated values that prevent identical passphrases from yielding identical keys and allow the same passphrase to produce different keys for each encryption operation.
By tying the salt solely to the passphrase, the implementation undermines these protections and simplifies attack strategies that rely on recognizing repeated key usage and performing offline passphrase cracking.
Potential impact
- Attacks on encrypted data may be easier because the same passphrase always yields the same key.
- An attacker who obtains multiple ciphertexts encrypted with the same passphrase can correlate and analyze them more effectively.
- Offline brute-force or dictionary attacks against passphrases can become more feasible, since the key derivation process is deterministic and lacks per-operation uniqueness.
- Compromise of one passphrase can expose multiple encrypted secrets that reused the same passphrase.
General mitigation guidance
Effective mitigation centers on strengthening the key derivation process and reducing reliance on static passphrase-derived keys:
- Use a standard, well-vetted key derivation function (e.g., PBKDF2, scrypt, Argon2) that:
- Incorporates a cryptographically secure random salt
- Supports configurable work factors (iterations, memory cost) for resistance to brute-force attacks
- Generate a new random salt for each encryption operation or per-secret basis, and store salts alongside the ciphertext as non-secret metadata.
- Avoid using the raw hash of a passphrase as either the key or the salt; instead, always derive keys via proper KDFs.
- Encourage rotation of existing passphrase-based keys and re-encryption of sensitive data when cryptographic schemes are strengthened.
- Design pipeline and Job DSL usage patterns that minimize passphrase reuse and centralize secret management, ideally delegating encryption to hardened secret stores or key management systems.
How teams detect issues like this
Detection focuses on identifying unsafe cryptographic patterns and verifying correct salt usage:
- Static analysis and code scanning:
- Flag custom key derivation logic that uses simple hashing (e.g.,
sha256(passphrase)) as salt or key. - Detect absence of random salt generation for encryption routines.
- Look for repeated patterns of deterministic salt derivation tied only to passphrases or static values.
- Code review signals:
- Custom cryptographic implementations instead of standard KDF libraries.
- Reuse of the same passphrase in multiple encryption contexts without explicit per-use randomness.
- Policy enforcement:
- Enforce development guidelines that require use of approved cryptographic APIs and prohibit ad-hoc key/ salt derivation.
- Integrate security linters or SAST tools into CI for Jenkins-related repositories to highlight weak encryption configurations.
- Runtime/configuration review:
- Inspect existing encrypted assets for evidence of repeated ciphertext patterns when the same passphrase is used.
- Verify that newer configurations embed per-encryption salt values and rely on supported cryptographic primitives.

