Join the Cyber Forum: Threat Intel on May 12, 2026 to learn how AI is reshaping threat defense.Join the Virtual Cyber Forum: Threat IntelRegister Now
Experiencing a Breach?Blog
Get StartedContact Us
SentinelOne
  • Platform
    Platform Overview
    • Singularity Platform
      Welcome to Integrated Enterprise Security
    • AI for Security
      Leading the Way in AI-Powered Security Solutions
    • Securing AI
      Accelerate AI Adoption with Secure AI Tools, Apps, and Agents.
    • How It Works
      The Singularity XDR Difference
    • Singularity Marketplace
      One-Click Integrations to Unlock the Power of XDR
    • Pricing & Packaging
      Comparisons and Guidance at a Glance
    Data & AI
    • Purple AI
      Accelerate SecOps with Generative AI
    • Singularity Hyperautomation
      Easily Automate Security Processes
    • AI-SIEM
      The AI SIEM for the Autonomous SOC
    • AI Data Pipelines
      Security Data Pipeline for AI SIEM and Data Optimization
    • Singularity Data Lake
      AI-Powered, Unified Data Lake
    • Singularity Data Lake for Log Analytics
      Seamlessly Ingest Data from On-Prem, Cloud or Hybrid Environments
    Endpoint Security
    • Singularity Endpoint
      Autonomous Prevention, Detection, and Response
    • Singularity XDR
      Native & Open Protection, Detection, and Response
    • Singularity RemoteOps Forensics
      Orchestrate Forensics at Scale
    • Singularity Threat Intelligence
      Comprehensive Adversary Intelligence
    • Singularity Vulnerability Management
      Application & OS Vulnerability Management
    • Singularity Identity
      Identity Threat Detection and Response
    Cloud Security
    • Singularity Cloud Security
      Block Attacks with an AI-Powered CNAPP
    • Singularity Cloud Native Security
      Secure Cloud and Development Resources
    • Singularity Cloud Workload Security
      Real-Time Cloud Workload Protection Platform
    • Singularity Cloud Data Security
      AI-Powered Threat Detection for Cloud Storage
    • Singularity Cloud Security Posture Management
      Detect and Remediate Cloud Misconfigurations
    Securing AI
    • Prompt Security
      Secure AI Tools Across Your Enterprise
  • Why SentinelOne?
    Why SentinelOne?
    • Why SentinelOne?
      Cybersecurity Built for What’s Next
    • Our Customers
      Trusted by the World’s Leading Enterprises
    • Industry Recognition
      Tested and Proven by the Experts
    • About Us
      The Industry Leader in Autonomous Cybersecurity
    Compare SentinelOne
    • Arctic Wolf
    • Broadcom
    • CrowdStrike
    • Cybereason
    • Microsoft
    • Palo Alto Networks
    • Sophos
    • Splunk
    • Trellix
    • Trend Micro
    • Wiz
    Verticals
    • Energy
    • Federal Government
    • Finance
    • Healthcare
    • Higher Education
    • K-12 Education
    • Manufacturing
    • Retail
    • State and Local Government
  • Services
    Managed Services
    • Managed Services Overview
      Wayfinder Threat Detection & Response
    • Threat Hunting
      World-Class Expertise and Threat Intelligence
    • Managed Detection & Response
      24/7/365 Expert MDR Across Your Entire Environment
    • Incident Readiness & Response
      DFIR, Breach Readiness, & Compromise Assessments
    Support, Deployment, & Health
    • Technical Account Management
      Customer Success with Personalized Service
    • SentinelOne GO
      Guided Onboarding & Deployment Advisory
    • SentinelOne University
      Live and On-Demand Training
    • Services Overview
      Comprehensive Solutions for Seamless Security Operations
    • SentinelOne Community
      Community Login
  • Partners
    Our Network
    • MSSP Partners
      Succeed Faster with SentinelOne
    • Singularity Marketplace
      Extend the Power of S1 Technology
    • Cyber Risk Partners
      Enlist Pro Response and Advisory Teams
    • Technology Alliances
      Integrated, Enterprise-Scale Solutions
    • SentinelOne for AWS
      Hosted in AWS Regions Around the World
    • Channel Partners
      Deliver the Right Solutions, Together
    • SentinelOne for Google Cloud
      Unified, Autonomous Security Giving Defenders the Advantage at Global Scale
    • Partner Locator
      Your Go-to Source for Our Top Partners in Your Region
    Partner Portal→
  • Resources
    Resource Center
    • Case Studies
    • Data Sheets
    • eBooks
    • Reports
    • Videos
    • Webinars
    • Whitepapers
    • Events
    View All Resources→
    Blog
    • Feature Spotlight
    • For CISO/CIO
    • From the Front Lines
    • Identity
    • Cloud
    • macOS
    • SentinelOne Blog
    Blog→
    Tech Resources
    • SentinelLABS
    • Ransomware Anthology
    • Cybersecurity 101
  • About
    About SentinelOne
    • About SentinelOne
      The Industry Leader in Cybersecurity
    • Investor Relations
      Financial Information & Events
    • SentinelLABS
      Threat Research for the Modern Threat Hunter
    • Careers
      The Latest Job Opportunities
    • Press & News
      Company Announcements
    • Cybersecurity Blog
      The Latest Cybersecurity Threats, News, & More
    • FAQ
      Get Answers to Our Most Frequently Asked Questions
    • DataSet
      The Live Data Platform
    • S Foundation
      Securing a Safer Future for All
    • S Ventures
      Investing in the Next Generation of Security, Data and AI
  • Pricing
