Summary
The targets R package contains a code injection vulnerability when crafted data store metadata supplies custom format or CAS repository functions that are evaluated as code. If a victim reads or loads the data store or opens its workspace, this may allow arbitrary R code to run in the victim's environment.
Affected context
The issue affects targets R package versions before 1.12.1 when data store metadata can contain attacker-controlled function definitions or expressions. The risk arises when a victim uses tar_read(), tar_load(), or tar_workspace() with a crafted data store and the metadata is passed to eval(parse()).
Exploit preconditions
- Attack surface: Metadata in a targets data store
- Required access: An attacker must be able to provide or influence a crafted data store that the victim uses
- Trigger point: The victim calls
tar_read(),tar_load(), ortar_workspace()on that store - Why exploitation is possible: Metadata-supplied format or CAS repository functions are parsed and evaluated as R code
Why this happens
The underlying issue is evaluating expressions derived from data store metadata with eval(parse()). When that metadata is attacker-controlled, parsing and evaluating it treats data as executable code, matching CWE-95: Improper Neutralization of Directives in Dynamically Evaluated Code ('Eval Injection').
Potential impact
- Arbitrary R code could run with the privileges of the process using the data store
- Local files or accessible data may be exposed or modified
- The application or analysis environment could be disrupted
- Credentials or other resources available to the process may be at risk
General mitigation guidance
Defensive patterns focus on keeping data separate from executable logic and reducing trust in imported data stores. Prefer fixed, allowlisted handling of supported formats and repositories over evaluating metadata-derived expressions. Validate metadata against a strict schema before use, limit who can create or distribute data stores, and run data-processing workflows with least privilege and restricted access to sensitive resources.
How teams detect issues like this
Review code for eval() or parse() calls that consume metadata, serialized content, or other externally influenced values. Static analysis and code review can flag dynamic evaluation and trace whether inputs are validated or constrained before use. Policy checks can restrict dynamic code evaluation and require schema validation for imported data stores; automated review tools may help identify these patterns.

