T09 · Insecure Skill Coding Practices
- Location
SKILL.md:284- Finding
Shell Command Injection Through Unquoted Manifest Heredoc
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md:284-289; duplicated inreferences/routine.md:306-310
Vulnerability Type: Shell command injection through unsafe heredoc interpolation
Risk Level: MediumVulnerable Code
bash cat > "$JOB/manifest.json" <<JSON {"decoration_id": <DECO_ID>, "job_reference": "<DECO_ID>", "customer": "<customer>", "job_name": "<job_name>", "digitize_demand_id": <DEMAND_ID>, "artwork_lady_order_id": "<order # if known>", "date_filed_utc": "<UTC now>", "files": [{"filename": "...", "bytes": 0}]} JSONThe reference documentation repeats the same unsafe construction:
bash cat > "$JOB/manifest.json" <<JSON {"decoration_id":4590,"job_reference":"4590","customer":"…","job_name":"…", "digitize_demand_id":812,"artwork_lady_order_id":"…","date_filed_utc":"$(date -u +%FT%TZ)", "files":[{"filename":"4590.DST","bytes":0},{"filename":"4590.pdf","bytes":0}]} JSONTechnical Analysis
An unquoted shell heredoc delimiter such as
<<JSONperforms parameter expansion, command substitution, and arithmetic expansion within its body. The instructions direct the agent to insert customer names, job names, order identifiers, filenames, and other metadata obtained from Odoo or the external digitizing vendor into that body.If an independently controlled metadata field is inserted verbatim and contains shell syntax such as
$(command)or backticks, the shell executes that content before writingmanifest.json. JSON quotation marks do not prevent shell expansion.The vulnerability crosses a trust boundary because ERP or vendor-provided text is intended to be stored as JSON data but can instead be interpreted by the agent host's shell. The Python scripts themselves do not implement this vulnerable operation; the affected behavior is contained in the operational instructions that the agent is expected to execute.
Attack Path
- An attacker able to influence ...[truncated 1324 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not generate JSON by interpolating external values into shell source.
- Use a JSON serializer, such as Python's
json.dump, and pass values through structured input or environment variables rather than embedding them into executable shell text. - Apply the same correction to both
SKILL.mdandreferences/routine.md. - If a static heredoc is unavoidable, quote the delimiter as
<<'JSON'so the shell performs no expansion. Dynamic values must then be added through a serializer rather than direct interpolation. - Validate that the archive path is derived only from an expected numeric decoration identifier and treat customer names, job names, order identifiers, and filenames exclusively as data.
- Add a regression test using values containing
$(...), backticks, quotation marks, newlines, and JSON metacharacters, verifying that they are serialized literally and never executed.