Get StartedContact Us
CVE Vulnerability Database
Vulnerability Database/CVE-2020-25696

CVE-2020-25696: PostgreSQL psql Terminal RCE Vulnerability

CVE-2020-25696 is a remote code execution flaw in PostgreSQL's psql interactive terminal that allows attackers to execute arbitrary code. This article covers technical details, affected versions, impact, and mitigation.

Published: March 4, 2026

CVE-2020-25696 Overview

A flaw was found in the psql interactive terminal of PostgreSQL that allows arbitrary code execution when a user connects to a compromised server. The vulnerability exists in multiple PostgreSQL versions before 13.1, 12.5, 11.10, 10.15, 9.6.20, and 9.5.24. When an interactive psql session uses the \gset meta-command while querying a malicious or compromised server, an attacker can execute arbitrary code as the operating system account running the psql client.

Critical Impact

Attackers controlling a compromised PostgreSQL server can achieve arbitrary code execution on client systems using the psql interactive terminal, threatening data confidentiality, integrity, and system availability.

Affected Products

  • PostgreSQL versions before 13.1
  • PostgreSQL versions before 12.5
  • PostgreSQL versions before 11.10
  • PostgreSQL versions before 10.15
  • PostgreSQL versions before 9.6.20
  • PostgreSQL versions before 9.5.24
  • Debian Linux 9.0

Discovery Timeline

  • 2020-11-23 - CVE-2020-25696 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2020-25696

Vulnerability Analysis

This vulnerability (CWE-183: Permissive List of Allowed Inputs, CWE-697: Incorrect Comparison) exists in the psql interactive terminal's handling of the \gset meta-command. The \gset command is designed to store query results as psql variables, which can then be used in subsequent commands or scripts. The flaw occurs because psql does not properly validate or sanitize server-controlled values before using them in contexts that could lead to code execution.

When a user connects to a malicious PostgreSQL server and issues a query using \gset, the server can return specially crafted data that, when processed by psql, results in arbitrary command execution. This is particularly dangerous in scenarios where users may connect to untrusted servers or in environments where a legitimate server has been compromised.

The attack requires network access and user interaction (the victim must execute a query with \gset against the malicious server), but once these conditions are met, full code execution is achieved with the privileges of the user running psql.

Root Cause

The root cause of this vulnerability is inadequate input validation in the psql client when processing server responses during \gset operations. The psql terminal allows variable assignment from query results without properly restricting what characters or escape sequences can be included in the values. This creates a permissive input handling scenario where attacker-controlled data from the server can influence client-side execution.

The vulnerability is classified under CWE-183 (Permissive List of Allowed Inputs) and CWE-697 (Incorrect Comparison), indicating that the input validation mechanisms were insufficient to prevent malicious payloads from being processed as executable content.

Attack Vector

The attack vector is network-based and requires the following conditions:

  1. The attacker must control or have compromised a PostgreSQL server
  2. A victim must connect to this malicious server using the psql interactive terminal
  3. The victim must execute a query using the \gset meta-command

The malicious server responds to the \gset query with specially crafted data containing escape sequences or shell metacharacters. When psql processes these values and assigns them to variables, the malicious content can be executed as operating system commands. This allows the attacker to run arbitrary code with the privileges of the user account running the psql client, potentially leading to complete system compromise.

The attack does not require any authentication on the attacker's part beyond controlling the server, and it exploits the trust relationship between the psql client and the server it connects to.

Detection Methods for CVE-2020-25696

Indicators of Compromise

  • Unusual outbound connections from psql client processes to unknown or suspicious PostgreSQL servers
  • Unexpected process spawning from psql sessions, particularly shell processes or command interpreters
  • Anomalous system calls or file operations initiated by psql processes
  • Evidence of shell command execution in psql session logs or command history

