VAITP Dataset

← Back to the dataset

CVE-2026-8470

Predictable keys from a non-cryptographic PRNG allow secret decryption.

  • CVSS 7.4
  • 327
  • Cryptographic
  • Remote

IBM Langflow OSS 1.0.0 through 1.10.3, 1.0.0 through 1.10.3, 1.0.0 through 1.10.3, and 1.0.0 through 1.10.3 use Python's non-cryptographic random module for generating Fernet encryption keys from user secrets under 32 characters. The deterministic Mersenne Twister PRNG produces identical keys for identical seeds, allowing attackers to reproduce encryption keys and decrypt stored API keys and authentication tokens.

CWE
327
CVSS base score
7.4
Published
2026-08-05
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
IBM Langflow
Fixed by upgrading
Yes

Solution

Upgrade to Langflow OSS version 1.10.4 or later.

Vulnerable code sample

import base64
import random
from cryptography.fernet import Fernet

def get_encryption_key(secret: str) -> bytes:
    """
    Generates a Fernet encryption key from a user secret. If the secret is
    shorter than 32 bytes, it's used to seed a PRNG to generate the key.
    """
    secret_bytes = secret.encode('utf-8')

    if len(secret_bytes) >= 32:
        key_material = secret_bytes[:32]
    else:
        # VULNERABLE: The 'random' module is not cryptographically secure and uses a deterministic PRNG.
        random.seed(secret_bytes)
        key_material = random.randbytes(32)

    return base64.urlsafe_b64encode(key_material)

def store_api_key(api_key: str, secret: str):
    """
    Encrypts an API key for storage using a key derived from the user secret.
    """
    key = get_encryption_key(secret)
    f = Fernet(key)
    encrypted_api_key = f.encrypt(api_key.encode('utf-8'))
    # e.g., db.execute("INSERT INTO secrets (data) VALUES (?)", (encrypted_api_key,))

Patched code sample

import base64
import hashlib
from cryptography.fernet import Fernet

def get_encryption_key(secret: str) -> bytes:
    """
    Generates a Fernet encryption key from a user secret. If the secret is
    shorter than 32 bytes, it's used to seed a PRNG to generate the key.
    """
    secret_bytes = secret.encode('utf-8')

    # FIX: Use a cryptographic hash function (SHA-256) to derive a key of the correct
    # length from the user secret, regardless of the secret's original length.
    key_material = hashlib.sha256(secret_bytes).digest()

    return base64.urlsafe_b64encode(key_material)

def store_api_key(api_key: str, secret: str):
    """
    Encrypts an API key for storage using a key derived from the user secret.
    """
    key = get_encryption_key(secret)
    f = Fernet(key)
    encrypted_api_key = f.encrypt(api_key.encode('utf-8'))
    # e.g., db.execute("INSERT INTO secrets (data) VALUES (?)", (encrypted_api_key,))

Cite this entry

@misc{vaitp:cve20268470,
  title        = {{Predictable keys from a non-cryptographic PRNG allow secret decryption.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-8470},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-8470/}}
}
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 ::