T09 · Insecure Skill Coding Practices
- Location
SKILL.md:84- Finding
Shell Command Injection Through User-Controlled Heredoc Content
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 84–86
Vulnerability Type: Shell command injection through unsafe heredoc generation
Risk Level: HighVulnerable Code:
bash cat > /tmp/job_application_email.txt << 'EOF' [email body here] EOFTechnical Analysis
The skill directs the agent to insert an email body into a shell heredoc. Although quoting
'EOF'prevents shell expansion inside the heredoc body, it does not prevent an inserted line containing exactlyEOFfrom terminating the heredoc.The email body may include user-controlled resume or cover-letter content. If that content is interpolated into the displayed shell command without validation, an attacker can terminate the heredoc and place arbitrary shell commands after it. Those commands would be parsed and executed by the shell running the workflow.
For example, malicious resume content could conceptually include a standalone heredoc terminator followed by a command and another heredoc construction. This turns document content into executable shell syntax.
Attack Path
- An attacker supplies resume, cover-letter, or email-body content containing a line that consists only of
EOF. - The attacker places shell commands on the following lines.
- The agent interpolates that content into the documented heredoc command.
- The injected
EOFcloses the intended heredoc prematurely. - The shell interprets the remaining attacker-controlled lines as commands.
- Those commands execute with the operating-system privileges and accessible credentials of the agent process.
Impact Assessment
Successful exploitation permits arbitrary local command execution under the account running the skill. The attacker could read or modify files accessible to that account, access environment variables and local credentials, alter the email being sent, invoke authenticated tools such as
gog, or establish additional effe ...[truncated 191 chars]- An attacker supplies resume, cover-letter, or email-body content containing a line that consists only of
- Remediation
View remediation
Remediation Suggestions
- Do not construct a shell script by interpolating untrusted email or resume content.
- Use a file-writing API that treats the body strictly as data rather than shell syntax.
- If a subprocess is required, pass the body through standard input using a parameterized process API without
shell=true. - Avoid fixed heredoc delimiters for untrusted multiline content. Merely changing the delimiter to another constant does not eliminate the weakness.
- Keep command arguments in an argument array rather than constructing a single command string.
- Validate the generated message and show the exact final body and recipients to the user before invoking the email tool.
- Add tests containing standalone delimiter lines and shell metacharacters to ensure document content cannot alter command structure.
