MariaDB Server 11.4.10 미만, 11.5.x ~ 11.8.6 미만, 12.x ~ 12.2.2 미만 버전
공격자가 'caching_sha2_password' 플러그인을 사용하는 사용자 계정으로 인증 요청을 보낼 때, 비정상적으로 큰 크기의 패킷을 전송하여 서버의 스택 메모리를 고갈시키고 프로세스를 충돌시킵니다.
MariaDB Server를 보안 패치가 적용된 최신 버전(11.4.10, 11.8.6, 12.2.2 또는 그 이상)으로 업데이트하십시오.
이 코드는 Python 3 환경에서 실행 가능합니다. MariaDB 서버가 설치된 Linux 시스템에서 실행해야 하며, `mariadb -V` 명령어와 `information_schema.plugins` 테이블에 접근할 수 있는 권한(예: root 권한 또는 .my.cnf 설정)이 필요합니다. 실행 전 `mariadb` 클라이언트 도구가 설치되어 있는지 확인하십시오.
import subprocess
import re
import json
def get_mariadb_version():
try:
result = subprocess.check_output(['mariadb', '-V'], stderr=subprocess.STDOUT).decode()
match = re.search(r'MariaDB (\d+\.\d+(\.\d+)?)', result)
return match.group(1) if match else None
except Exception:
return None
def is_plugin_enabled():
try:
# This requires the user to have access to the database without a password or via .my.cnf
cmd = ['mariadb', '-e', 'SELECT plugin_name FROM information_schema.plugins WHERE plugin_name = "caching_sha2_password";']
result = subprocess.check_output(cmd, stderr=subprocess.STDOUT).decode()
return 'caching_sha2_password' in result
except Exception:
return False
def compare_versions(current, fixed):
c_parts = [int(x) for x in current.split('.')]
f_parts = [int(x) for x in fixed.split('.')]
for i in range(min(len(c_parts), len(f_parts))):
if c_parts[i] < f_parts[i]: return True
if c_parts[i] > f_parts[i]: return False
return len(c_parts) < len(f_parts)
version = get_mariadb_version()
if not version:
print(json.dumps({"result": "양호", "reason": "MariaDB가 설치되어 있지 않거나 버전을 확인할 수 없습니다."}))
exit()
plugin_active = is_plugin_enabled()
# Vulnerability ranges
vulnerable = False
if version.startswith('11.4') and compare_versions(version, '11.4.10'):
vulnerable = True
elif version.startswith('11.5') or version.startswith('11.6') or version.startswith('11.7') or (version.startswith('11.8') and compare_versions(version, '11.8.6')):
vulnerable = True
elif version.startswith('12') and compare_versions(version, '12.2.2'):
vulnerable = True
if vulnerable and plugin_active:
print(json.dumps({"result": "취약", "reason": f"설치된 버전({version})이 취약한 범위에 있으며 caching_sha2_password 플러그인이 활성화되어 있습니다."}))
elif vulnerable:
print(json.dumps({"result": "양호", "reason": f"버전({version})은 취약 범위에 있으나, caching_sha2_password 플러그인이 사용되지 않고 있습니다."}))
else:
print(json.dumps({"result": "양호", "reason": f"설치된 버전({version})은 보안 패치가 적용된 버전입니다."}))
CVSS:3.1/AV:N/AC:L/PR:L/UI:N/S:U/C:N/I:N/A:H