CVE-2025-13780 – Database Restore Tool Command Injection in pgAdmin

Vulnerable Version

pgAdmin 4 versions prior to 9.11

Fixed Version

pgAdmin 4 v9.11

Base Score

9.1 Critical

Vendor Discription:-

pgAdmin is a widely used open-source administration and development tool for PostgreSQL, one of the most sophisticated relational database systems. It provides a graphical interface for database management operations such as database creation and management, SQL query execution, user, role, and permission management, and data structure visualization. Designed for both new and experienced developers, pgAdmin includes advanced capabilities such as debugging, performance monitoring, and database design tools. It may be accessible through a web browser, making it easy to manage both local and distant PostgreSQL servers.

CVE-2025-13780 Description:-

CVE-2025-13780 is a critical remote code execution (RCE) vulnerability affecting pgAdmin 4, arising from insecure handling of plain-text database restore operations.

The vulnerability originates from pgAdmin 4’s plain-text restore feature, which relies on the psql client to process user-supplied SQL dump files. When a PLAIN-format dump is restored, pgAdmin launches the psql binary on the host system and passes the uploaded SQL file directly to it for execution.

The psql client supports a set of powerful meta-commands, prefixed with backslashes (\), which allow actions such as executing shell commands (\!), reading or writing files, and spawning external processes. If malicious meta-commands are included in a restore file, they can result in arbitrary command execution on the pgAdmin host system.

To mitigate this risk, pgAdmin implemented a regex-based security filter intended to detect and block dangerous psql meta-commands before invoking the restore process. This filter searched for backslashes at the beginning of lines, allowing only spaces and tabs as valid leading whitespace.

However, researchers discovered that this approach was fundamentally flawed. While the regex filter recognized only limited whitespace characters, psql itself accepts a much broader set of whitespace and line-break characters, including:

  • Carriage returns (\r)
  • Vertical tabs (\v)
  • Form feeds (\f)
  • Bare carriage returns between lines

By inserting these alternative whitespace characters between newlines and backslashes, an attacker can hide malicious meta-commands from the regex filter while still having them fully interpreted by psql.

The provided proof-of-concept demonstrates how carriage return characters can be used to bypass the filter entirely. When pgAdmin processes such a crafted SQL dump, the regex check fails to identify the meta-commands, but psql executes them normally. This mismatch between filter logic and interpreter behavior results in unauthenticated or authenticated remote code execution, depending on deployment configuration.

The vulnerability can be exploited through multiple whitespace variants, all of which are treated as valid by psql but ignored by the regex pattern. This creates a dangerous security gap caused by relying on application-level pattern matching instead of enforcing restrictions at the execution layer.

The pgAdmin development team addressed CVE-2025-13780 in pgAdmin version 9.11 by fundamentally changing the security model. Instead of attempting to sanitize input using fragile regex checks, pgAdmin now launches psql with the restricted mode directive, which disables dangerous meta-commands at the interpreter level.

This architectural change shifts enforcement from error-prone pre-filtering to native psql security controls, eliminating the need to track psql’s evolving grammar and whitespace handling rules.

Impact

CVE-2025-13780 is a critical remote code execution (RCE) vulnerability in pgAdmin 4 that can allow attackers to execute arbitrary system commands on the pgAdmin host.

By exploiting weaknesses in the plain-text restore feature, an attacker can inject malicious psql meta-commands that bypass input validation and are executed by the psql client. Successful exploitation may lead to:

  • Full compromise of the pgAdmin host system
  • Unauthorized access, modification, or exfiltration of database data
  • Privilege escalation and persistence on the affected server
  • Increased risk in multi-user or network-exposed pgAdmin deployments

Due to its low exploitation complexity and high impact, this vulnerability poses a severe security risk.

Mitigations

Primary Mitigation

  • Upgrade to pgAdmin 9.11 or later, which enforces psql restricted mode and prevents dangerous meta-command execution.

Additional Mitigations

  • Avoid or restrict plain-text (PLAIN) database restores.
  • Limit restore privileges to trusted administrators only.
  • Run pgAdmin with least-privileged system accounts.
  • Harden the host system and enable logging and monitoring for restore operations.
  • Isolate pgAdmin within a secured management network.

Leave a Reply

Your email address will not be published. Required fields are marked *