Skip to content

Arbitrary Code Execution via Malicious Recipe Selectors

High
jaimergp published GHSA-6cc8-c3c9-3rgr Jun 14, 2025

Package

conda-build (conda)

Affected versions

<=25.3.2

Patched versions

25.4.0

Description

The conda-build recipe processing logic has been found to be vulnerable to arbitrary code execution due to unsafe evaluation of recipe selectors. Currently, conda-build uses the eval function to process embedded selectors in meta.yaml files. This approach evaluates user-defined expressions without proper sanitization, which allows arbitrary code to be executed during the build process. As a result, the integrity of the build environment is compromised, and unauthorized commands or file operations may be performed.

The vulnerability stems from the inherent risk of using eval() on untrusted input in a context intended to control dynamic build configurations. By directly interpreting selector expressions, conda-build creates a potential execution pathway for malicious code, violating security assumptions. This highlights the need for a more secure mechanism to handle recipe selectors without evaluating untrusted expressions.

The following PoC demonstrates the method by which the recipe file with malicious recipe selectors can be used to run arbitrary code via the conda-build command:

mkdir /tmp/poc
cd /tmp/poc
cat > meta.yaml << "EOF"
package:
  name: poc
  version: 0.1

build:
  number: 0
  string: "dummy"  # [__import__('os').system('echo This is a malicious file!!! > /var/run/shm/poc.txt')]
EOF
conda build .
cat /var/run/shm/poc.txt

Output:

[...]
This is a malicious file!!!

The root cause lies in the unsafe handling of recipe selectors. TODO comments in the source code indicate that the development team is aware of the potential arbitrary code execution.

Affected file: https://github.com/conda/conda-build/blob/834448b995eee02cf1c2e7ca97bcfa9affc77ee5/conda_build/metadata.py

image image

Proposed fix

The use of eval() should be eliminated and replaced with a secure, custom parser capable of interpreting selector expressions safely. This parser should restrict evaluation to a safe subset of predefined operations, preventing execution of arbitrary code while maintaining the intended functionality of recipe selectors.

Severity

High

CVE ID

CVE-2025-32798

Weaknesses

No CWEs

Credits