T09 · Insecure Skill Coding Practices
- Location
paper-viz/scripts/ppt-exporter.ts:70- Finding
Arbitrary Python Code Execution Through PPT Output Path Injection
- Content
View full analysis
{ return this.runCommand(this.pythonPath, ['-c', code]); } ``` The CLI supplies the path: ```ts const outputIndex = args.indexOf('--output'); const outputFile = outputIndex > -1 ? args[outputIndex + 1] : undefined; const exportPpt = args.includes('--ppt'); const htmlPath = outputFile || `${analysis.metadata.title.slice(0, 50).replace(/[^\w\s-]/g, '').trim().replace(/\s+/g, '-')}-viz.html`; if (exportPpt) { const pptPath = htmlPath.replace(/\.html$/, '.pptx'); const exporter = new PptExporter(); await exporter.export(presentation, { outputPath: pptPath }); } ``` ### Technical Analysis Replacing backslashes does not make a string safe for interpolation into Python source. A path containing a double quote, newline, or other Python syntax can terminate the string literal and append attacker-controlled statements. The child process is created without a shell, but that does not prevent this vulnerability because the injection occurs inside the Python program passed to `python - ...[truncated 1082 chars]- Remediation
View remediation
