T09 · Insecure Skill Coding Practices
- Location
scripts/convert.sh:142- Finding
Unrestricted Pandoc Options Permit Arbitrary Filter Execution
- Content
View full analysis
Vulnerability Details
File Location:
scripts/convert.sh, lines 142-152
Vulnerability Type: Unrestricted forwarding of execution-capable command-line options
Risk Level: Highbash --) shift while [ "$#" -gt 0 ]; do pandoc_args+=("$1") shift done ;; --*) pandoc_args+=("$1") validate_args+=("$1") shift ;;Technical Analysis
The wrapper forwards every unrecognized long option directly to Pandoc. It also forwards every argument following
--without validation. Although the final Pandoc invocation uses a Bash array and is therefore not directly vulnerable to shell metacharacter injection, Pandoc itself exposes execution-capable options.In particular, Pandoc supports
--filterand--lua-filter. A filter can be an executable program or a Lua script, and Pandoc executes it during document processing. Neither the conversion wrapper norvalidate.shrejects these options.Consequently, the wrapper's prerequisite validation does not form a security boundary. An attacker who can influence conversion arguments and provide or reference a local filter can cause arbitrary code to run with the privileges of the Agent process.
The broad
Bash(pandoc *)permission declared inSKILL.mdalso allows direct Pandoc invocation and should be narrowed as part of the same hardening effort.Attack Path
- An attacker places a malicious executable or Pandoc Lua filter in an accessible project or temporary directory.
- The attacker requests a document conversion containing an option such as
--lua-filter payload.luaor--filter ./payload. convert.shtreats the option as an unknown--*argument and adds it topandoc_args.- The associated option value is also added to the Pandoc argument array.
validate.shdoes not reject the execution-capable option.
...[truncated 683 chars]
- Remediation
View remediation
Remediation Suggestions
- Replace the generic
--*branch with an explicit allowlist of supported, non-executable Pandoc options. - Reject unknown options with a clear error instead of forwarding them.
- Remove unrestricted forwarding of arguments after
--, or apply the same strict allowlist to those arguments. - Explicitly deny at least
--filter,--lua-filter, and any other Pandoc option that loads code, invokes external programs, or reads configuration from an uncontrolled location. - Ensure
validate.shapplies the same option policy so validation and execution cannot interpret arguments differently. - Narrow or remove the
Bash(pandoc *)permission inSKILL.md; permit only hardened wrapper commands and narrowly scoped format-discovery operations where needed. - Add negative tests demonstrating that execution-capable and unknown options are rejected.
- If filters are required in the future, accept only administrator-approved filters from a fixed, trusted directory and verify their canonical paths before execution.
- Replace the generic
