T09 · Insecure Skill Coding Practices
- Location
SKILL.md:63- Finding
Unsafe Default Execution of Generated Code
- Content
View full analysis
Vulnerability Details
File Location:
SKILL.md, line 63
Vulnerability Type: Unsafe execution guidance for generated code
Risk Level: MediumVulnerable Code Snippet
markdown 3. **代码测试**: 生成的代码先运行验证English translation:
text 3. Code testing: Run generated code first to verify it.Technical Analysis
The skill directs the agent to run generated code as a verification step but does not require prior static review, isolation, least-privilege execution, network restrictions, resource limits, or user approval.
Generated code should be treated as untrusted because it may be influenced by user-controlled prompts or external content. It may contain destructive commands, credential-access logic, unauthorized network operations, or unintended side effects. Automatically executing such code through an agent's available tools can therefore cross the boundary between content generation and arbitrary code execution.
Attack Path
- An attacker supplies a prompt or external content designed to influence generated code.
- The agent produces code containing malicious or destructive behavior.
- The skill's verification instruction causes the agent to run the generated code.
- The code executes with the permissions and environmental access available to the agent.
- Depending on those permissions, the code may read or alter files, access credentials, initiate network requests, or perform other unauthorized actions.
Impact Assessment
The impact is bounded by the execution environment and the agent's privileges. In an insufficiently isolated environment, exploitation could result in:
- Unauthorized reading, modification, or deletion of accessible files.
- Exposure of credentials, tokens, or other secrets available to the process.
- Unauthorized outbound network activity or data disclosure.
- Execution of arbitrary commands under the agent's operating-system identity.
- Compromise of other resources reachable from the executio ...[truncated 166 chars]
- Remediation
View remediation
Remediation Suggestions
Replace the unconditional execution guidance with a safety-gated verification process:
- Perform static review before executing generated code.
- Execute code only when runtime testing is necessary.
- Use an isolated, disposable sandbox with no production credentials or sensitive files.
- Deny network access by default and permit only explicitly required destinations.
- Mount the filesystem read-only where possible and expose only task-specific files.
- Run under a dedicated, unprivileged identity with minimal permissions.
- Enforce CPU, memory, process, disk, and execution-time limits.
- Require explicit user approval before tests that may create external side effects.
- Reject or escalate code containing destructive commands, credential access, persistence, privilege changes, or unapproved network activity.
- Verify outputs and side effects after execution, then destroy the sandbox.
A safer replacement instruction would be:
text Review generated code statically first. Execute it only when necessary, using an isolated sandbox with no secrets, minimal filesystem and network access, strict resource limits, and explicit approval for any external side effects.
