/

CVE-2025-68702

Severity:

HIGH RISK

(7.5)

Cryptographic Weakness in Jervis SHA-256 Hex Padding

CVE-2025-68702

Analyzed

Vulnerability type

Category:

Cryptographic Weakness

CWE:

CWE-327

Impact:

Weakened cryptographic integrity and possible validation bypass

Severity:

HIGH RISK

(7.5)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

Jervis, a library for Job DSL plugin scripts and shared Jenkins pipeline libraries, contained a cryptographic implementation error where SHA-256 digests were padded to only 32 characters instead of the required 64 hex characters.

Under conditions where this incorrectly padded hash is used as an integrity check, token, or signature component, an attacker could exploit the truncated value to weaken security guarantees, potentially bypassing validation or reducing the effective search space of the hash.

Affected context

The issue affects environments that:

  • Use Jervis prior to version 2.2
  • Rely on Jervis to compute or compare SHA-256-based values (e.g., identifiers, checksums, or signatures)
  • Treat the resulting hex-encoded hash as a security-relevant artifact (for integrity, authenticity, or uniqueness)

In these contexts, only 32 hex characters are produced for SHA-256 digests instead of the full 64, reducing the effective representation of the hash and potentially undermining assumptions about its strength.

Exploit preconditions

  • Attack surface: Any workflow, pipeline, or script that consumes Jervis-generated SHA-256 hex strings for security decisions (such as validation, gating, or trust checks).
  • Required access: Ability to influence or observe inputs whose hashes are computed by Jervis, or to supply alternative values to collide under the truncated representation.
  • Trigger point: Operations that compute, store, or compare SHA-256 digests using Jervis's padding logic, particularly when the truncated value is used as a security control.
  • Why exploitation is possible: The implementation pads SHA-256 digests to 32 hex characters instead of 64, effectively truncating the digest representation and weakening the space an attacker must search to find values that produce the same truncated output.

Why this happens

The root cause is an incorrect assumption about the size of a SHA-256 hash when rendered in hexadecimal form. SHA-256 yields 32 bytes, which must be represented as 64 hex characters; using padLeft(32, '0') instead of padLeft(64, '0') results in an under-sized hex string.

This maps to CWE-327: Use of a Broken or Risky Cryptographic Algorithm, in the sense that the cryptographic construction is misapplied. While SHA-256 itself is sound, the faulty encoding truncates its effective representation, degrading its intended security properties. Abstractly, this is a cryptographic implementation error where formatting/encoding logic fails to preserve the full entropy of the underlying digest.

Potential impact

  • Reduction of the effective hash space, which can lower the work factor required to find inputs that collide under the truncated hash representation
  • Possible bypass of integrity checks if systems trust the truncated value as a full-strength SHA-256 digest
  • Increased risk of accidental or malicious collisions where distinct inputs share the same truncated hash
  • Undermined auditability or traceability if hashes are used as unique identifiers, leading to ambiguity in logs or artifact metadata

General mitigation guidance

Mitigation typically focuses on ensuring that cryptographic values are correctly represented and validated end-to-end:

  • Verify that all SHA-256 digests are represented with the full 64-character hexadecimal encoding, preserving the complete 32-byte output.
  • Treat formatting and encoding logic for cryptographic outputs as security-sensitive and subject to the same rigor as the core cryptographic routines.
  • Implement automated tests that assert expected length and format of cryptographic values (for example, asserting that a SHA-256 hex string is exactly 64 characters).
  • Where hashes are used as identifiers or verification tokens, consider adding explicit schema or contract checks that reject malformed or truncated values.
  • Apply a defense-in-depth approach by not relying solely on a single hash comparison for critical authorization or integrity controls.

How teams detect issues like this

Organizations can detect and prevent similar issues through:

  • Static analysis and linting: Rules that flag fixed-size hash encodings with incorrect lengths (e.g., SHA-256 represented with anything other than 64 hex characters).
  • Code review practices: Explicit review of cryptographic usage, including key sizes, hash lengths, and encoding details, treating these as high-risk areas requiring reviewer acknowledgment.
  • Unit and integration tests: Test fixtures that compare known SHA-256 test vectors against implementation outputs, verifying both content and length.
  • Policy enforcement in CI: Security gates that run automated cryptographic correctness tests or SAST tools on pull requests, particularly for libraries used in build and deployment pipelines like Jervis.

Sources

SourceLink
github.comgithub.com/samrocketman/jervis/commit/c3981ff71de7b0f767dfe7b37a2372cb2a51974a
github.comgithub.com/samrocketman/jervis/security/advisories/GHSA-67rj-pjg6-pq59

Frequently asked

questions

Exploitability depends on how the truncated hash is used. If systems treat the 32-character value as a full-strength SHA-256 digest for integrity, uniqueness, or access control, the weakened representation can make it easier to find collisions or bypass checks. If the value is only used as a non-security identifier, the impact may be limited.

Not necessarily. An attacker mainly needs the ability to influence or observe data whose truncated hash is used in a security-sensitive context. This might occur through normal inputs to CI/CD pipelines, artifact naming, or configuration data that Jervis processes.

Ensure that the full output of cryptographic primitives is preserved and correctly encoded. For SHA-256, always handle 32 bytes of output and represent it as 64 hex characters (or an equivalent full-length encoding such as base64), and enforce this via tests and validation checks.

Rely on well-vetted cryptographic libraries and utility functions for encoding rather than custom padding logic, add tests against published test vectors, and make cryptography usage a specific focus of security review and automated analysis. Establish internal guidelines that document expected sizes and formats for all cryptographic elements used in your pipelines.

Find out what's already
exploitable in your codebase.