🇰🇷 한글 설명
pgAdmin 4의 오류 렌더링 및 실행 계획 노드 렌더링 경로에서 저장형 XSS 취약점이 발견되었습니다. 공격자가 제어하는 PostgreSQL 서버가 악의적인 텍스트를 반환할 경우, pgAdmin 인터페이스 내에 임의의 HTML 및 스크립트가 삽입되어 피싱 공격이나 세션 탈취가 가능합니다.
💡 쉬운 설명
데이터베이스가 보내는 메시지를 pgAdmin이 검증 없이 화면에 그대로 보여주면서 발생하는 문제입니다. 해커가 만든 가짜 메시지를 통해 사용자의 정보를 훔치거나 가짜 로그인 창을 띄울 수 있습니다.
🇺🇸 원문 (English)
Stored cross-site scripting in pgAdmin 4's error-rendering and plan-node-rendering paths. Text returned by a PostgreSQL server (ErrorResponse messages, including object names quoted back inside relation-does-not-exist errors and inside EXPLAIN Recheck Cond / Exact Heap Blocks fields) was passed verbatim through html-react-parser at every user-facing sink — the notifier toasts, FormFooterMessage / FormInput help and error areas, FormNote, ModalProvider AlertContent and confirmDelete, ToolErrorView, the Explain visualiser's NodeText panel, the SQL editor confirm dialogs, ConfirmSaveContent, PreferencesHelper modal alerts, and SelectThemes helper text. A PostgreSQL server an attacker controls — or any server returning attacker-influenced text such as a table or column name a low-privilege database user can create — could inject arbitrary HTML (including <iframe>) into the pgAdmin DOM the moment the victim's pgAdmin connected to that server or viewed an Explain plan that referenced the crafted object.
The injected iframe's srcdoc could fetch attacker-served JavaScript and, by writing to parent.location, redirect the victim's top-level pgAdmin browser tab to an attacker-controlled URL. Because the injection originates from inside pgAdmin's own interface, standard anti-clickjacking controls (X-Frame-Options, Content-Security-Policy: frame-ancestors) do not mitigate it. A phishing page rendered inside the legitimate pgAdmin window is indistinguishable from a genuine pgAdmin dialog.
Fix combines three complementary layers. (1) DOMPurify sanitisation is wrapped around every html-react-parser call site reachable from notifier, alert, form-error, Explain, and SQL-editor flows. (2) A new plain-text rendering contract — SafeMessage / SafeHtmlMessage components plus Notifier.errorText / alertText / warningText / infoText / successText helpers — is introduced; around fifty callers across browser, tools, dashboard, debugger, misc, llm, preferences, schema diff, and the SQL editor that previously interpolated backend-derived strings are migrated to the plain-text variants. (3) Backend HTML-escape is applied at the post-connection-SQL handler (execute_post_connection_sql) via a new sanitize_external_text helper, so third-party JSON consumers (audit logs, API clients) never receive raw markup either; the Explain plan-info renderer is also patched to _.escape Recheck Cond and Exact Heap Blocks at construction (matching every sibling field), giving defence in depth even before DOMPurify runs.
This issue affects pgAdmin 4: from 6.0 before 9.16.
📍 영향받는 시스템
pgAdmin 4 버전 6.0부터 9.16 미만 버전
⚔️ 공격 벡터
공격자가 제어하는 PostgreSQL 서버를 통해 악의적인 객체 이름이나 오류 메시지를 pgAdmin에 전달하여 스크립트 실행
🛡️ 대응 방법
pgAdmin 4를 최신 버전(9.16 이상)으로 업데이트하여 DOMPurify 적용 및 텍스트 렌더링 보안 패치 적용
🔧 검증 코드
출력된 버전이 9.16 미만인 경우 해당 취약점에 노출된 상태입니다.
pip show pgadmin4 2>/dev/null | grep Version || python3 -c 'import pgadmin4; print(pgadmin4.__version__)' 2>/dev/null || echo 'Version check failed'