Skip to content
Path traversal Write-up Advanced

pgAdmin (<=8.3) Path Traversal in Session Handling Leads to Unsafe Deserialization and Remote Code Execution (RCE)

pgAdmin 8.3 and earlier deserialises session files from a path built from the user-controlled session cookie, allowing path traversal. On Windows an unauthenticated attacker can point the cookie to a remote SMB share and execute code; on Linux an authenticated user can upload a malicious pickle file and execute code.

shielder.com

Published on shielder.com

pgAdmin <= 8.3 is affected by a path-traversal vulnerability while deserializing users’ sessions in the session handling code. If the server is running on Windows, an unauthenticated attacker can load and deserialize remote pickle objects and gain code execution.

The author, on shielder.com

The full write-up lives on its author's site

It belongs to its author, so we link to it rather than copy it. The other two tabs are our own rewrites, checked against it.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

How it worked

Root cause

The session manager joins the sessions directory with the user-controlled session ID using os.path.join, which allows absolute paths or traversal sequences to escape the intended directory, and then deserialises the resulting file with pickle.load.

Impact

An attacker could execute arbitrary code on the pgAdmin server; on Windows this is pre-authentication via a UNC path, while on Linux it requires a valid account to upload the malicious pickle file.

What the attacker needed

Windows: no account needed, SMB share reachable; Linux: valid pgAdmin account; Ability to host a malicious pickle file

How it was found

  1. Set up an SMB share or HTTP server hosting a malicious pickle file.
  2. Deploy pgAdmin4 on Windows or Linux.
  3. For Windows, visit the login page and change the pga4_session cookie to a UNC path pointing to the SMB share.
  4. For Linux, log in, upload the pickle file via Storage Manager, and change the cookie to a relative path to the uploaded file.
  5. Observe the server fetching the file and making an HTTP request, confirming code execution.

Explained by bugbounty.wiki with AI from the original and checked against quotes from it; it can still be wrong. Read the original before relying on a detail.

Not written yet. The AI write-up for this write-up has not been written yet. The Original tab links to the source.

pgAdmin stores login sessions as files on disk and reads them back using a cookie value. Because the cookie value is used to build a file path without checking it stays inside the sessions folder, an attacker can make the server read a file from anywhere, including a malicious file they control. When the server loads that file it runs code hidden inside it, giving the attacker control of the server.

What is Path traversal?

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.

Similar reports

View all

Same bug class and techniques, clearest first.

Path traversal and file inclusion

The lesson behind this report.

Input that builds a file path escapes the intended folder, reading or writing files the application should never touch.