T09 · Insecure Skill Coding Practices
- Location
scripts/generate_build_dockerfile.py:107- Finding
Dockerfile Instruction Injection Through Unvalidated Version Metadata
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is mostly aligned with containerizing projects, but it needs review because it can duplicate live configuration secrets and run Docker build/deploy workflows with limited safety controls.
Review before installing or using on a real project. Run it only on repositories where Docker builds are acceptable, inspect generated deploy/ files before executing them, avoid running it against projects with live .env or secret-bearing config files, and prefer non-root containers with pinned images and package-manager versions.
scripts/generate_build_dockerfile.py:107Dockerfile Instruction Injection Through Unvalidated Version Metadata
scripts/prepare_configs.py:12Live Environment Files and Secrets Are Recursively Copied Into Deployment Output
scripts/generate_deployment.py:53Generated Deployment Script Unsafely Parses and Expands Environment Values
scripts/generate_deploy_dockerfile.py:9Generated Application Containers Default to Root Execution
scripts/generate_build_dockerfile.py:151Generated Builds Use Mutable Images and Unpinned Package-Manager Dependencies
该代码块是一个“阶段1”分析脚本,功能集中在读取项目目录结构与常见文件,检测技术栈,查找现有 Dockerfile,扫描配置和文档,并输出一份 Markdown 分析报告。它确实与“容器化”领域相关,属于容器化前置分析的一部分,但与声明中的核心能力存在明显差距:声明强调自动配置和优化容器化方案、生成 Dockerfile、生成 compose.yaml、输出最终部署方案;而实际代码没有任何模板渲染、文件生成功能(除分析报告外),也没有构建/部署编排逻辑。因此描述将该技能表述为完整容器化适配工具,而代码实际只是分析阶段组件,属于功能性描述不准确、主目的缩窄明显的情况。
声明描述的是一个覆盖面较广的“完整容器化改造/部署方案生成”技能,而代码行为明显更窄:这是一个专门生成构建阶段 Dockerfile 的脚本。它会读取少量常见配置文件来推断语言版本或包管理器,并按传入的项目类型模板化输出 Dockerfile.build。虽然这与“容器化”领域相关,属于声明的一部分支撑能力,但远未达到声明中的完整能力范围。尤其缺少 compose.yaml 生成、部署文档生成、完整运行容器方案、自动项目识别与整体编排。因此描述对实际能力有明显夸大,构成描述与行为不匹配。
声明描述的是一个“完整容器化适配”能力集合,范围包括自动分析项目、优化容器化打包方案、生成 Dockerfile 与 compose.yaml、输出文档和完整部署方案。而实际代码块的职责明显更窄:它只是一个部署 Dockerfile 生成脚本,基于用户提供的 project_type 选择预定义模板,写出 deploy/Dockerfile。虽然这与声明中的“生成 Dockerfile”部分一致,但缺失了声明中的多个核心能力,尤其是 compose.yaml 生成、说明文档生成、完整项目分析、以及整体部署方案产出。因此描述明显夸大了该代码块的实际功能,属于描述与行为不匹配。
声明描述的是一个端到端的项目容器化能力,核心输出应包括 Dockerfile、compose.yaml 以及完整部署方案。而提供的代码块功能范围明显更窄,仅是“阶段4”的配置准备脚本:查找配置文件、复制到部署目录、生成环境变量模板和配置说明文档。虽然这些行为可作为容器化流程的辅助步骤,且文档中提到容器挂载路径,但它并没有实际生成任何容器构建/编排文件,也没有体现自动检测分析项目代码文档或优化打包方案的能力。因此,代码实际行为与声明的主要用途存在实质性不匹配。
The skill does not warn that it will execute Docker build and deployment commands on the user's system. That omission is dangerous because builds and startup can run arbitrary project-defined logic, consume resources, open ports, and pull remote dependencies without informed approval.
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
}
# 环境变量文件
for f in ['.env', '.env.example', '.env.template', '.env.local', 'config.env']:
if os.path.exists(os.path.join(project_path, f)):
configs['env_files'].append(f)
The generated shell script reads .env and exports its contents using 'export $(cat .env | grep -v '^#' | xargs)'. This is an unsafe pattern because shell word-splitting and parsing can corrupt secret values, mishandle special characters, and potentially alter shell behavior if the file contains unexpected content; in a deployment skill, .env commonly contains credentials, so the context increases sensitivity.
set -e
# 加载环境变量
if [ -f .env ]; then
export $(cat .env | grep -v '^#' | xargs)
fi
This is the continuation of the same unsafe .env-loading logic and therefore carries the same risk: secrets in .env are injected into the current shell environment through fragile parsing. In deployment automation, that broadens exposure of credentials to subprocesses and increases the chance of accidental leakage via debugging, process environments, or malformed variable parsing.
# 加载环境变量
if [ -f .env ]; then
export $(cat .env | grep -v '^#' | xargs)
fi
# 镜像名称
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
├── compose.yaml # 部署编排(含配置挂载)
├── compose.build.yaml # 打包编排
├── docker-run.sh # 部署脚本
├── .env # 环境变量配置
├── artifacts/ # 打包制品目录
├── config/ # 配置文件目录
│ └── [项目原有配置文件]
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
├── compose.yaml # 部署编排(含配置挂载)
├── compose.build.yaml # 打包编排
├── docker-run.sh # 部署脚本
├── .env # 环境变量配置
├── artifacts/ # 打包制品目录
├── config/ # 配置文件目录
│ └── [项目原有配置文件]
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
├── compose.yaml # 部署编排(含配置挂载)
├── compose.build.yaml # 打包编排
├── docker-run.sh # 部署脚本
├── .env # 环境变量配置
├── artifacts/ # 打包制品目录
├── config/ # 配置文件目录
│ └── [项目原有配置文件]
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
├── compose.yaml # 部署编排(含配置挂载)
├── compose.build.yaml # 打包编排
├── docker-run.sh # 部署脚本
├── .env # 环境变量配置
├── artifacts/ # 打包制品目录
├── config/ # 配置文件目录
│ └── [项目原有配置文件]
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
├── compose.yaml # 部署编排(含配置挂载)
├── compose.build.yaml # 打包编排
├── docker-run.sh # 部署脚本
├── .env # 环境变量配置
├── artifacts/ # 打包制品目录
├── config/ # 配置文件目录
│ └── [项目原有配置文件]
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
├── compose.yaml # 部署编排(含配置挂载)
├── compose.build.yaml # 打包编排
├── docker-run.sh # 部署脚本
├── .env # 环境变量配置
├── artifacts/ # 打包制品目录
├── config/ # 配置文件目录
│ └── [项目原有配置文件]
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
├── compose.yaml # 部署编排(含配置挂载)
├── compose.build.yaml # 打包编排
├── docker-run.sh # 部署脚本
├── .env # 环境变量配置
├── artifacts/ # 打包制品目录
├── config/ # 配置文件目录
│ └── [项目原有配置文件]
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
├── compose.yaml # 部署编排(含配置挂载)
├── compose.build.yaml # 打包编排
├── docker-run.sh # 部署脚本
├── .env # 环境变量配置
├── artifacts/ # 打包制品目录
├── config/ # 配置文件目录
│ └── [项目原有配置文件]
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
├── compose.yaml # 部署编排(含配置挂载)
├── compose.build.yaml # 打包编排
├── docker-run.sh # 部署脚本
├── .env # 环境变量配置
├── artifacts/ # 打包制品目录
├── config/ # 配置文件目录
│ └── [项目原有配置文件]
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# JWT_SECRET=your-secret-key
"""
env_path = os.path.join(project_path, 'deploy', '.env')
with open(env_path, 'w') as f:
f.write(env_content)
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
# JWT_SECRET=your-secret-key
"""
env_path = os.path.join(project_path, 'deploy', '.env')
with open(env_path, 'w') as f:
f.write(env_content)
The skill clearly instructs reading project files, writing deployment artifacts, and executing Docker commands, yet it declares no explicit tool scope or permissions boundaries. That mismatch increases the chance of overbroad execution in environments where tool access is policy-driven, and makes the skill harder to review safely.
The skill description says it will analyze code and docs but does not clearly warn that it may read environment templates and configuration files that can contain secrets or sensitive infrastructure details. Missing disclosure reduces informed consent and can cause operators to expose more data than expected during use.
The workflow creates multiple files under deploy/ but does not clearly warn users that existing files may be created or overwritten. In operational contexts, silent workspace modification can destroy local changes or introduce deployment artifacts that are later committed unintentionally.
The skill goes beyond planning and file generation by directing execution of docker compose ... up --build, which builds and starts code from the target project. In the context of an analysis/generation skill, automatically moving into build-and-run behavior can execute untrusted build steps, network fetches, post-install hooks, or service startup code with significant side effects.
The skill instructs copying original configuration files, including .env and app configs, into deploy/config/, which can duplicate live credentials, tokens, and internal endpoints into a broader, more portable directory. In a containerization skill, this is especially dangerous because deployment folders are often committed, shared, or packaged, increasing the chance of secret exposure.
The skill lacks a clear warning that it copies original configuration into a deployment directory, potentially duplicating secrets into a place that is easier to archive, commit, or share. In deployment-focused workflows, this materially raises accidental credential leakage risk.
No suspicious patterns detected.