subprocess module call
Medium
- Category
- Dangerous Code Execution
- Content
# Root the tree print("\n[3b] Rooting tree (R/ape)") subprocess.run([ "Rscript", "-e", f''' library(ape) t <- midpoint(read.tree("{tree_file}"))- Confidence
- 90% confidence
- Finding
- This code builds inline R source with Python f-strings that interpolate filesystem paths directly into quoted R code. If an attacker controls the output directory or related path values and includes characters like quotes or backslashes, they can break out of the R string literal and inject arbitrary R commands, leading to code execution when Rscript runs.
