T09 · Insecure Skill Coding Practices
- Location
skill.json:13- Finding
Command Injection Through an Unquoted Message ID Template
- Content
View full analysis
Vulnerability Details
File Location:
skill.json, line 13
Vulnerability Type: OS command injection through unsafe template interpolation
Risk Level: HighVulnerable Code:
json "command": "gog gmail read --id {{id}}"Technical Analysis
The
idparameter is inserted directly into a command string without quoting, escaping, or documented format validation. If the skill runtime performs textual substitution and passes the resulting string to a shell, an attacker-controlled value containing shell metacharacters can terminate or extend the intendedgogcommand.For example, a value conceptually shaped like
valid-id; attacker-commandcould cause the shell to execute both the expected Gmail operation and an additional command. The exact payload syntax depends on the shell and the tool runner's command-execution semantics.Attack Path
- An attacker causes an untrusted or attacker-controlled value to be supplied as the
idargument togmail_read. - The runtime substitutes that value into
gog gmail read --id {{id}}. - If the resulting command is evaluated through a shell, metacharacters in the value alter the command structure.
- The injected command executes with the operating-system permissions and environment inherited from the Agent process.
- The injected process may access local files, environment variables, OAuth material, or network resources available to that process.
Impact Assessment
Successful exploitation could provide arbitrary command execution under the Agent process account. The resulting scope is bounded by that account's local permissions, sandbox restrictions, available credentials, and network access. Because this skill is intended to access Google Workspace, a compromised process may also be able to reach locally stored OAuth credentials or invoke authenticated Workspace operations available to the configured
gogaccount.- An attacker causes an untrusted or attacker-controlled value to be supplied as the
- Remediation
View remediation
Remediation Suggestions
- Do not construct commands through string interpolation or invoke them through a shell.
- Define the executable and arguments separately, such as an argument array equivalent to
["gog", "gmail", "read", "--id", id]. - Validate
idagainst the exact Gmail message-ID syntax expected bygog, rejecting whitespace, control characters, shell metacharacters, option prefixes, and values outside reasonable length limits. - If the framework only supports command strings, apply a framework-approved shell-escaping function after validation; quoting alone should not be treated as the primary control.
- Add tests using values containing semicolons, command substitutions, quotes, newlines, and leading hyphens to verify that they are rejected or passed strictly as one literal argument.
- Run the skill with least privilege and isolate Workspace credentials from unrelated subprocesses.
