/

CVE-2026-116241

Severity:

CRITICAL RISK

(9.9)

OS Command Injection (CWE-78) in pgAdmin 4 Import Tool

CVE-2026-116241

Analyzed

Vulnerability type

Category:

OS Command Injection

CWE:

CWE-78, CWE-115

Impact:

Remote Code Execution on the pgAdmin Host

Severity:

CRITICAL RISK

(9.9)

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

A critical command-injection vulnerability in pgAdmin 4's Import/Export Data tool can allow a database user to cause operating-system commands to run on the host running pgAdmin.

The risk arises when crafted query text, database session settings, and mismatched quote parsing cause a command clause to escape the tool's intended export wrapper. The command executes with the privileges of the operating-system account running pgAdmin.

A critical command-injection vulnerability in pgAdmin 4's Import/Export Data tool can allow a database user to cause operating-system commands to run on the host running pgAdmin.

The risk arises when crafted query text, database session settings, and mismatched quote parsing cause a command clause to escape the tool's intended export wrapper. The command executes with the privileges of the operating-system account running pgAdmin.

Affected context

The issue affects pgAdmin 4 deployments using the Import/Export Data tool before version 9.19, particularly where non-administrative database roles have that permission. It occurs when pgAdmin validates query quoting differently from the psql parser and relies on connection-specific escape behavior that cannot be determined safely during validation.

The exposure is greater when pgAdmin runs with broad operating-system privileges or has access to sensitive files, credentials, networks, or other administrative services.

The issue affects pgAdmin 4 deployments using the Import/Export Data tool before version 9.19, particularly where non-administrative database roles have that permission. It occurs when pgAdmin validates query quoting differently from the psql parser and relies on connection-specific escape behavior that cannot be determined safely during validation.

The exposure is greater when pgAdmin runs with broad operating-system privileges or has access to sensitive files, credentials, networks, or other administrative services.

Exploit preconditions

  • Attack surface: pgAdmin 4's Import/Export Data query handling and its host-side psql invocation
  • Required access: A database role able to use the Import/Export Data tool; administrative database privileges are not inherently required
  • Trigger point: Processing and execution of an export query wrapped in a psql copy command
  • Relevant condition: The database session can use a setting that changes backslash and quote interpretation, such as disabling standard-conforming strings
  • Why exploitation is possible: pgAdmin's delimiter validation can disagree with psql's parser, allowing syntax that was considered inside the wrapper to be interpreted as a separate command clause by psql
  • Attack surface: pgAdmin 4's Import/Export Data query handling and its host-side psql invocation
  • Required access: A database role able to use the Import/Export Data tool; administrative database privileges are not inherently required
  • Trigger point: Processing and execution of an export query wrapped in a psql copy command
  • Relevant condition: The database session can use a setting that changes backslash and quote interpretation, such as disabling standard-conforming strings
  • Why exploitation is possible: pgAdmin's delimiter validation can disagree with psql's parser, allowing syntax that was considered inside the wrapper to be interpreted as a separate command clause by psql

Why this happens

The underlying bug is a parser differential caused by incomplete validation of backslashes in double-quoted identifiers. pgAdmin treated an escaped double quote as terminating an identifier, while psql applied the connection's escape rules to the quote that opened the token and interpreted the identifier differently.

This mismatch allowed a closing delimiter to evade pgAdmin's wrapper check and enabled command execution through a psql command clause. The issue maps primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command, with CWE-115: Mis-categorization of Errors relevant to the flawed interpretation and validation of structured input.

The underlying bug is a parser differential caused by incomplete validation of backslashes in double-quoted identifiers. pgAdmin treated an escaped double quote as terminating an identifier, while psql applied the connection's escape rules to the quote that opened the token and interpreted the identifier differently.

This mismatch allowed a closing delimiter to evade pgAdmin's wrapper check and enabled command execution through a psql command clause. The issue maps primarily to CWE-78: Improper Neutralization of Special Elements used in an OS Command, with CWE-115: Mis-categorization of Errors relevant to the flawed interpretation and validation of structured input.

Potential impact

  • An attacker may execute operating-system commands on the pgAdmin host
  • The attacker could access, modify, or destroy files available to the pgAdmin account
  • The compromise could expose database credentials, configuration data, or exported records
  • The attacker may pivot to connected database systems, cloud services, or internal networks
  • The incident could result in data theft, tampering, persistence, or service disruption
  • An attacker may execute operating-system commands on the pgAdmin host
  • The attacker could access, modify, or destroy files available to the pgAdmin account
  • The compromise could expose database credentials, configuration data, or exported records
  • The attacker may pivot to connected database systems, cloud services, or internal networks
  • The incident could result in data theft, tampering, persistence, or service disruption

