T09 · Insecure Skill Coding Practices
- Location
scripts/md-to-html-post.sh:42- Finding
Python Code Injection Through Untrusted Publication Parameters
- Content
View full analysis
/dev/null; then ``` ### Technical Analysis The script interpolates `PROFILE`, `TITLE`, and `SLUG` directly into source code supplied to `python3 -c`. The title and slug originate in a potentially untrusted Markdown file, while the profile is a command-line argument. Shell quoting around the outer Python program does not make these values safe Python literals. An attacker can include a single quote and a valid Python expression in a front-matter value. After interpolation, that expression becomes executable Python code. For example, a title shaped like the following can cause an operating-system command to run while remaining syntactically valid inside the argument list: ```yaml title: "x' + __import__('os').popen('id').read() + 'y" ``` The simple `sed` operations only remove surrounding quote characters. They do not perform Python string escaping or YAML-aware validation. ### Attack Path 1. An attacker prepares a Markdown document containing a malicious `title` or `slug` front-matter value. 2. A user or automation in ...[truncated 872 chars]- Remediation
View remediation
