The SentinelOne Annual Threat Report - A Defenders Guide from the FrontlinesThe SentinelOne Annual Threat ReportGet the Report
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
    • 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-2021-23214

CVE-2021-23214: PostgreSQL SQLI Vulnerability

CVE-2021-23214 is a SQL injection vulnerability in PostgreSQL that allows man-in-the-middle attackers to inject arbitrary SQL queries during connection establishment. This article covers technical details, affected versions, impact, and mitigation strategies.

Published: February 25, 2026

CVE-2021-23214 Overview

CVE-2021-23214 is a Man-in-the-Middle SQL Injection vulnerability affecting PostgreSQL database servers. When the server is configured to use trust authentication with a clientcert requirement or to use cert authentication, a man-in-the-middle attacker can inject arbitrary SQL queries when a connection is first established, despite the use of SSL certificate verification and encryption.

Critical Impact

Attackers can inject malicious SQL queries during the SSL handshake phase, potentially leading to unauthorized data access, data manipulation, or complete database compromise even when SSL encryption is enabled.

Affected Products

  • PostgreSQL (multiple versions including 14.0)
  • Fedora 34 and 35
  • Red Hat Enterprise Linux 8.0
  • Red Hat Software Collections 1.0
  • Red Hat Enterprise Linux for IBM z Systems 8.0
  • Red Hat Enterprise Linux for Power Little Endian 8.0

Discovery Timeline

  • 2022-03-04 - CVE-2021-23214 published to NVD
  • 2024-11-21 - Last updated in NVD database

Technical Details for CVE-2021-23214

Vulnerability Analysis

This vulnerability exploits a race condition in PostgreSQL's SSL/TLS connection establishment process. The flaw allows an attacker positioned between a client and server to inject data into the connection buffer before the SSL handshake completes. Due to improper validation of buffered data during the transition from unencrypted to encrypted communication, PostgreSQL would process data received before encryption was established as if it were legitimate encrypted traffic.

The vulnerability is particularly dangerous because it bypasses the security guarantees that SSL/TLS certificate authentication is supposed to provide. Organizations relying on client certificates for database authentication believed they had strong security controls in place, but this flaw undermined those protections entirely. The attack requires the attacker to be in a network position to intercept traffic (man-in-the-middle), which adds complexity but is achievable in many enterprise and cloud environments.

Root Cause

The root cause lies in PostgreSQL's failure to verify that no data was buffered before the SSL handshake completed. The server's connection handling code would accept and process any data that arrived in the receive buffer prior to SSL negotiation, treating it as legitimate post-encryption traffic. This design oversight meant that an attacker could send malicious SQL commands during the brief window between initial TCP connection and SSL establishment, and those commands would be executed with the privileges of the authenticated user.

Attack Vector

The attack requires a network-level man-in-the-middle position between the PostgreSQL client and server. The attacker intercepts the initial connection attempt and injects arbitrary SQL queries into the data stream before the SSL handshake completes. When the legitimate SSL connection is established and the client authenticates via certificate, the previously injected SQL commands are processed as if they came from the authenticated client. This allows the attacker to execute queries with the full privileges of the certificate-authenticated user, which often has elevated database permissions.

c
// Security patch in src/backend/postmaster/postmaster.c
// Source: https://github.com/postgres/postgres/commit/28e24125541545483093819efae9bca603441951

 			return STATUS_ERROR;
 #endif
 
