🇰🇷 한글 설명
PostgreSQL의 pg_dump, pg_dumpall, pg_restore, pg_upgrade에서 object name 내의 newline 문자가 적절히 무효화되지 않아, 악의적으로 조작된 object name을 통해 psql 메타명령어를 주입할 수 있습니다. 이를 통해 복원 시점에 클라이언트 시스템 계정으로 임의 코드를 실행하거나 superuser 권한으로 SQL injection을 수행할 수 있습니다.
💡 쉬운 설명
PostgreSQL 백업 도구에서 특수한 문자를 담은 이름의 객체를 만들면, 백업 복원 시 공격자가 원하는 명령어를 실행할 수 있습니다. 이는 클라이언트 컴퓨터 전체가 해킹되거나 데이터베이스의 모든 권한을 탈취할 수 있는 심각한 취약점입니다.
🇺🇸 원문 (English)
Improper neutralization of newlines in pg_dump in PostgreSQL allows a user of the origin server to inject arbitrary code for restore-time execution as the client operating system account running psql to restore the dump, via psql meta-commands inside a purpose-crafted object name. The same attacks can achieve SQL injection as a superuser of the restore target server. pg_dumpall, pg_restore, and pg_upgrade are also affected. Versions before PostgreSQL 17.6, 16.10, 15.14, 14.19, and 13.22 are affected. Versions before 11.20 are unaffected. CVE-2012-0868 had fixed this class of problem, but version 11.20 reintroduced it.
📍 영향받는 시스템
PostgreSQL 13.22 이전, 14.19 이전, 15.14 이전, 16.10 이전, 17.6 이전 (11.20 이상 12.x 는 영향 없음)
⚔️ 공격 벡터
악의적인 object name(newline + psql 메타명령어 포함)을 가진 데이터베이스 객체 생성 후 pg_dump 유도, restore 시 주입된 명령어 자동 실행
🛡️ 대응 방법
PostgreSQL을 13.22, 14.19, 15.14, 16.10, 17.6 이상으로 즉시 업그레이드
🔧 검증 코드
SAFE가 출력되면 패치된 버전, VULNERABLE이 출력되면 긴급 업그레이드 필요
psql --version | grep -oE '[0-9]+\.[0-9]+' | awk -F. '{if($1==13 && $2>=22 || $1==14 && $2>=19 || $1==15 && $2>=14 || $1==16 && $2>=10 || $1==17 && $2>=6 || $1>17) print "SAFE"; else print "VULNERABLE"}'