Summary
The Adversarial Robustness Toolbox (ART) Kubeflow component uses Python's eval() on user-supplied strings for LossFn and Optimizer when evaluating PyTorch model robustness.
A crafted parameter value can inject arbitrary Python code, leading to remote code execution and full compromise of the system running the ART evaluation.
Affected context
This vulnerability occurs in deployments that:
- Use the Adversarial Robustness Toolbox (ART) up to and including version 1.20.1
- Run the Kubeflow-based robustness evaluation pipelines for PyTorch models
- Accept or propagate user-controlled strings for the LossFn and Optimizer parameters
The risk is most pronounced in environments where evaluation jobs are triggered by external users, automated workflows, or shared experimentation platforms that allow arbitrary parameter configuration.
Exploit preconditions
- Attack surface: ART Kubeflow robustness evaluation interface for PyTorch (e.g., pipeline parameters, job specs, APIs, or UI forms that set LossFn and Optimizer).
- Required access: Ability to submit or influence robustness evaluation jobs such that attacker-controlled strings are used as LossFn and/or Optimizer values.
- Trigger point: Execution of the robustness evaluation function that calls eval() on these user-supplied strings.
- Why exploitation is possible: The implementation directly passes unvalidated, unbounded user input into Python's eval(), which executes arbitrary expressions with the process' full interpreter context and privileges.
Why this happens
The core issue is a classic code injection pattern mapped to CWE-94: Improper Control of Generation of Code ('Code Injection').
Instead of mapping user input to a safe, predefined set of loss functions and optimizers, the ART Kubeflow component dynamically evaluates arbitrary strings via eval() to construct these objects at runtime.
Because eval() treats input as executable Python code, any attacker-controlled parameter becomes part of the program itself, allowing execution of OS commands or arbitrary logic with the same privileges as the ART evaluation process.
The absence of strict whitelisting, sandboxing, or context restriction around eval() enables full interpreter access and makes exploitation straightforward wherever user-controlled input flows into these parameters.
Potential impact
- Execution of arbitrary Python code in the ART evaluation environment
- Full compromise of the container, pod, or host running the Kubeflow evaluation job
- Theft or manipulation of model artifacts, training data, or robustness evaluation results
- Lateral movement within the Kubeflow or Kubernetes cluster, depending on existing permissions and network configuration
- Use of the compromised environment as a pivot for broader infrastructure attacks or data exfiltration
General mitigation guidance
Effective mitigation focuses on eliminating dynamic code evaluation and strictly constraining how loss functions and optimizers are selected:
- Replace eval() with explicit mapping tables (e.g., dictionaries) from allowed string identifiers to known-safe LossFn and Optimizer classes or factory functions.
- Enforce allowlists for all user-configurable algorithm parameters, rejecting any value not in a predefined set of supported options.
- Separate configuration from code by treating user input purely as data, never as executable expressions, and avoiding APIs that parse or interpret input as code.
- Run robustness evaluations with least-privilege runtime settings (restricted filesystem access, limited network connectivity, non-root accounts, and minimal Kubernetes RBAC permissions) to reduce blast radius if a flaw reappears.
- Introduce defense-in-depth controls such as input length limits and strict type validation to reduce unexpected input forms even when using safe selection mechanisms.
How teams detect issues like this
Detection can rely on both code-centric and operational approaches:
- Static analysis: Configure rules to flag any usage of eval(), exec(), or similar dynamic execution APIs, especially when fed by untrusted or external data flows.
- Code review: Treat dynamic code evaluation as a high-risk pattern; reviewers should explicitly verify that configuration-driven behavior uses allowlists or factory mappings rather than evaluating raw strings.
- Policy enforcement: Adopt secure coding standards that prohibit eval() and require justification and sign-off for any dynamic execution constructs; integrate these checks into CI/CD pipelines.
- Runtime monitoring: Observe Kubeflow and container logs for unusual Python execution patterns, subprocess invocations, or unexpected network/file access from robustness evaluation jobs that could indicate code injection attempts.

