/

CVE-2026-12048

Severity:

CRITICAL RISK

(9.3)

Stored XSS (CWE-79) in pgAdmin 4 UI rendering flows

CVE-2026-12048

Analyzed

Vulnerability type

Category:

Cross-Site Scripting (Stored)

CWE:

CWE-79, CWE-116

Impact:

Client-Side Code Execution and UI Phishing

Severity:

CRITICAL RISK

(9.3)

CVSS version:

3.1

Catch this CVE while code is being written

Detect vulnerable code directly in pull requests, so CVEs are fixed before merge.

Summary

pgAdmin 4 contains a stored cross-site scripting vulnerability where text returned from a PostgreSQL server is rendered as HTML in multiple UI components without sufficient sanitization.

An attacker who controls or can influence server-side object names or error messages can inject arbitrary HTML into the pgAdmin interface, enabling phishing and potential credential theft when a victim connects or views crafted query plans.

Affected context

The vulnerability arises in pgAdmin 4 installations that connect to PostgreSQL servers whose error messages, object identifiers, or EXPLAIN output can be influenced by an attacker.

Affected paths include error toasts, form help and error areas, modal alerts, SQL editor confirmations, and the Explain visualiser, where backend-supplied text was passed directly through html-react-parser into the DOM.

It typically occurs when a user connects pgAdmin to an untrusted or shared database instance, or when low-privilege users can create objects with crafted names that later surface in administrative workflows.

Exploit preconditions

  • Attack surface: Browser-based pgAdmin 4 web interface.
  • Required access: Ability to control or influence PostgreSQL server text returned to pgAdmin, such as:
  • Running a malicious or compromised PostgreSQL instance the victim connects to, or
  • Holding low-privilege access on a shared database where crafted table/column/index names, constraints, or other identifiers will appear in errors or EXPLAIN output.
  • Trigger point: Victim opens pgAdmin and:
  • Connects to the attacker-influenced server, or
  • Executes queries, EXPLAINs, or actions that surface crafted error messages or plan-node text in pgAdmin UI components.
  • Why exploitation is possible: Backend-derived text is treated as HTML and parsed with html-react-parser without robust sanitization or consistent escaping, allowing attacker-controlled markup (e.g., iframes) to be injected directly into the DOM.

Why this happens

This bug is rooted in rendering untrusted backend text as HTML in a rich client UI without enforcing a strict plain-text contract or robust sanitization.

Multiple React components in pgAdmin 4 used html-react-parser on strings received from PostgreSQL error messages and EXPLAIN metadata, effectively treating them as trusted HTML fragments.

Because these strings could contain attacker-controlled content such as crafted object names, the pattern matches CWE-79: Improper Neutralization of Input During Web Page Generation (Cross-Site Scripting), with CWE-116: Improper Encoding or Escaping of Output as a contributing factor.

The insecure pattern is the assumption that server-sent "messages" are safe for HTML rendering, instead of encoding them as plain text or sanitizing them before insertion into the DOM.

Potential impact

  • Attackers can inject arbitrary HTML elements into the pgAdmin interface.
  • Malicious iframes can render phishing pages that visually mimic pgAdmin dialogs and workflows.
  • Users can be tricked into entering credentials or sensitive data into attacker-controlled pages displayed inside the pgAdmin tab.
  • The injected content can redirect the top-level pgAdmin browser tab to attacker-controlled URLs, facilitating credential theft or broader account compromise.
  • Users' trust in administrative output (errors, EXPLAIN plans, confirmations) can be abused to drive targeted social-engineering attacks.

General mitigation guidance

Effective mitigation focuses on treating all backend-derived text as untrusted and enforcing a strict separation between data and presentation:

  • Prefer plain-text rendering contracts for error messages, plan metadata, and server-side messages; encode content so it cannot be interpreted as HTML or script.
  • Use context-appropriate escaping on all output derived from database identifiers, error messages, or logs before they reach the UI layer, aligning with HTML escaping rules.
  • Where HTML rendering is truly necessary, apply well-maintained sanitization libraries (e.g., DOMPurify-style filters) around every parse or injection point, with a conservative allowlist.
  • Introduce UI components that distinguish between trusted HTML and untrusted text (e.g., SafeMessage vs. SafeHtmlMessage) and make the safe variant the default.
  • Reduce privileges and trust in connected database instances; avoid connecting administrative tools to untrusted or user-controlled servers without strong isolation.
  • Apply defense-in-depth by sanitizing and escaping at both backend generators and frontend renderers, ensuring external consumers (logs, APIs, dashboards) never see raw markup.

How teams detect issues like this

Teams can identify similar vulnerabilities using layered detection approaches:

  • Static analysis and code search:
  • Scan for uses of HTML rendering helpers (html-react-parser, dangerouslySetInnerHTML, or equivalent) that accept unvalidated or unescaped server data.
  • Flag UI components that render error messages, EXPLAIN output, or object names without explicit encoding or sanitization.
  • Code review practices:
  • Require reviewers to trace the origin of any string that reaches an HTML sink, verifying encoding and sanitization paths.
  • Establish patterns where message rendering must go through safe abstractions (e.g., SafeMessage components or escape helpers) and treat bypasses as security issues.
  • Security testing:
  • Fuzz error messages and database object names with harmless HTML markers (e.g., unique tags or attributes) and verify whether they appear interpreted in the DOM.
  • Use browser DevTools or automated UI tests to detect unescaped markup in rendered output.
  • Policy and tooling:
  • Integrate secure coding rules into CI to block unreviewed use of raw HTML rendering APIs.
  • Optionally employ SAST/DAST tools capable of tracking tainted data from database responses into client-side HTML sinks.

Sources

SourceLink
github.comgithub.com/pgadmin-org/pgadmin4/commit/9e370d3cb67b83b3945f82969c959fad3f926517
github.comgithub.com/pgadmin-org/pgadmin4/issues/10068

Frequently asked

questions

Yes. Exploitation typically occurs when a victim's browser connects via pgAdmin 4 to a PostgreSQL server whose messages or object names an attacker can influence, including multi-tenant or shared database environments.

The attacker needs the ability to control or significantly influence the PostgreSQL server's textual responses, such as by operating a malicious server or having low-privilege database access to create objects with crafted names that surface in errors or EXPLAIN output.

The safest approach is to treat all backend-supplied text as untrusted data, escape it on the backend, and render it as plain text by default in the UI, only passing content through a well-audited sanitization layer when rich HTML is absolutely required.

Adopt a consistent output-encoding strategy, use dedicated safe rendering components for server messages, enforce coding guidelines that prohibit direct HTML rendering of untrusted strings, and integrate automated checks so any introduction of new raw HTML sinks is reviewed under a security lens.

Find out what's already
exploitable in your codebase.