+		/*
+		 * At this point we should have no data already buffered.  If we do,
+		 * it was received before we performed the SSL handshake, so it wasn't
+		 * encrypted and indeed may have been injected by a man-in-the-middle.
+		 * We report this case to the client.
+		 */
+		if (pq_buffer_has_data())
+			ereport(FATAL,
+					(errcode(ERRCODE_PROTOCOL_VIOLATION),
+					 errmsg("received unencrypted data after SSL request"),
+					 errdetail("This could be either a client-software bug or evidence of an attempted man-in-the-middle attack.")));
+
 		/*
 		 * regular startup packet, cancel, etc packet should follow, but not
 		 * another SSL negotiation request, and a GSS request should only

The patch adds a new function pq_buffer_has_data() to check for buffered data and validates that no unencrypted data exists in the buffer after SSL handshake:

c
// Security patch in src/backend/libpq/pqcomm.c
// Source: https://github.com/postgres/postgres/commit/28e24125541545483093819efae9bca603441951

 	return 0;
 }
 
+/* --------------------------------
+ *		pq_buffer_has_data		- is any buffered data available to read?
+ *
+ * This will *not* attempt to read more data.
+ * --------------------------------
+ */
+bool
+pq_buffer_has_data(void)
+{
+	return (PqRecvPointer < PqRecvLength);
+}
+
 
 /* --------------------------------
  *		pq_startmsgread - begin reading a message from the client.

Detection Methods for CVE-2021-23214

Indicators of Compromise

  • PostgreSQL error logs containing "received unencrypted data after SSL request" messages (indicates patched server detected attack attempt)
  • Unusual SQL query patterns immediately following client certificate authentication
  • Network traffic anomalies showing data injection between TCP SYN and SSL handshake completion
  • Database audit logs showing queries executed that don't match client application patterns

Detection Strategies

  • Deploy network intrusion detection systems (IDS) to monitor for anomalous traffic patterns during PostgreSQL SSL handshake sequences
  • Enable PostgreSQL logging with log_connections = on and log_statement = all to capture authentication and query activity
  • Implement database activity monitoring (DAM) solutions to detect suspicious query patterns from certificate-authenticated connections
  • Use SentinelOne Singularity to monitor PostgreSQL process behavior and detect anomalous database operations

Monitoring Recommendations

  • Configure alerting for PostgreSQL protocol violation errors in application and system logs
  • Monitor for unexpected database schema changes or data exfiltration patterns
  • Establish baseline network behavior for PostgreSQL connections and alert on deviations during connection establishment
  • Review certificate authentication logs for connections that execute unexpected administrative queries

How to Mitigate CVE-2021-23214

Immediate Actions Required

  • Upgrade PostgreSQL to a patched version immediately (versions released after November 2021)
  • Audit database logs for any suspicious activity that may indicate prior exploitation
  • Review network architecture to minimize exposure of PostgreSQL servers to potential MITM positions
  • Consider implementing additional network-level encryption (VPN, IPsec) for database traffic in sensitive environments

Patch Information

PostgreSQL has released security patches addressing this vulnerability. The fix introduces the pq_buffer_has_data() function to detect and reject any data present in the receive buffer after SSL handshake completion. Patched servers will terminate connections with a FATAL error if pre-handshake data is detected, logging a message indicating a potential man-in-the-middle attack.

For detailed patch information, refer to the PostgreSQL Security Advisory for CVE-2021-23214 and the GitHub commit 28e24125. Red Hat users should consult the Red Hat Bug Report for distribution-specific patches.

Workarounds

  • Implement network segmentation to isolate PostgreSQL servers and reduce MITM attack surface
  • Use VPN tunnels or IPsec for all PostgreSQL client-server communication as an additional encryption layer
  • Deploy PostgreSQL behind a reverse proxy or load balancer that performs SSL termination in a trusted network zone
  • Consider temporarily disabling remote certificate-based authentication if patching is not immediately possible
bash
# Configuration example - Enable comprehensive PostgreSQL logging for detection
# Add to postgresql.conf

# Enable connection logging
log_connections = on
log_disconnections = on

# Log all statements for forensic analysis
log_statement = 'all'

# Enable SSL debugging (temporary for investigation)
ssl = on
ssl_cert_file = '/path/to/server.crt'
ssl_key_file = '/path/to/server.key'
ssl_ca_file = '/path/to/ca.crt'

# Require SSL for all connections
# In pg_hba.conf, use 'hostssl' instead of 'host'

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

  • Vulnerability Details
  • TypeSQLI

  • Vendor/TechPostgresql

  • SeverityHIGH

  • CVSS Score8.1

  • EPSS Probability0.33%

  • Known ExploitedNo
  • CVSS Vector
  • CVSS:3.1/AV:N/AC:H/PR:N/UI:N/S:U/C:H/I:H/A:H
  • Impact Assessment
  • ConfidentialityHigh
  • IntegrityNone
  • AvailabilityHigh
  • CWE References
  • CWE-89
  • Technical References
  • PostgreSQL Commit Log

  • Gentoo GLSA 202211-04
  • Vendor Resources
  • Red Hat Bug Report

  • GitHub PostgreSQL Commit

  • PostgreSQL Security Advisory CVE-2021-23214
  • Related CVEs
  • CVE-2024-1597: PostgreSQL JDBC Driver SQLi Vulnerability

  • CVE-2025-1094: PostgreSQL libpq SQL Injection Vulnerability

  • CVE-2023-39417: PostgreSQL SQL Injection Vulnerability

  • CVE-2020-25695: PostgreSQL SQL Injection Vulnerability
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