T09 · Insecure Skill Coding Practices
- Location
scripts/tier1/phase-4-execute-tests.sh:136- Finding
Untrusted target commands bypass the default read-only execution gate ## Remediation Suggestions 1. Replace shell command strings with structured executable and argument fields, and execute validated argument arrays without `bash -c`. 2. Enforce an explicit allowlist of read-only cloud operations. Treat unknown operations as requiring authorization rather than assuming they are safe. 3. Reject shell operators, substitutions, and redirections in automatically executed CLI test definitions. 4. Treat target-provided scripts and SDK snippets as untrusted executable code. Require separate authorization and run them in an isolated environment. 5. Provide subprocesses only the credentials and environment variables required for the approved operation. Prefer a cloud identity whose permissions independently enforce read-only access. 6. Apply the same execution policy to Phase 4 and single-Skill Phase 6, and add regression tests covering compound commands and command substitution.
- Content
View full analysis
Vulnerability Details
File Location:
scripts/tier1/phase-1-skill-analysis.sh:317–327scripts/tier1/phase-3-gen-testcases.sh:172–190scripts/tier1/phase-4-execute-tests.sh:136–172- Additional affected path:
scripts/tier2/phase-6-full-flow.sh:175–209
Vulnerability Type: T09: Insecure Skill Coding Practices
Risk Level: High
Validation: Confirmed by static analysis; no exploitation was executed.Technical Analysis
Phase 1 extracts command lines from the target Skill's documentation. For lines beginning with
hcloud, it determines whether the entire command is a write operation using only four substring checks. It does not parse or reject shell composition.python elif cl.startswith('hcloud '): cmd_id += 1 is_write = any(kw in cl.lower() for kw in ['create', 'delete', 'update', 'destroy']) clean_cmd = re.sub(r'<[^>]+>', '', cl).strip() commands.append({ 'id': 'CMD-%02d' % cmd_id, 'source': 'SKILL.md-bash-block', 'description': clean_cmd[:80], 'command': clean_cmd, 'executor': 'cli', 'is_write': is_write })Phase 3 inherits the classification rather than independently validating execution safety:
python is_write = cmd.get('is_write', False)The generated test case retains the command and classification:
python 'command': cmd_text,python 'is_write': is_write,Phase 4 evaluates
ALLOW_WRITESonly for cases classified as writes:python if is_write:python allow_writes = os.environ.get('ALLOW_WRITES', '0') == '1' if not allow_writes: entry['status'] = 'skip' entry['output_snippet'] = '写操作已跳过 (ALLOW_WRITES=0)' skip_count += 1 print(f" ⏭️ SKIP-写操作 (ALLOW_WRITES=0)") exec_results.append(entry) continueThe CLI execution branch then interprets the retained command as shell code:
python r = subprocess.run( ['bash', '-c', cmd_text], capture_output=True, text=True, timeout=int(o ...[truncated 2157 chars]
