T09 · Insecure Skill Coding Practices
- Location
SKILL.md:27- Finding
Shell Command Injection Through Untrusted Certificate Inputs
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, lines 27–40
Vulnerability Type: Shell command injection through unsafe interpolation of user-controlled PEM content, file paths, and hostnames
Risk Level: HighVulnerable Code
markdown 2. **From pasted PEM text:** Write the PEM content to a temp file, then: ``` echo "PEM_CONTENT" | openssl x509 -text -noout ``` Or use process substitution if available. 3. **From a file path:** ``` openssl x509 -text -noout -in /path/to/cert.pem ``` 4. **From a live hostname (port 443):** ``` echo | openssl s_client -connect HOSTNAME:443 -servername HOSTNAME 2>/dev/null | openssl x509 -text -noout ```Technical Analysis
The skill instructs an agent to insert user-controlled certificate text, file paths, or hostnames into shell command templates. It does not require strict input validation, shell-safe escaping, argument-array execution, or robust end-of-options handling.
If these templates are assembled as command strings and evaluated by a shell, crafted input containing quotation marks, command substitutions, separators, redirections, or other shell metacharacters could escape the intended argument context and alter command execution. The hostname is interpolated twice in a shell pipeline, increasing the injection surface. Pasted PEM data is also shown as an argument to
echo, which is unsafe for arbitrary multiline content and may expose shell parsing behavior if implemented by direct textual substitution.File paths can additionally create option-confusion risks if option-like values are accepted without validation or safe argument separation. The issue is conditional on the invoking agent constructing and executing these templates through a shell, but the skill explicitly recommends that execution pattern without relevant safeguards.
Attack Path
- An attacker asks the skill to inspect a certificate ...[truncated 1053 chars]
- Remediation
View remediation
Remediation Suggestions
- Do not construct shell command strings from user input. Invoke
opensslthrough a subprocess API with an explicit argument array and shell execution disabled. - Write pasted PEM bytes directly to a securely created temporary file using a file API. Use restrictive permissions, avoid predictable names, and delete the file in a guaranteed cleanup block.
- Validate live-certificate targets using a strict hostname or IP-address parser. Reject whitespace, control characters, shell metacharacters, embedded ports, and malformed internationalized domain names.
- Keep the port as a separately validated integer and construct the
host:portargument in application code rather than through shell interpolation. - Pass certificate paths as discrete subprocess arguments. Reject ambiguous option-like paths or safely normalize them before invocation.
- Capture standard output and standard error directly through the subprocess API instead of using shell pipelines and redirections.
- Add explicit instructions that raw user input must never be interpolated into a command line, including through
echo, process substitution, orsh -c. - Run certificate inspection with least privilege, a restricted environment, bounded execution time, and appropriate network controls to reduce the impact of any parsing or invocation failure.
- Do not construct shell command strings from user input. Invoke