Detection Strategies

  • Monitor network traffic for psql connections to non-approved or external PostgreSQL servers
  • Implement endpoint detection rules to alert on child process creation from psql binaries
  • Review psql command history files for suspicious \gset usage patterns
  • Deploy behavioral analysis to detect psql processes executing unexpected system commands

Monitoring Recommendations

  • Enable comprehensive logging of psql sessions and database connections
  • Configure network monitoring to track all PostgreSQL protocol traffic (port 5432)
  • Implement file integrity monitoring on systems where psql is frequently used
  • Establish baseline behavior patterns for psql usage and alert on deviations

How to Mitigate CVE-2020-25696

Immediate Actions Required

  • Upgrade PostgreSQL to patched versions: 13.1, 12.5, 11.10, 10.15, 9.6.20, or 9.5.24 immediately
  • Restrict psql client connections to only trusted, known PostgreSQL servers
  • Implement network segmentation to limit exposure of psql clients to untrusted networks
  • Educate users about the risks of connecting to untrusted database servers

Patch Information

PostgreSQL has released security updates addressing this vulnerability across all supported versions. The PostgreSQL Release Announcement provides details on the patched releases: PostgreSQL 13.1, 12.5, 11.10, 10.15, 9.6.20, and 9.5.24. Organizations should upgrade to these versions or later to remediate this vulnerability. Additional vendor information is available in the Red Hat Bug Report #1894430. Debian users should refer to the Debian LTS Announcement December 2020, and Gentoo users should consult Gentoo GLSA 202012-07.

Workarounds

  • Avoid using \gset commands when connected to untrusted or unknown PostgreSQL servers
  • Use read-only connections and restrict interactive psql usage in production environments
  • Implement strict network access controls to prevent psql clients from connecting to unauthorized servers
  • Consider using connection poolers or proxy solutions that can inspect and filter PostgreSQL traffic
bash
# Configuration example - Restrict PostgreSQL client connections
# In pg_hba.conf on trusted servers, ensure only known hosts can connect
# Additionally, configure firewall rules to limit outbound connections

# Example iptables rule to restrict psql outbound connections
iptables -A OUTPUT -p tcp --dport 5432 -d trusted_server_ip -j ACCEPT
iptables -A OUTPUT -p tcp --dport 5432 -j DROP

Disclaimer: This content was generated using AI. While we strive for accuracy, please verify critical information with official sources.

  • Vulnerability Details
  • TypeRCE

  • Vendor/TechPostgresql

  • SeverityHIGH

  • CVSS Score7.5

  • EPSS Probability0.47%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:H/PR:N/UI:R/S:U/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityHigh
  • IntegrityHigh
  • AvailabilityHigh
  • CWE References
  • CWE-183

  • CWE-697
  • Technical References
  • Debian LTS Announcement December 2020

  • Gentoo GLSA 202012-07
  • Vendor Resources
  • Red Hat Bug Report #1894430

  • PostgreSQL Release Announcement
  • Related CVEs
  • CVE-2025-13957: Hard-coded Credentials RCE Vulnerability

  • CVE-2026-2004: PostgreSQL intarray Extension RCE Flaw

  • CVE-2026-2006: PostgreSQL RCE Vulnerability

  • CVE-2023-5869: PostgreSQL RCE Vulnerability
Default Legacy - Prefooter | Experience the World’s Most Advanced Cybersecurity Platform

Experience the World’s Most Advanced Cybersecurity Platform

See how our intelligent, autonomous cybersecurity platform can protect your organization now and into the future.

Try SentinelOne
  • Get Started
  • Get a Demo
  • Product Tour
  • Why SentinelOne
  • Pricing & Packaging
  • FAQ
  • Contact
  • Contact Us
  • Customer Support
  • SentinelOne Status
  • Language
  • Platform
  • Singularity Platform
  • Singularity Endpoint
  • Singularity Cloud
  • Singularity AI-SIEM
  • Singularity Identity
  • Singularity Marketplace
  • Purple AI
  • Services
  • Wayfinder TDR
  • SentinelOne GO
  • Technical Account Management
  • Support Services
  • Verticals
  • Energy
  • Federal Government
  • Finance
  • Healthcare
  • Higher Education
  • K-12 Education
  • Manufacturing
  • Retail
  • State and Local Government
  • Cybersecurity for SMB
  • Resources
  • Blog
  • Labs
  • Case Studies
  • Videos
  • Product Tours
  • Events
  • Cybersecurity 101
  • eBooks
  • Webinars
  • Whitepapers
  • Press
  • News
  • Ransomware Anthology
  • Company
  • About Us
  • Our Customers
  • Careers
  • Partners
  • Legal & Compliance
  • Security & Compliance
  • Investor Relations
  • S Foundation
  • S Ventures

©2026 SentinelOne, All Rights Reserved.

Privacy Notice Terms of Use

English