VAITP Dataset

← Back to the dataset

CVE-2026-74874

Use of non-cryptographic random for pixel selection allows data extraction.

  • CVSS 8.7
  • CWE-338
  • Cryptographic
  • Remote

openssl_encrypt versions before 1.4.0 use Python's non-cryptographic random module for steganographic pixel selection in the generate_pseudorandom_sequence function. Attackers who know the password can recover the Mersenne Twister state from approximately 624 outputs and predict pixel locations containing hidden data for extraction.

CVSS base score
8.7
Published
2026-08-17
OWASP
A02 Cryptographic Failures
Orthogonal defect classification
Algorithm
Code defect classification
Incorrect Algorithm
Category
Cryptographic
Subcategory
Inadequate random number generation
Accessibility scope
Remote
Impact
Information Disclosure
Affected component
Python
Fixed by upgrading
Yes

Solution

Upgrade openssl_encrypt to version 1.4.0 or later.

Vulnerable code sample

import random
from typing import List

def generate_pseudorandom_sequence(password: str, num_pixels: int) -> List[int]:
    """
    Generates a deterministic sequence of pixel indices for steganography.
    """
    # Seed the PRNG with the password to make the sequence deterministic.
    random.seed(password)

    indices = list(range(num_pixels))

    # Use Fisher-Yates shuffle algorithm to generate the sequence.
    for i in range(num_pixels - 1, 0, -1):
        # VULNERABLE: Uses Python's non-cryptographic PRNG which is predictable.
        j = random.randint(0, i)
        indices[i], indices[j] = indices[j], indices[i]

    return indices

Patched code sample

import hashlib
import hmac
from typing import List

def generate_pseudorandom_sequence(password: str, num_pixels: int) -> List[int]:
    """
    Generates a deterministic sequence of pixel indices for steganography.
    """
    # Derive a secure key from the password using a KDF.
    key = hashlib.pbkdf2_hmac(
        'sha256', password.encode('utf-8'), b'steganography-salt', 100000
    )

    indices = list(range(num_pixels))

    # Use Fisher-Yates shuffle algorithm to generate the sequence.
    for i in range(num_pixels - 1, 0, -1):
        # FIX: Use an HMAC-based generator for cryptographically secure random numbers.
        h = hmac.new(key, i.to_bytes(4, 'big'), hashlib.sha256)
        j = int.from_bytes(h.digest(), 'big') % (i + 1)
        indices[i], indices[j] = indices[j], indices[i]

    return indices

Published fix

Public sources link this CVE to the changes below. The code samples above were generated to illustrate the defect; these links lead to the code the project actually changed.

  • security: Replace non-crypto random with HMAC-SHA256 CSPRNG in steganography (GHSA-vfgx-5q85-58q3) (jahlives/openssl_encrypt)
    openssl_encrypt/plugins/steganography/core/base.py · SteganographyBase.__init__, openssl_encrypt/plugins/steganography/core/utils.py, openssl_encrypt/plugins/steganography/core/utils.py · SteganographyUtils.generate_pseudorandom_sequence, openssl_encrypt/plugins/steganography/formats/flac.py · FLACSteganography._extract_from_flac_samples, openssl_encrypt/plugins/steganography/formats/flac.py · FLACSteganography._hide_in_flac_samples, openssl_encrypt/plugins/steganography/formats/image.py · LSBImageStego.extract_data, openssl_encrypt/plugins/steganography/formats/image.py · LSBImageStego.hide_data, openssl_encrypt/plugins/steganography/formats/mp3.py · MP3Steganography._extract_from_mp3_frames, openssl_encrypt/plugins/steganography/formats/mp3.py · MP3Steganography._hide_in_mp3_frames, openssl_encrypt/plugins/steganography/formats/tiff.py · TIFFSteganography._extract_from_tiff, openssl_encrypt/plugins/steganography/formats/tiff.py · TIFFSteganography._hide_in_tiff, openssl_encrypt/plugins/steganography/formats/wav.py · WAVSteganography._extract_from_wav_samples and 3 more

Cite this entry

@misc{vaitp:cve202674874,
  title        = {{Use of non-cryptographic random for pixel selection allows data extraction.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-74874},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-74874/}}
}

Download this entry as JSON Download the whole dataset

Introducing the "VAITP dataset": a specialized repository of Python vulnerabilities and patches, meticulously compiled for the use of the security research community. As Python's prominence grows, understanding and addressing potential security vulnerabilities become crucial. Crafted by and for the cybersecurity community, this dataset offers a valuable resource for researchers, analysts, and developers to analyze and mitigate the security risks associated with Python. Through the comprehensive exploration of vulnerabilities and corresponding patches, the VAITP dataset fosters a safer and more resilient Python ecosystem, encouraging collaborative advancements in programming security.

The supreme art of war is to subdue the enemy without fighting.

Sun Tzu – “The Art of War”

:: Shaping the future through research and ingenuity ::

Before you use the VAITP AI models

Please read and accept the following disclaimer:

By choosing "I understand and accept", you acknowledge that you understand and agree to these terms.