T09 · Insecure Skill Coding Practices
- Location
pctx-skill.sh:213- Finding
Arbitrary Local Code Execution Through Unsafe CLI Argument Interpolation
- Content
View full analysis
/dev/null | grep "^data:" | head -1 | sed 's/^data: //') echo "📚 Available functions in $ns:" echo "$list_resp" | python3 -c " import sys, json, re ns = '$ns' d = json.load(sys.stdin) text = d.get('result',{}).get('content',[{}])[0].get('text','') pattern = f'namespace {ns}' idx = text.find(pattern) ... " 2>/dev/null return fi local code="async function run() { const result = await ${ns}.${fn}({}); return JSON.stringify(result, null, 2); }" local call_payload call_payload=$(python3 -c " import json print(json.dumps({'jsonrpc':'2.0','id':2,'method':'tools/call','params':{ 'name':'execute_typescript', 'arguments':{'code':'$code'} }})) " 2>/dev/null) ``` ### Technical Analysis The `test` command accepts `server` and `fn` as command-line arguments. Values other than the two recognized server names are assigned directly to `ns` without validation: ```bash *) ns="$server" ;; ``` The resulting value is embedded inside Python source supplied to `python3 -c`: ```python ns = '$ns' ``` Both `ns` and `fn` are also included in `code`, which is subsequently embedded inside another single-quoted Python string: ```python 'arguments':{'code':'$code'} ``` Shell quoting does not make these generated Python strings ...[truncated 1898 chars]- Remediation
View remediation
