T05 · Unauthorized Access and Privilege Escalation
- Location
scripts/generate-setup-guide.py:271- Finding
Unauthenticated Docker Remote API Exposure
- Content
View full analysis
- Remediation
View remediation
Security audit
Security checks for vulnerabilities and agentic risk
The skill is a coherent CI/CD template generator, but it includes unsafe production deployment guidance that can grant root-equivalent access if followed.
Review before installing. Use this only as a starting point, not as production-ready CI/CD security guidance. Remove Docker TCP exposure, avoid host docker.sock and privileged runners for general jobs, remove deploy-user sudo-group membership, validate and quote generated project names, pin images, use least-privilege Kubernetes credentials, protect production deployments with approvals, and handle kubeconfig material through secure CI secret mechanisms.
scripts/generate-setup-guide.py:271Unauthenticated Docker Remote API Exposure
scripts/generate-setup-guide.py:134Deployment User Receives Unnecessary Full Sudo Membership
scripts/generate-setup-guide.py:430CI Runner Configuration Grants Host-Equivalent Privileges
scripts/generate-setup-guide.py:146Command Injection Through Unvalidated Project Name
scripts/notify.sh:58Unescaped Build Metadata Is Embedded in Webhook JSON
assets/gitlab-ci.yml:204Kubernetes Credential Is Written Without Explicit Secure Permissions
assets/gitlab-ci.yml:204CI and Production Images Use Mutable Unpinned Tags
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
// K8s 配置
K8S_NAMESPACE = 'production'
KUBE_CONFIG_ID = 'kubeconfig'
// 版本标签
IMAGE_TAG = "${BUILD_NUMBER}-${GIT_COMMIT?.take(7) ?: 'unknown'}"
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
// K8s 配置
K8S_NAMESPACE = 'production'
KUBE_CONFIG_ID = 'kubeconfig'
// 版本标签
IMAGE_TAG = "${BUILD_NUMBER}-${GIT_COMMIT?.take(7) ?: 'unknown'}"
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
// K8s 配置
K8S_NAMESPACE = 'production'
KUBE_CONFIG_ID = 'kubeconfig'
// 版本标签
IMAGE_TAG = "${BUILD_NUMBER}-${GIT_COMMIT?.take(7) ?: 'unknown'}"
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
// K8s 配置
K8S_NAMESPACE = 'production'
KUBE_CONFIG_ID = 'kubeconfig'
// 版本标签
IMAGE_TAG = "${BUILD_NUMBER}-${GIT_COMMIT?.take(7) ?: 'unknown'}"
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
// K8s 配置
K8S_NAMESPACE = 'production'
KUBE_CONFIG_ID = 'kubeconfig'
// 版本标签
IMAGE_TAG = "${BUILD_NUMBER}-${GIT_COMMIT?.take(7) ?: 'unknown'}"
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
// K8s 配置
K8S_NAMESPACE = 'production'
KUBE_CONFIG_ID = 'kubeconfig'
// 版本标签
IMAGE_TAG = "${BUILD_NUMBER}-${GIT_COMMIT?.take(7) ?: 'unknown'}"
Piping file paths from find output through xargs rm -f is unsafe because whitespace, special characters, or crafted filenames can cause incorrect parsing and deletion of unintended files. In a build pipeline processing repository-controlled content, an attacker could create maliciously named files that alter removal behavior or damage artifacts/workspace contents.
echo "❌ Security violation found:"
echo "$VIOLATIONS"
echo "Removing violation files..."
echo "$VIOLATIONS" | xargs rm -f
fi
echo "✅ Vue build check passed"
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
}
steps {
script {
withCredentials([file(credentialsId: "${KUBE_CONFIG_ID}", variable: 'KUBECONFIG')]) {
sh """
# 验证 kubectl 连接
kubectl cluster-info
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
image: bitnami/kubectl:latest
script:
# 配置 K8s 访问
- echo "$KUBE_CONFIG" | base64 -d > ~/.kube/config
- kubectl config use-context $K8S_CLUSTER
# 更新镜像版本
The section header introducing kubeconfig upload is not dangerous by itself, but in context it normalizes moving powerful cluster credentials into Jenkins without discussing minimization or handling safeguards. In CI/CD guidance, omission of those warnings increases the risk of overprivileged, widely accessible secrets.
--namespace=production
```
#### 4. 上传 Kubeconfig 到 Jenkins
```bash
# 复制 kubeconfig 内容
cat ~/.kube/config | base64
This line labels the action as copying kubeconfig content, which contributes to insecure secret-handling practices. The danger is contextual: users may expose raw credential material while following the documented workflow.
#### 4. 上传 Kubeconfig 到 Jenkins
```bash
# 复制 kubeconfig 内容
cat ~/.kube/config | base64
# 在 Jenkins 中创建 credentials:
cat ~/.kube/config | base64 encourages direct handling and transformation of a sensitive kubeconfig in a terminal workflow. Kubeconfig files often contain bearer tokens, client certificates, or cluster-admin credentials; exposing them in shell history, scrollback, copy/paste buffers, or support artifacts can enable unauthorized cluster access.
#### 4. 上传 Kubeconfig 到 Jenkins
```bash
# 复制 kubeconfig 内容
cat ~/.kube/config | base64
# 在 Jenkins 中创建 credentials:
# Kind: Secret file
Telling users to paste base64 content as a Jenkins secret file risks mishandling, accidental logging, and broad credential distribution, especially if the kubeconfig is overprivileged. The skill context makes this more dangerous because it is prescriptive operational guidance likely to be copied verbatim by users.
# 在 Jenkins 中创建 credentials:
# Kind: Secret file
# ID: kubeconfig
# File: 粘贴 base64 内容或上传文件
```
"""
The guide suggests configuring Docker to listen on tcp://0.0.0.0:2376 alongside the local socket, with no mention of TLS, firewalling, or authentication. Exposing the Docker API on all interfaces can allow remote attackers to start privileged containers, mount the host filesystem, steal secrets, and effectively gain root-level control of the machine.
添加:
```json
{{
"hosts": ["unix:///var/run/docker.sock", "tcp://0.0.0.0:2376"]
}}
```
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
```bash
# 1. 检查 Jenkins 服务器上的 SSH 密钥
sudo su - jenkins
cat ~/.ssh/id_rsa.pub
# 2. 确保公钥已添加到目标服务器的 authorized_keys
cat ~/.ssh/authorized_keys # 在目标服务器上
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
cat ~/.ssh/id_rsa.pub
# 2. 确保公钥已添加到目标服务器的 authorized_keys
cat ~/.ssh/authorized_keys # 在目标服务器上
# 3. 检查权限
chmod 700 ~/.ssh
Code accesses credential files (SSH keys, AWS credentials, etc.). This could indicate credential theft attempts.
cat ~/.ssh/id_rsa.pub
# 2. 确保公钥已添加到目标服务器的 authorized_keys
cat ~/.ssh/authorized_keys # 在目标服务器上
# 3. 检查权限
chmod 700 ~/.ssh
Mounting /var/run/docker.sock into the GitLab Runner container gives the container effective control over the host Docker daemon. If jobs or the runner are compromised, an attacker can launch privileged containers and escape into full host compromise.
```bash
docker run -d --name gitlab-runner --restart always \\
-v /srv/gitlab-runner/config:/etc/gitlab-runner \\
-v /var/run/docker.sock:/var/run/docker.sock \\
gitlab/gitlab-runner:latest
```
The pipeline can deploy directly to the production Kubernetes namespace on main/master or via FORCE_DEPLOY without any explicit approval gate at execution time. In CI/CD contexts, an automatic path to production increases the risk of accidental or unauthorized rollout of unreviewed code, especially if branch protections, webhook triggers, or parameter controls are weak.
The natural-language content in the file is presented in Chinese only, including key pipeline descriptions and section headers. This can violate a language/locale policy when a skill or artifact imposes a specific language without user opt-in or a documented regional justification.
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
image: alpine/curl:latest
script:
- |
curl -X POST "${WEBHOOK_URL}" \
-H "Content-Type: application/json" \
-d "{
\"msg_type\": \"text\",
Data is being sent to an external URL. This could be legitimate telemetry or data exfiltration. Manual review is recommended.
image: alpine/curl:latest
script:
- |
curl -X POST "${WEBHOOK_URL}" \
-H "Content-Type: application/json" \
-d "{
\"msg_type\": \"text\",
The Jenkins guide title and surrounding generated content are written in Chinese, and the GitLab guide follows the same pattern later in the file. This imposes a specific language on all users with no opt-in or documented locale constraint, which matches the language/locale policy violation category.
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
#### 1. 创建部署用户
```bash
# 创建 deploy 用户
sudo useradd -m -s /bin/bash deploy
# 设置密码(可选,如果使用密钥认证)
sudo passwd deploy
Commands invoke sudo or root privileges. Verify this elevated access is necessary and justified.
#### 1. 创建部署用户
```bash
# 创建 deploy 用户
sudo useradd -m -s /bin/bash deploy
# 设置密码(可选,如果使用密钥认证)
sudo passwd deploy
No suspicious patterns detected.