Summary
A critical vulnerability in DIRAC's dataset handling allows an authenticated caller to influence a SQL query used to retrieve dataset metadata. The resulting database-controlled expression is evaluated by Python, which may enable arbitrary command execution with the privileges of the DIRAC service account.
Affected context
The issue occurs in DIRAC deployments where the DataManagementSystem file catalog handler processes caller-controlled dataset values and forwards them to the dataset manager. Risk is present when dataset names are incorporated into SQL statements without parameterization and returned metadata is subsequently evaluated as executable Python code.
Exploit preconditions
- Attack surface: DIRAC file catalog and dataset management services
- Required access: An authenticated account able to invoke the affected dataset-checking functionality
- Trigger point: Processing of the
checkDatasetrequest and subsequent metadata evaluation - Why exploitation is possible: Caller-controlled input reaches a non-parameterized SQL query, and the returned metadata value can influence Python
evalexecution
Why this happens
The primary defect is SQL query construction through string interpolation, allowing untrusted dataset input to alter database query behavior. This maps to CWE-89: Improper Neutralization of Special Elements used in an SQL Command ('SQL Injection'). The vulnerability is compounded by CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code, because database-derived content is passed to Python evaluation rather than being treated strictly as data.
Potential impact
- An attacker may execute operating-system commands as the DIRAC service account.
- Sensitive configuration files, database credentials, proxies, and tokens could be exposed.
- The attacker could fully compromise DIRAC-managed services and associated computing resources.
- Local logs and other evidence could be altered or removed.
- Distributed-computing workloads, data, and service integrity could be affected.
General mitigation guidance
Mitigation generally focuses on removing both the SQL injection path and the dynamic evaluation of database-derived values.
Common defensive patterns include:
- Use parameterized queries or trusted query-builder abstractions for all caller-influenced values.
- Replace
evalwith explicit parsing, typed structures, and allowlisted operations. - Apply strict schema and format validation at the service boundary.
- Treat database results as untrusted data, even when they originate from internal tables.
- Run DIRAC services with least-privilege accounts and restrict access to secrets, proxies, and configuration files.
- Segment service permissions and protect logs from unauthorized modification.
How teams detect issues like this
High-level detection approaches include:
- Static analysis for SQL statements built through string concatenation or interpolation.
- Rules identifying
evalor equivalent dynamic execution on request data or database results. - Code review checks for missing query parameters, weak input validation, and implicit trust in metadata tables.
- Runtime monitoring for anomalous dataset queries, unexpected metadata values, and child-process creation by DIRAC services.
- Policy enforcement requiring parameterized database access and prohibiting dynamic evaluation of external or database-controlled content.
- Neutral automated security-review tools can help identify these patterns during development and CI.

