Summary
Jervis, a library used for Job DSL plugin scripts and shared Jenkins pipeline libraries, relied on java.util.Random() for randomness in contexts intended to mitigate timing attacks.
Because java.util.Random() is not cryptographically secure, an attacker who can observe or influence timing-related behavior may be able to predict supposedly random values, weakening protections against timing-based attacks.
Affected context
This vulnerability affects environments where Jervis is used within Jenkins for Job DSL scripts or shared pipeline libraries and where randomness is part of logic intended to mitigate timing attacks, obfuscate execution timing, or otherwise make sensitive operations less predictable.
The risk is present when java.util.Random() is used under the assumption that it provides cryptographically strong randomness to defend against attackers capable of making repeated observations of pipeline or job behavior over time.
Exploit preconditions
- Attack surface: Jenkins jobs or pipelines that incorporate Jervis functionality and expose observable timing or behavioral patterns (e.g., response times, delays, or retry intervals).
- Required access: Ability to repeatedly trigger, observe, or profile Jenkins job behavior (such as a user with job execution rights, or an external observer when jobs drive outward-facing systems).
- Trigger point: Code paths in Jervis-based scripts or libraries that rely on randomness for timing jitter, delay selection, or other anti-analysis measures.
- Why exploitation is possible:
java.util.Random()is a deterministic pseudo-random number generator with a relatively small internal state and predictable output sequence, allowing an attacker to approximate or model the random values and reduce the uncertainty that timing defenses are supposed to introduce.
Why this happens
The root cause is the use of a general-purpose pseudo-random number generator (java.util.Random) in scenarios where stronger, cryptographic-quality randomness is required to mitigate timing attacks.
This maps to CWE-330: Use of Insufficiently Random Values, where values intended to be unpredictable are generated by an algorithm that can be predicted by an adversary observing enough outputs.
In the abstract, the insecure pattern is: treating a non-cryptographic RNG as if it provided security properties (unpredictability, resistance to state recovery) and using it to randomize timing or other security-relevant decisions.
Potential impact
- Attackers could more accurately predict the timing or ordering of operations that are meant to be randomized.
- Timing attack mitigations may be weakened, making it easier to correlate observable behavior with sensitive internal state.
- Security assumptions relying on unpredictability (e.g., jitter added to delays, randomized backoff intervals, or timing noise) can be undermined.
- Under certain threat models, this may contribute to broader attacks such as more precise profiling of pipeline behavior or better alignment of probing attempts.
General mitigation guidance
Effective mitigation focuses on using cryptographically secure randomness and treating timing obfuscation as a defense-in-depth measure rather than a primary control.
Recommended design patterns include:
- Replace uses of
java.util.Random()in security-relevant contexts with cryptographically secure RNGs (such as APIs explicitly designed for security-sensitive randomness). - Clearly distinguish between randomness used for functional behavior (e.g., load balancing) and randomness used for security; enforce stricter standards for the latter.
- Minimize reliance on timing jitter alone as a security control; combine it with robust authorization, input validation, and rate-limiting.
- Centralize random number generation in a small set of well-reviewed helper utilities or services so that security requirements are consistently applied.
- Document threat models around timing attacks so that developers understand when secure randomness is mandatory.
How teams detect issues like this
Organizations can look for insufficiently secure randomness through:
- Static analysis rules that flag uses of
java.util.Random()(and similar non-cryptographic RNGs) in packages or modules marked as security-sensitive. - Code review checklists that explicitly ask reviewers to confirm that any randomness used for timing obfuscation, secrets, or security decisions comes from a cryptographically secure source.
- Repository-wide searches for insecure RNG APIs in CI pipelines, enforcing policies that require security review before such calls are approved in sensitive paths.
- Use of automated code scanning tools configured with custom rules to detect and report misuse of RNG APIs in Jenkins-related code and shared libraries.

