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
    • 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-2021-23214

CVE-2021-23214: PostgreSQL SQL Injection Vulnerability

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

Updated: May 16, 2026

CVE-2021-23214 Overview

CVE-2021-23214 affects PostgreSQL servers configured to use trust authentication with a clientcert requirement or cert authentication. A man-in-the-middle (MITM) attacker positioned on the network path can inject arbitrary SQL queries during the initial connection establishment. The injection succeeds despite SSL certificate verification and encryption being enabled. The vulnerability stems from how the server processed unencrypted bytes received before the TLS handshake completed, allowing those bytes to be treated as authenticated SQL input.

Critical Impact

An authenticated network attacker can execute arbitrary SQL statements against the PostgreSQL backend with the privileges of the connecting user, leading to data tampering, disclosure, or destruction.

Affected Products

  • PostgreSQL versions prior to 14.1, 13.5, 12.9, 11.14, 10.19, and 9.6.24
  • Red Hat Enterprise Linux 8 and Red Hat Software Collections 1.0
  • Fedora 34 and Fedora 35

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

The flaw resides in the PostgreSQL backend protocol handling during the connection startup phase. When a client requests SSL with the SSLRequest message, the server responds with S and proceeds with the TLS handshake. The server failed to discard any additional bytes buffered before TLS negotiation completed. An attacker controlling the network path could prepend attacker-chosen plaintext bytes to the connection stream. Those bytes were later parsed as authenticated protocol messages after the TLS session was established.

This behavior maps to [CWE-89: SQL Injection], because adversary-controlled bytes ultimately reach the SQL parser as if they originated from the trusted client. The issue is exploitable only when authentication does not bind the client identity to the SQL session through the encrypted channel, which is the case for trust with clientcert and cert authentication modes.

Root Cause

The root cause is improper handling of pre-TLS buffered input in backend/libpq/pqcomm.c. The server consumed network bytes into its receive buffer prior to enabling encryption and did not flush that buffer when TLS started. The fix, committed as 28e2412554 in the PostgreSQL repository, discards any unread bytes from the socket before initiating the encrypted session.

Attack Vector

Exploitation requires a network-positioned attacker capable of modifying packets between the client and PostgreSQL server. The attacker injects SQL statements into the TCP stream before the TLS handshake completes. Once the legitimate client authenticates through the certificate-based mechanism, the server executes the injected statements under that user's identity. No prior credentials are required because authentication relies solely on the client certificate and not on a challenge bound to the TLS channel.

The vulnerability manifests during connection startup and cannot be triggered after a session is fully established. Refer to the PostgreSQL CVE-2021-23214 advisory for protocol-level details.

Detection Methods for CVE-2021-23214

Indicators of Compromise

  • Unexpected SQL statements in PostgreSQL log_statement output that do not correlate with application activity from the same client session
  • Connections originating from network paths or proxies that should not handle PostgreSQL traffic on port 5432
  • TLS handshakes preceded by unusually large amounts of pre-handshake data on the PostgreSQL listener

Detection Strategies

  • Enable log_statement = 'all' and log_connections = on to correlate executed SQL with authenticated session identities
  • Monitor for divergence between application-issued queries and queries observed in PostgreSQL audit logs using pgaudit
  • Inspect network telemetry for anomalies in the PostgreSQL startup protocol, particularly bytes transmitted before TLS negotiation

Monitoring Recommendations

  • Forward PostgreSQL logs to a centralized SIEM and alert on schema-modifying statements from service accounts that normally only execute reads
  • Baseline TLS handshake patterns on database listeners and alert on deviations indicative of MITM interception
  • Track certificate-based authentication events and correlate with source IP and ARP table changes on database network segments

How to Mitigate CVE-2021-23214

Immediate Actions Required

  • Upgrade PostgreSQL to 14.1, 13.5, 12.9, 11.14, 10.19, 9.6.24, or later
  • Apply vendor updates from Red Hat, Fedora, and Gentoo as documented in Gentoo GLSA 202211-04
  • Review pg_hba.conf for entries using trust with clientcert or cert authentication and audit recent connections from those sources

Patch Information

The PostgreSQL Global Development Group released fixed builds on November 11, 2021. The upstream fix is commit 28e24125541545483093819efae9bca603441951, which clears any buffered plaintext before initiating TLS. See the PostgreSQL commit details and the Red Hat bug report for distribution-specific package versions.

Workarounds

  • Replace trust and cert authentication with scram-sha-256 so that authentication is cryptographically bound to user-supplied secrets in addition to certificates
  • Restrict PostgreSQL listeners to trusted network segments using firewall rules and listen_addresses configuration
  • Require mutual TLS through a dedicated network appliance that terminates and re-originates database connections to remove untrusted intermediaries
bash
# Configuration example: pg_hba.conf hardening
# Replace cert-only entries with password-bound authentication
hostssl all all 10.0.0.0/8 scram-sha-256 clientcert=verify-full

# Verify installed PostgreSQL version against fixed releases
psql -V
# Expected output: psql (PostgreSQL) 14.1 or later

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.19%

  • 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 Details

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

  • GitHub PostgreSQL Commit

  • PostgreSQL CVE-2021-23214 Details
  • Related CVEs
  • CVE-2025-1094: PostgreSQL libpq SQL Injection Vulnerability

  • CVE-2024-1597: PostgreSQL JDBC Driver SQLi Vulnerability

  • CVE-2023-39417: PostgreSQL SQL Injection Vulnerability

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