General mitigation guidance

Mitigation generally focuses on eliminating shell-sensitive command construction and ensuring that every parser involved in validation and execution follows the same safe grammar.

Common defensive patterns include:

  • Rejecting backslashes and other parser-sensitive characters in quoted identifiers and string contexts when their meaning depends on server settings
  • Avoiding construction of shell or psql command text from user-controlled query content
  • Using structured APIs with explicit argument separation instead of command-string composition
  • Applying strict allowlists and grammar-aware validation before invoking host-side tools
  • Granting Import/Export Data permissions only to roles that require them
  • Running pgAdmin under a dedicated, least-privileged operating-system account with restricted filesystem and network access
  • Keeping sensitive credentials out of the pgAdmin process environment and accessible files

Mitigation generally focuses on eliminating shell-sensitive command construction and ensuring that every parser involved in validation and execution follows the same safe grammar.

Common defensive patterns include:

  • Rejecting backslashes and other parser-sensitive characters in quoted identifiers and string contexts when their meaning depends on server settings
  • Avoiding construction of shell or psql command text from user-controlled query content
  • Using structured APIs with explicit argument separation instead of command-string composition
  • Applying strict allowlists and grammar-aware validation before invoking host-side tools
  • Granting Import/Export Data permissions only to roles that require them
  • Running pgAdmin under a dedicated, least-privileged operating-system account with restricted filesystem and network access
  • Keeping sensitive credentials out of the pgAdmin process environment and accessible files

How teams detect issues like this

Detection can combine source review, runtime monitoring, and authorization analysis:

  • Use static analysis to identify concatenation of user-controlled SQL or query text into shell, psql, or command-execution arguments
  • Review code for custom quote, parenthesis, or delimiter balancing that differs from the parser used for execution
  • Flag validation logic whose behavior depends on database session settings that are not fixed or known
  • Monitor pgAdmin child-process creation, especially unexpected psql command arguments and host-level process launches
  • Audit Import/Export Data permissions and investigate unusual export activity by low-privilege roles
  • Enforce code-review and automated security rules for command injection and parser-differential patterns

Detection can combine source review, runtime monitoring, and authorization analysis:

  • Use static analysis to identify concatenation of user-controlled SQL or query text into shell, psql, or command-execution arguments
  • Review code for custom quote, parenthesis, or delimiter balancing that differs from the parser used for execution
  • Flag validation logic whose behavior depends on database session settings that are not fixed or known
  • Monitor pgAdmin child-process creation, especially unexpected psql command arguments and host-level process launches
  • Audit Import/Export Data permissions and investigate unusual export activity by low-privilege roles
  • Enforce code-review and automated security rules for command injection and parser-differential patterns

Sources

SourceLink
github.comgithub.com/pgadmin-org/pgadmin4/commit/9be31a019f780647fb689c458408c8803263c812
github.comgithub.com/pgadmin-org/pgadmin4/issues/10663

Frequently asked

questions

It can be exploitable through a pgAdmin deployment when an attacker can access the Import/Export Data functionality and influence the relevant database session or query processing. The final impact depends on how pgAdmin is exposed and what network and operating-system privileges it has.

No. The affected permission may be available to non-administrative database roles, so authorization should be reviewed even where database administrative privileges are restricted.

Use a parser-safe implementation that rejects ambiguous backslash handling, avoids composing executable command strings from query text, and passes data through structured interfaces rather than shell-like command construction.

Keep validation and execution grammars aligned, treat database-controlled settings as untrusted inputs, minimize Import/Export permissions, and run administrative web tools with strong operating-system isolation and least privilege.

It can be exploitable through a pgAdmin deployment when an attacker can access the Import/Export Data functionality and influence the relevant database session or query processing. The final impact depends on how pgAdmin is exposed and what network and operating-system privileges it has.

No. The affected permission may be available to non-administrative database roles, so authorization should be reviewed even where database administrative privileges are restricted.

Use a parser-safe implementation that rejects ambiguous backslash handling, avoids composing executable command strings from query text, and passes data through structured interfaces rather than shell-like command construction.

Keep validation and execution grammars aligned, treat database-controlled settings as untrusted inputs, minimize Import/Export permissions, and run administrative web tools with strong operating-system isolation and least privilege.

Find out what's already
exploitable in your codebase.