Summary
A broken access control vulnerability in pgAdmin 4 server mode allows authenticated users to access and manipulate other users' private servers, server groups, background processes, and debugger data by guessing object identifiers.
Flaws in the Shared Servers feature further expose connection credentials, enable privilege escalation via writable connection commands, and permit corruption of owner data, making multi-user deployments particularly at risk.
Affected context
This vulnerability arises in pgAdmin 4 when it is deployed in server mode as a multi-user web application.
It affects:
- User-owned objects: Server Groups, Servers, Shared Servers
- Operational objects: Background Processes, Debugger modules and function argument views
The issue manifests where:
- API endpoints and internal handlers fetch objects by ID but do not constrain queries to the requesting user's identity
- Shared Servers state and metadata are stored in a way that is not properly scoped per-user
- Owner-only fields are exposed or writable to non-owners through the API and merge logic
Single-user desktop mode deployments are much less exposed, while shared or multi-tenant pgAdmin instances are at significant risk.
Exploit preconditions
- Attack surface: HTTP API endpoints and web UI actions of pgAdmin 4 when running in server mode.
- Required access: Any authenticated pgAdmin user account; no elevated role is necessary.
- Knowledge required: Ability to guess or enumerate numeric or opaque object IDs for:
- Server Groups
- Servers and Shared Servers
- Background Processes
- Debugger targets and function argument records
- Trigger points:
- Calling object-detail or mutation endpoints with another user's object ID
- Editing Shared Servers fields (e.g.,
passexec_cmd,passfile,tags,post_connection_sql) - Initiating connections that cause
passexec_cmdto execute - Why exploitation is possible:
- Object fetches and updates are not consistently filtered by
owner == requesting_user - Shared Servers metadata mixes per-owner and shared state without proper isolation
- Owner-only fields are exposed in responses or accepted in writes from non-owners
- SQLAlchemy sessions are shared such that non-owner edits mutate owner-backed records
Why this happens
The core bug class is broken access control for user-scoped resources.
Multiple layers of pgAdmin 4 server mode treat object identifiers (IDs) as sufficient authority, rather than verifying that the current authenticated user actually owns or is entitled to access the referenced object.
Concretely, this maps to CWE-284: Improper Access Control:
- Query paths retrieve Server Groups, Servers, Background Processes, and Debugger-related entities without applying a user filter.
- The Shared Servers feature exposes and accepts writes to fields that are intended to be owner-only, such as
passexec_cmd,passexec_expiration,db_res, anddb_res_type. - Certain fields (
kerberos_conn,tags,post_connection_sql) are not persisted in a per-user fashion; instead, updates from any user mutate a shared SQLAlchemy session object that backs the owner's data.
Because identity checks and ownership scoping were scattered and inconsistent, privilege boundaries between users eroded:
- Data that should be private becomes visible when only ID knowledge is required.
- Write operations on shared objects are not constrained by ownership, enabling privilege escalation and state corruption.
Potential impact
- Unauthorized access to another user's private Servers and Server Groups within pgAdmin.
- Exposure of sensitive connection data, including:
passfilereferences and SSL key metadatapassexec_cmdand related credential-handling commands- Arbitrary command execution in the context of the owning user's pgAdmin process via a writable
passexec_cmdexecuted on connection. - Unauthorized manipulation of Shared Server configuration, including:
- Changing
post_connection_sqlto run attacker-chosen SQL on target databases. - Tampering with
kerberos_connand other connection attributes. - Data corruption of owner-controlled resources resulting from SQLAlchemy session mutations (e.g., altered tags, connection parameters, and runtime result metadata).
- Lateral movement opportunities within a shared administrative environment if compromised servers provide access to production databases.
General mitigation guidance
Effective mitigation centers on consistent user scoping, least-privilege access, and hardening shared features:
- Centralize Access Control:
- Implement a dedicated access control layer responsible for enforcing ownership and permissions checks for all user-owned models.
- Ensure every read and write operation routes through this layer, rather than relying on ad hoc checks in individual endpoints.
- User-Scoped Data Models:
- Introduce explicit user scoping on all objects that are conceptually "owned" (e.g., via a mixin or base class that automatically filters queries by the current user).
- Make "owner" a first-class property, and ensure ORM queries carry this constraint by default.
- Owner-Only Fields and Views:
- Classify fields as:
- Owner-visible and owner-writable
- Shared-visible but owner-writable only
- Strictly owner-private (not exposed to other users in any representation)
- Strip or redact owner-only fields from API responses and view models for non-owners.
- Safe Shared Feature Design (Shared Servers):
- Avoid executing arbitrary shell commands from user-modifiable fields.
- Where command execution is necessary, support only controlled, parameterized actions with input validation and clear privilege boundaries.
- Store any secret-bearing or security-sensitive configuration in private, owner-only structures.
- Session and State Isolation:
- Prevent shared ORM or in-memory objects from being mutated by non-owners in ways that persist back to owner records.
- Use per-user sessions or carefully controlled transaction boundaries for shared features.
- Principle of Least Privilege:
- Run pgAdmin components with minimal OS-level privileges required to perform their tasks.
- Avoid configurations where
passexec_cmdor similar mechanisms run as highly privileged users.
These patterns reduce the risk that future features will unintentionally bypass ownership boundaries or expose cross-user state.
How teams detect issues like this
Detection should focus on both code-level patterns and runtime signals:
- Static Analysis & Code Review:
- Search for ORM queries on user-owned models that do not filter by a user or owner field.
- Flag controller or view code that:
- Accepts object IDs from clients and fetches records without verifying ownership.
- Exposes sensitive fields (commands, credentials, keys) in JSON or HTML responses.
- Add linting rules or custom static checks for:
- "Fetch-by-ID without owner filter" patterns.
- Methods that permit writing to owner-only fields from generic request contexts.
- Access Control Policy Checks:
- Implement tests and CI checks that:
- Log in as multiple distinct users and ensure cross-user object access is denied.
- Attempt to read and modify Shared Server fields as non-owners, asserting failure.
- Use automated security testing frameworks to fuzz object IDs and verify no cross-tenant leakage occurs.
- Runtime Monitoring & Logging:
- Record audit logs for:
- Access to private server configurations and Shared Servers.
- Updates to sensitive fields such as
passexec_cmd,post_connection_sql, and credential-related properties. - Monitor for unusual patterns such as:
- Multiple users accessing the same supposedly private server ID.
- Repeated 4xx/5xx responses around object ID probing, which may indicate ID enumeration attempts.
- Periodic Security Review:
- Regularly review new features that handle user-owned resources to ensure they integrate with centralized access control mechanisms rather than implementing bespoke checks.

