Another PostgreSQL COPY Protocol Flaw: CVE-2026-31431 PoC Drops

4 min read 6 sources breaking
├── "PostgreSQL's COPY protocol is a systemic attack surface that demands architectural rethinking, not just patching"
│  └── top10.dev editorial (top10.dev) → read below

The editorial argues that two major COPY protocol CVEs from the same research firm in under two years reveals a pattern, not a coincidence. It emphasizes that COPY's ability to read/write files, execute shell commands, and handle complex protocol state transitions creates an enormous attack surface that has proven repeatedly difficult to secure.

├── "Theori's repeated discoveries validate deep, focused security research on core database internals"
│  └── theori-io (GitHub, 2185 pts) → read

By publishing a second proof-of-concept exploit targeting the same PostgreSQL subsystem (COPY FAIL message handling), Theori demonstrates the value of sustained research into a single protocol family. Their first find (CVE-2025-1094) emerged from analyzing the BeyondTrust attack chain, and this follow-up suggests they continued auditing COPY protocol internals systematically.

└── "The rapid community attention signals high real-world exposure and urgency to patch"
  └── @GitHub community (GitHub, 2185 pts) → view

The repository accumulated over 2,100 stars rapidly, indicating widespread concern among security practitioners and database administrators. This level of engagement suggests many organizations recognize they may be directly affected, given PostgreSQL's ubiquity and the COPY protocol's common use in ETL pipelines and data ingestion workflows.

What happened

South Korean security research firm Theori has published a proof-of-concept exploit repository for CVE-2026-31431, a new vulnerability in PostgreSQL's COPY protocol. The repo, [theori-io/copy-fail-CVE-2026-31431](https://github.com/theori-io/copy-fail-CVE-2026-31431), has already accumulated over 2,100 GitHub stars — a clear signal that the security community is paying close attention.

This is the second time in under two years that Theori has found a significant vulnerability in PostgreSQL's COPY subsystem. The first, CVE-2025-1094, disclosed in early 2025, exploited improper handling of malformed UTF-8 byte sequences in `COPY...FROM PROGRAM` to achieve SQL injection. That vulnerability affected PostgreSQL versions through 17.x and required emergency patches across every supported branch. It was initially discovered during Theori's analysis of the BeyondTrust CVE-2024-12356 attack chain, where the PostgreSQL flaw turned out to be the actual mechanism attackers used to achieve remote code execution.

Now CVE-2026-31431 targets a different aspect of the same protocol family — the COPY FAIL message handling path. The naming convention (the "copy-fail" prefix in the repo name) suggests the vulnerability lies in how PostgreSQL processes error conditions during COPY operations, specifically when the client sends a CopyFail message to abort a COPY transfer.

Why it matters

### The COPY protocol is PostgreSQL's most powerful — and most dangerous — feature

PostgreSQL's COPY protocol is unlike anything in MySQL or SQL Server. It provides a direct, high-speed data pipeline between the server and external sources — files, programs, network streams. This power comes with an enormous attack surface: COPY can read and write server-side files, execute shell commands (via `COPY...FROM PROGRAM`), and handles complex protocol state transitions that have proven difficult to secure.

The pattern is now unmistakable. In 2024, researchers found that BeyondTrust's remote access vulnerability was ultimately exploitable because of a PostgreSQL COPY flaw. In 2025, CVE-2025-1094 showed that even the character encoding validation in COPY paths was insufficient. Now in 2026, CVE-2026-31431 reveals that the error-handling path — the CopyFail message flow — contains its own exploitable weakness.

Each discovery has been in a different part of the same subsystem. This isn't the same bug being reintroduced; it's a pattern where a protocol designed for maximum flexibility keeps revealing new ways that flexibility can be weaponized.

### Theori's track record demands attention

