VAITP Dataset

← Back to the dataset

CVE-2026-74874

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

  • CVSS 8.7
  • 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.

CWE
338
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
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

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/}}
}
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 ::