VAITP Dataset

← Back to the dataset

CVE-2026-31230

ART Kubeflow argument injection via unsafe eval() allows code execution.

  • CVSS 9.8
  • CWE-88
  • Input Validation and Sanitization
  • Remote

The Adversarial Robustness Toolbox (ART) thru 1.20.1 contains a command-line argument injection vulnerability in its Kubeflow component (robustness_evaluation_fgsm_pytorch.py). The script uses the unsafe eval() function to parse string values provided via the –clip_values and –input_shape command-line arguments. This allows an attacker to inject arbitrary Python code into these arguments, which will be executed when eval() is called. The vulnerability can be exploited remotely if an attacker can control these arguments (e.g., through pipeline configuration or automated scripts), leading to arbitrary code execution on the system running the ART evaluation.

CVSS base score
9.8
Published
2026-05-12
OWASP
A03 Injection
Orthogonal defect classification
Checking
Code defect classification
Incorrect Algorithm
Category
Input Validation and Sanitization
Subcategory
Command Injection
Accessibility scope
Remote
Impact
Arbitrary Code Execution
Affected component
Adversarial
Fixed by upgrading
Yes

Solution

Upgrade Adversarial Robustness Toolbox (ART) to version 1.20.2 or later.

Vulnerable code sample

import argparse
import sys

def main():
    """
    Main function to parse arguments and run a simulated evaluation.
    This script contains a command injection vulnerability via eval().
    """
    parser = argparse.ArgumentParser(description="PyTorch FGSM Robustness Evaluation")

    parser.add_argument(
        "--clip_values",
        type=str,
        help="A string to be evaluated as a Python tuple, e.g., '(0, 1)'.",
        required=True,
    )
    parser.add_argument(
        "--input_shape",
        type=str,
        help="A string to be evaluated as a Python tuple, e.g., '(1, 28, 28)'.",
        required=True,
    )
    parser.add_argument(
        "--model_path",
        type=str,
        help="Path to the trained model.",
        default="/mnt/model.pt"
    )

    # In a real Kubeflow component, more arguments would be parsed here.

    if len(sys.argv) == 1:
        parser.print_help(sys.stderr)
        sys.exit(1)

    args = parser.parse_args()

    print(f"[INFO] Received model path: {args.model_path}")
    
    # VULNERABILITY: Unsafe use of eval() on user-provided command-line arguments.
    # An attacker can inject arbitrary code into --clip_values or --input_shape.
    # Example payload: --clip_values="__import__('os').system('echo pwned > /tmp/pwned')"
    print(f"[INFO] Parsing --clip_values argument: {args.clip_values}")
    clip_values = eval(args.clip_values)
    
    print(f"[INFO] Parsing --input_shape argument: {args.input_shape}")
    input_shape = eval(args.input_shape)

    print(f"[SUCCESS] Parsed clip_values: {clip_values}")
    print(f"[SUCCESS] Parsed input_shape: {input_shape}")
    print("\n[INFO] Starting simulated robustness evaluation...")
    # Dummy evaluation logic would follow
    print("[INFO] Evaluation complete.")

if __name__ == "__main__":
    main()

Patched code sample

import argparse
import ast
import sys

# This example represents the fixed code.
# The vulnerability was the use of the unsafe `eval()` function to parse
# command-line arguments. The fix is to replace it with the secure
# `ast.literal_eval()` function.

parser = argparse.ArgumentParser()

parser.add_argument(
    "--clip_values",
    type=str,
    default="(0, 1)",
    help="String representation of a tuple, e.g., '(0, 1)'"
)
parser.add_argument(
    "--input_shape",
    type=str,
    default="(1, 28, 28)",
    help="String representation of a tuple, e.g., '(1, 28, 28)'"
)

args = parser.parse_args()

try:
    # FIXED AND SAFE CODE:
    # `ast.literal_eval` safely parses strings containing Python literals
    # (like tuples, lists, numbers) without executing arbitrary code.
    clip_values = ast.literal_eval(args.clip_values)
    input_shape = ast.literal_eval(args.input_shape)

    print(f"Successfully parsed clip_values: {clip_values}")
    print(f"Successfully parsed input_shape: {input_shape}")

except (ValueError, SyntaxError) as e:
    # An attempt to inject code (e.g., passing "__import__('os').system('id')")
    # will fail safely with a ValueError here instead of being executed.
    print(f"Error: Invalid or malicious input detected. {e}", file=sys.stderr)
    sys.exit(1)

Payload

__import__('os').system('id')

Cite this entry

@misc{vaitp:cve202631230,
  title        = {{ART Kubeflow argument injection via unsafe eval() allows code execution.}},
  author       = {Bogaerts, Fr\'ed\'eric and Ivaki, Naghmeh and Fonseca, Jos\'e},
  year         = {2026},
  note         = {VAITP Python Vulnerability Dataset, entry CVE-2026-31230},
  howpublished = {\url{https://netpack.pt/vaitp/vulnerability/CVE-2026-31230/}}
}
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 ::