Summary
yt evaluates the con_args attribute from ytdata HDF5 files as Python code when loading a saved dataset. A malicious file may therefore execute code with the permissions of the user who loads it.
Affected context
The vulnerability occurs in SavedDataset._parse_parameter_file() when yt processes the con_args attribute in a ytdata HDF5 file. It becomes risky when a user loads a crafted .h5 file with yt.load() and the attribute reaches unrestricted evaluation.
Exploit preconditions
- Attack surface: Loading a ytdata HDF5 file through yt.
- Required access: An attacker must be able to provide or influence a file that a user will load; the attacker does not necessarily need direct access to the user's runtime.
- Trigger point: Processing
con_argsinSavedDataset._parse_parameter_file()during dataset loading. - Why exploitation is possible: The attribute is passed to unrestricted
eval(), allowing its contents to be interpreted as Python code.
Why this happens
The code evaluates a value from a dataset file rather than treating it strictly as data. Using unrestricted eval() on attacker-influenced input can execute Python expressions, matching CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code.
Potential impact
- An attacker could execute Python code with the loading user's permissions.
- The user's files, credentials, or accessible data may be exposed or modified.
- The compromised process could be used to affect other systems or services available to that user.
General mitigation guidance
Mitigation generally focuses on removing dynamic evaluation of file-controlled values and reducing trust in dataset metadata.
Common defensive patterns include:
- Parse values with data-only formats or restricted parsers instead of evaluating them as code.
- If expressions are required, define and enforce a narrow, explicit grammar and reject unsupported constructs.
- Treat datasets from external or untrusted sources as potentially hostile, and validate their metadata before use.
- Load untrusted files in isolated environments with minimal permissions and limited access to sensitive resources.
How teams detect issues like this
- Use static analysis to identify
eval()and similar dynamic execution APIs, especially when their inputs originate from files or metadata. - Review dataset-loading paths for flows from HDF5 attributes into interpreters or expression evaluators.
- Apply code-review policies that require justification and strict input constraints for dynamic evaluation.
- Use automated code review or security scanning tools to flag risky evaluation patterns.

