VAITP Dataset

← Back to the dataset

CVE-2026-40319

A crafted regex in Giskard may cause a Denial of Service via backtracking.

  • CVSS 1.0
  • CWE-1333
  • Resource Management
  • Local

Giskard is an open-source testing framework for AI models. In versions prior to 1.0.2b1, the RegexMatching check passes a user-supplied regular expression pattern directly to Python's re.search() without any timeout or complexity guard. A crafted regex pattern can trigger catastrophic backtracking, causing the process to hang indefinitely. Exploitation requires write access to a check definition and subsequent execution of the test suite. This issue has been fixed in giskard-checks version 1.0.2b1.

CVSS base score
1.0
Published
2026-04-17
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Missing Check
Category
Resource Management
Subcategory
Resource Exhaustion
Accessibility scope
Local
Impact
Denial of Service (DoS)
Affected component
giskard-chec
Fixed by upgrading
Yes

Solution

Upgrade the `giskard-checks` package to version 1.0.2b1 or later.

Vulnerable code sample

import re

# This code simulates the vulnerable part of Giskard's RegexMatching check.
# The 'run_check' function directly passes a user-supplied pattern and input
# to re.search() without any timeout or complexity guard, creating a
# Regular Expression Denial of Service (ReDoS) vulnerability.

def run_check(pattern, text_input):
    """Simulates the vulnerable check execution."""
    # The vulnerable call: a user-controlled pattern is used directly.
    re.search(pattern, text_input)
    # In a real application, the result would be processed. Here, the
    # process hangs before the function can even return.

# 1. An attacker crafts a malicious regex pattern designed to cause
# "catastrophic backtracking". The nested quantifiers (a+)+ create an
# exponential number of paths for the regex engine to try.
malicious_pattern = r"^(a+)+b$"

# 2. The attacker provides an input string that triggers the worst-case
# performance. This "almost-matching" string forces the engine to explore
# all futile backtracking paths, causing it to hang.
input_to_cause_dos = "a" * 28 + "!"

# 3. The vulnerable check is executed. This call will cause the Python
# process to hang indefinitely, consuming 100% of a CPU core.
run_check(malicious_pattern, input_to_cause_dos)

# The script will never proceed past the line above.

Patched code sample

import re
import signal

def safe_regex_search(pattern, text, timeout_seconds=1):
    """
    Performs re.search with a timeout to mitigate catastrophic backtracking (ReDoS).
    
    This function conceptually represents the fix for CVE-2026-40319.
    It wraps the regex operation in a timeout mechanism.

    Note: This specific implementation uses the 'signal' module and is not
    compatible with Windows. A cross-platform solution might use
    the 'multiprocessing' module instead.
    """
    def handler(signum, frame):
        raise TimeoutError(f"Regex search timed out after {timeout_seconds} seconds.")

    # Set the signal handler for the alarm signal
    signal.signal(signal.SIGALRM, handler)
    # Set an alarm for the specified timeout
    signal.alarm(timeout_seconds)

    try:
        # Execute the potentially vulnerable regex search
        result = re.search(pattern, text)
    finally:
        # Cancel the alarm to prevent it from firing later
        signal.alarm(0)

    return result

Payload

(a+)+Z

Cite this entry

@misc{vaitp:cve202640319,
  title        = {{A crafted regex in Giskard may cause a Denial of Service via backtracking.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-40319},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-40319/}}
}
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 ::