Theori isn't a typical CVE mill. The Seoul-based firm specializes in deep binary and protocol-level analysis, and their PostgreSQL work has consistently uncovered vulnerabilities that other researchers missed. Their CVE-2025-1094 discovery was notable because it emerged from investigating an entirely separate product's vulnerability — they followed the attack chain down to its root cause and found a zero-day in PostgreSQL itself. That kind of thoroughness explains why the security community responds rapidly when Theori publishes a new PoC.

The fact that they've published a full proof-of-concept repository (not just an advisory) means defenders and attackers alike have working exploit code. The 2,100+ stars reflect both security researchers studying the PoC and operations teams assessing their exposure.

### The COPY FAIL message path

In the PostgreSQL wire protocol, a COPY operation involves a specific sub-protocol with its own message types: CopyInResponse, CopyData, CopyDone, and CopyFail. The CopyFail message is sent by the client to abort a COPY operation, and it includes an error message string. The server is supposed to handle this gracefully — roll back the partial COPY, report the error, and return to normal query processing.

The vulnerability likely exists in how the server processes the error message content or manages state transitions when CopyFail arrives at unexpected points in the protocol flow. Protocol state machine bugs are notoriously hard to catch through standard testing because they require sending malformed or out-of-sequence messages that normal client libraries would never generate.

What this means for your stack

### Immediate actions

Check your PostgreSQL version and watch for the official PostgreSQL security release. Given Theori's responsible disclosure track record (CVE-2025-1094 had patches available at disclosure time), patches are likely already available or imminent. If you're running PostgreSQL in any environment where untrusted clients can initiate COPY operations — which includes many application stacks that use COPY for bulk imports — you should treat this as a priority patch.

Audit your COPY usage. Most application code doesn't use COPY directly, but many ETL pipelines, data import tools, and backup systems do. Check whether your pg_hba.conf restricts which users and hosts can execute COPY commands. If you're using connection poolers like PgBouncer, verify that they properly handle COPY protocol messages — poolers that don't fully implement the COPY sub-protocol may inadvertently provide a different attack surface.

Review extension trust levels. PostgreSQL extensions that use COPY internally (including some popular ones for foreign data wrappers and bulk loading) may expose the vulnerable code path even if your application code doesn't use COPY directly.

### The broader pattern

For teams evaluating database security posture, the recurring COPY vulnerabilities suggest a systemic issue. PostgreSQL's COPY protocol was designed in an era when the database was trusted infrastructure behind application servers, not a service exposed to potentially hostile clients through connection poolers, serverless functions, and multi-tenant platforms. The protocol's power — direct file I/O, program execution, streaming data transfer — is exactly what makes it a persistent target.

If you're running PostgreSQL in a multi-tenant or edge-exposed configuration, consider whether `pg_hba.conf` rules and role-based COPY restrictions are sufficient, or whether you need network-level segmentation to limit who can speak the wire protocol directly to your database.

Looking ahead

Theori's systematic exploration of the COPY protocol subsystem suggests they may not be done. The protocol has multiple message types, encoding paths, and state transitions — each a potential vulnerability surface. For the PostgreSQL core team, this likely means a broader audit of the COPY protocol implementation is warranted, not just point fixes for individual CVEs. For the rest of us, it means keeping PostgreSQL patching in the "immediate" category, not the "next maintenance window" bucket.

GitHub 3264 pts 376 comments

cursor/cookbook: New trending repository

→ read on GitHub
GitHub 3057 pts 636 comments

theori-io/copy-fail-CVE-2026-31431: New trending repository

→ read on GitHub
GitHub 1927 pts 206 comments

denuitt1/mhr-cfw: New trending repository

→ read on GitHub
GitHub 835 pts 308 comments

wrongly-cuddly-obsession/NTSB_FOIA_MU5735: New trending repository

→ read on GitHub
GitHub 635 pts 59 comments

deepseek-ai/awesome-deepseek-agent: New trending repository

→ read on GitHub
GitHub 359 pts 1027 comments

amirshaker000/netlify-relay: New trending repository

→ read on GitHub

// share this

// get daily digest

Top 10 dev stories every morning at 8am UTC. AI-curated. Retro terminal HTML email.