T09 · Insecure Skill Coding Practices
- Location
scripts/hermes_dashboard_extension_builder.py:36- Finding
Python Code Injection in Generated Backend Route
- Content
View full analysis
route namespace.'}) ``` ### Technical Analysis The `api_route` value may originate from an attacker-controlled JSON specification. It is inserted directly into generated Python source code inside a double-quoted string literal. Validation only requires that the value begin with `/api/`. It does not reject quotation marks, backslashes, line breaks, comments, or other Python syntax. Consequently, a crafted value can terminate the generated string, close the return expression, and append arbitrary Python statements. For example, a route beginning with `/api/` could contain a closing quote followed by a newline and Python statements. The generated file would then contain attacker-selected executable code rather than only a route constant. Because this is source-code generation rather than ordinary data serialization, the payload can execute when the generated module is imported, run directly, or invoked by the dashboard backend. ### Attack Path 1. An attacker creates or modifies a JSON specification supplied through `--spec`. 2. The attacker sets `api_route` to a value that starts with `/api/` but contains a quote, newline, and injected Python statements. ...[truncated 989 chars]- Remediation
View remediation
